Tkinter File Dialog Question

Jeff Epler jepler at unpythonic.net
Mon Nov 4 09:08:41 EST 2002


When the tk file dialog window is closed, the window is not actually
destroyed.  If you don't mind being a little bit dirty, you can peek in
and see what text was displayed in the 'file type' when it was
dismissed.

Of course, this doesn't work on Windows (where the dialog is native, not
constructed from Tk widgets) and the paths may change from version to
version.

If 'w' is some widget, just run
    label = w.tk.call(".__tk_filedialog.f3.menu", "cget", "-text")
    m = re.search("\(\*\.([^,]*)", label)
    extension = m.group(1)
    print extension
this worked for me.  I think that my python is using tk8.3 for Tkinter.
The OS is Linux.

Jeff




More information about the Python-list mailing list