Hello!

As the title suggests I need some help regarding an "open directory" dialog box.

I tried this code but every time I run the module it appears a blank window in the back of the dialog box and normally after I select the directory it should disappear but it still remains in the background and only if I close it manually it stops. What`s the problem with this? How can I fix it or how can I replace this code with something else? (p.s : I`m still a beginner. A also used easygui for some of the needs)

import Tkinter, tkFileDialog

root = Tkinter.Tk()
dirname = tkFileDialog.askdirectory(parent=root,initialdir="/",title='Please select a directory')

catcit,
I'm having the same problem. Can you please post your solution. Thanks a bunch.

Here`s the code with the problem.

import Tkinter, tkFileDialog

root = Tkinter.Tk()
dirname = tkFileDialog.askdirectory(parent=root,initialdir="/",title='Please select a directory')

and here`s the code with the problem solved

import Tkinter, tkFileDialog

root = Tkinter.Tk()
root.withdraw()
dirname = tkFileDialog.askdirectory(parent=root,initialdir="/",title='Please select a directory')

I used

root.withdraw

in order to get rid of the root from tkinter. If you want to find out more about it google it.

Even simpler, for your console programs you can just use ...

import tkFileDialog

dirname = tkFileDialog.askdirectory(initialdir="/",  title='Please select a directory')

# test
print dirname
This question has already been answered. Start a new discussion instead.