tkFileDialog without a parent window

klappnase klappnase at freenet.de
Sat Jul 19 21:41:25 EDT 2003


Stephen Boulet <stephen.boulet at motorola.com> wrote in message news:<be21e4$trp$1 at localhost.localdomain>...
> I'm using the following code to get a file name:
> 
>     import tkFileDialog
>     tkFileDialog.askopenfilename(filetypes=[("HDF Files", ".hdf")])
> 
> How can I do this without an empty tk window popping up and hanging around 
> after the dialog is closed? Thanks.
> 
> -- Stephen

Hi,

you may use the withdraw() method on the root window:

root = Tk()
root.withdraw()
somefile = tkFileDialog.askopenfilename(filetypes=[("HDF Files", ".hdf")])
...

Cheers

michael




More information about the Python-list mailing list