471,055 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,055 software developers and data experts.

empty window when using askopenfile

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
3 3501
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
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
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.

Similar topics

4 posts views Thread by tornado | last post: by
8 posts views Thread by Ricky K. Rasmussen | last post: by
4 posts views Thread by Raed Sawalha | last post: by
10 posts views Thread by Charles Hunt | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.