El Confuso
El Confuso

Reputation: 1981

Calling tkFileDialog without opening a parent window

Is there a way to call tkFileDialog.askdirectory() without opening a parent tk window? This is annoying and (for me) goes unresponsive when I try to close it.

Thanks

Upvotes: 2

Views: 1754

Answers (1)

Malik Brahimi
Malik Brahimi

Reputation: 16711

Unfortunately, you will need to instantiate a root window, but you can hide it programmatically.

from Tkinter import *
from tkFileDialog import *

root = Tk()
root.withdraw() # hide root

path = askdirectory()
root.mainloop()

Upvotes: 4

Related Questions