How to have windows automatically add an extension to a file?

python, python-2.7, tkinter, windows

Solution

Try using `defaultextension`:

tkF.askopenfilename(initialdir='D:\\',
filetypes=myFormat,
title="Open a .mydoc",
defaultextension=".mydoc")

Problem

Background I am currently in the process of making a basic text editor in hopes of gaining a basic understanding of Tkinter. I want to make my own file format called `.mydoc` I have attempted to change the `filetype` to `.mydoc` to no prevail. This is the code that I currently have: Code ``` def openMe(self): #import the Tk file dialogue import tkFileDialog as tkF myFormat = [('Example Format', '*.mydoc')] direct = tkF.askopenfilename(initialdir='D:\\', filetypes = myFormat, title = "Open a .mydoc") try: #open the text file txt_file = open(direct,"r") except UnboundLocalError, IOError: print "You either did not select a file, or the filetype was incorrect.\nPlease try again." #Read the data currentTEXT = txt_file.read() #Delete current text self.write.delete(0.0, END) #insert new text self.write.insert(0.0, currentTEXT) ``` Question - How can I have the computer automatically add my extension? (And yes, I have turned off the `hide extensions` option. Tech Specs Language: Python 2.7.3 OS: Windows 7

Original source