Problems with the tkFileDialog widget

Eric Melski ericm at ajubasolutions.com
Mon Oct 9 16:18:28 EDT 2000


On Sun, 8 Oct 2000, Hans Kristian Ruud wrote:

> I have added a tkFileDialog widget to an application:
> 
> .
> .
>         xlsfile = tkFileDialog.Open (root,
>                 filetypes=[('Excel files','*.xls')],
>                  initialfile=filename,
>                  title='Result spreadsheet').show()
> .
> .

Are you running on Windows?  There is some sort of issue with the Windows
event loop interacting badly with the Tk event loop when the Windows loop
gets kicked off first.  It's sort of a race condition, and you can hit it
when the very first thing in your script that gets a chance to display
anything is a call to tkFileDialog.  Basically, the Windows event loop
gets started first and prevents the Tk event loop from starting
properly, so your normal Tk events never get processed.  You can work
around it by putting a call to "update" immediately before the call to
tkFileDialog.  I'm sorry, I don't know the exact syntax for that call, as
I'm a Tcl/Tk guy, not a Tkinter guy.

Hope this helps,

   Eric Melski                            The Other Tcl Guy
   ericm at ajubasolutions.com            Ajuba Solutions




More information about the Python-list mailing list