471,330 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

askopenfilename() as root window

Is there any way to open a Tkinter.askopenfilename() without opening a
root window alongside the file chooser?

I simply want a script to open a dialog and return the chosen file's
path to stdout.

"""
from tkFileDialog import askopenfilename

print askopenfilename()
"""

....does the job, but it opens that nagging root window beside it. I
tried setting parent=None to no avail. The second window always shows
up. Any ideas?

~Sean
Dec 19 '07 #1
2 3562
On 18 dic, 22:43, Sean DiZazzo <half.ital...@gmail.comwrote:
Is there any way to open a Tkinter.askopenfilename() without opening a
root window alongside the file chooser?

I simply want a script to open a dialog and return the chosen file's
path to stdout.
Yes, create the root yourself so you can call the withdraw() method:

root = Tk()
root.withdraw()
print askopenfilename()

--
Gabriel Genellina
Dec 19 '07 #2
On Dec 18, 6:06 pm, Gabriel Genellina <gagsl-...@yahoo.com.arwrote:
On 18 dic, 22:43, Sean DiZazzo <half.ital...@gmail.comwrote:
Is there any way to open a Tkinter.askopenfilename() without opening a
root window alongside the file chooser?
I simply want a script to open a dialog and return the chosen file's
path to stdout.

Yes, create the root yourself so you can call the withdraw() method:

root = Tk()
root.withdraw()
print askopenfilename()

--
Gabriel Genellina
As usual... Thank you Gabriel.
Dec 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Justin Straube | last post: by
reply views Thread by half.italian | last post: by
3 posts views Thread by rahulnag22 | last post: by
reply views Thread by Gabriel Genellina | last post: by
reply views Thread by rosydwin | 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.