empty window when using askopenfile

S

Sorin Gherman

Is there any way to minimize/hide the annoying default, empty Tk
window that shows behind the native file opening dialog , when using
askopenfile, etc, in tkCommonDialog?

I am using Python 2.3.2 on winXP.

Thanks in advance,
Sorin Gherman
 
F

Fredrik Lundh

Sorin said:
Is there any way to minimize/hide the annoying default, empty Tk
window that shows behind the native file opening dialog , when using
askopenfile, etc, in tkCommonDialog?

explicitly create the root window, and withdraw it from the
screen before you call askopenfile:

import Tkinter

root = Tkinter.Tk()
root.withdraw()

file = tkFileDialog.askopenfile(...)

</F>

Got Tkinter questions?
http://mail.python.org/mailman/listinfo/tkinter-discuss
has the answers.
 
P

Peter Otten

Sorin said:
Is there any way to minimize/hide the annoying default, empty Tk
window that shows behind the native file opening dialog , when using
askopenfile, etc, in tkCommonDialog?

import Tkinter, tkFileDialog
root = Tkinter.Tk()
root.withdraw()
tkFileDialog.askopenfile()

Peter
 
L

Lonnie Princehouse

Is there any way to minimize/hide the annoying default, empty Tk
window that shows behind the native file opening dialog , when using
askopenfile, etc, in tkCommonDialog?


Ah, the pesky Tk root window. You can minimize it, but I don't think
you can make it disappear completely (without nuking the rest of Tk).

Try this-

import Tkinter, tkFileDialog

tkroot = Tkinter.Tk()
tkroot.iconify()

tkFileDialog.askopenfile()

# If you're not doing anything with Tk besides prompting for the file,
# you'll want to get ride of the root window after askopenfile-
tkroot.destroy()


Alternately, you could just put a pretty picture in the root window
and call it a feature =)
 

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,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top