Select several directories with tkinter
<p>I have to perform an operation on several directories.</p>

<p>TKinter offers a dialog for opening one file (askopenfilename), and several files (askopenfilenames), but is lacking a dialog for several directories. </p>

<p>What is the quickest way to get to a feasible solution for "askdirectories"?</p>

<p>You should be able to use <code>tkFileDialog.askdirectory</code>. Take a look at the docs <a href="http://tkinter.unpythonic.net/wiki/tkFileDialog" rel="nofollow">here</a> :)</p>

<p><strong>EDIT</strong></p>

<p>Perhaps something like this?</p>

<pre><code>from Tkinter import *
import tkFileDialog

root = Tk()
root.geometry('200x200')
root.grid_rowconfigure(0, weight = 1)
root.grid_columnconfigure(0, weight = 1)

dirs = []
def get_directories():
    dirs.append(tkFileDialog.askdirectory())
    return dirs

b1 = Button(root, text='select directories...', command = get_directories)
b1.pack()


root.mainloop()
</code></pre>

<p>Any thoughts?</p>

python tkinter