tkFileDialog without a parent window

S

Stephen Boulet

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
 
M

Mike Abel

Stephen Boulet said:
How can I do this without an empty tk window popping up and hanging around
after the dialog is closed? Thanks.


Well i think this is probably a problem in your script not a
problem from tkFileDialog.

Mike
 
K

klappnase

Stephen Boulet said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top