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>The only way for doing this in pure tkinter (except building the directory selector widget by hand) is requesting user for each dir in separate dialog. You could save previously used location, so user won't need to navigate there each time, by using code of below:</p>

<pre><code>from tkinter import filedialog
dirselect = filedialog.Directory()
dirs = []
while True:
    d = dirselect.show()
    if not d: break
    dirs.append(d)
</code></pre>

<p>Another solution is to use <code>tkinter.tix</code> extension (now part of standard lib, but may require to install Tk's Tix on some platforms). Primarly, you'll need the <code>tkinter.tix.DirList</code> widget. It look as follows (a bit old img):</p>

<p><a href="http://i.stack.imgur.com/rrs7l.gif" rel="nofollow"><img src="http://i.stack.imgur.com/rrs7l.gif" alt="img"></a></p>

<p>For more, see <a href="https://docs.python.org/3.5/library/tkinter.tix.html" rel="nofollow">tkinter.tix</a> and <a href="http://tix.sourceforge.net/docs/tix-book/filesel.tex.html" rel="nofollow">Tk Tix</a> docs</p>

python tkinter