By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,539 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,539 IT Pros & Developers. It's quick & easy.

empty window when using askopenfile

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Sorin Gherman wrote:
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

Jul 18 '05 #2

P: n/a
Sorin Gherman wrote:
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.


Jul 18 '05 #3

P: n/a
s_*******@yahoo.com (Sorin Gherman) wrote in message news:<ac**************************@posting.google. com>...
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 =)
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.