[Tkinter-discuss] askopenfilename

CAB cabraut at yahoo.com
Mon Feb 27 21:55:12 CET 2012

I am observing some strange behavior in askopenfilename.  I am working 
under Python 2.7 on a Windows7 system.  Let's say I have the following 
bit of code:

f = askopenfilename(parent=root, filetypes=[('Text', '.txt'), ('Documents', '.doc'), ('All Files', '*.*')])

 the Open File dialog opens, it has a pulldown list of the filetypes.  
That's great.  However, in my hands, the filetype that is chosen by 
default by tkinter in that list changes from call to call.  That is, on 
some occasions, the default selection in that dropdown is "Text 
(*.txt)".  Other times, from the same bit of code, the default selction 
is "All Files (*.*)".  It always seems to default to either the first 
item in the list or the last item.

I wish I could post the code 
in which I observe this behavior, but it is quite complex and long.  I 
can't recapitulate the behavior in a little jiffy that I wrote to test 
this.  In that jiffy, the default item selected in the pulldown filetype
 list is *always* the first item in the list.

And so, I guess my 
question is, what would cause askopenfilename to default this pulldown list to 
the last item?  Is there any way to tell it which item in the list to 
select as the default?  I can't find anything in the docs that helps.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20120227/8cddb4e9/attachment.html>

More information about the Tkinter-discuss mailing list