[Tutor] tkinter.filedialog?

Jim Byrnes jf_byrnes at comcast.net
Wed Jun 25 03:37:58 CEST 2014


I am working with some demo programs in a breezypythongui book.  One 
program contains these two lines:

filetypes = [ ("Python files", "*.py"), ("Text files", "*.txt")]
fileName = tkinter.filedialog.askopenfilename(parent = self,
                    filetypes = filetypes)

According to the book this should open a file dialog and show .py and 
.txt files, but it only shows .py files.  Thinking that maybe it had 
something to do with the breezypythongui implementation, I opened a 
terminal and tried:

Python 3.3.5 (default, Mar 12 2014, 02:09:17)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> import tkinter.filedialog
 >>> filetypes = [("Python files", "*.py"), ("Text files", "*.txt")]
 >>> fileName = tkinter.filedialog.askopenfilename(filetypes = filetypes)

It pops up a file dialog but again only .py files are shown.

Why is it that both .py and .txt files are not shown?  It seems to be 
the correct way to do it.

Thanks,  Jim



More information about the Tutor mailing list