[Tkinter-discuss] select multiple folders/ directories

Wayne Werner waynejwerner at gmail.com
Thu Jan 13 17:36:11 CET 2011


On Thu, Jan 13, 2011 at 10:24 AM, Cameron Laird <Cameron at phaseit.net> wrote:

> Hi,
>
> I'm currently using tkFileDialog.askdirectory() to select a single
> directory. I would like to be able to select multiple directories.
>
> tkFileDialog.askopenfilenames() seems to do this for files.
>
> What can I do in my situation? Are there alternative classes that
> provide file dialogs better suited for my purpose?
>
>
> I want to select multiple folders at a time but tkFileDialog.askdirectory()
> doesnt allow "multiple=1".. is there any way to make this work?
>

>From my quick test, there doesn't appear to be. However, you can do this:

dirs = []
title = 'Choose Directory'
while True:
    dir = tkFileDialog.askdirectory(title=title)
    if not dir:
        break
    title = 'got %s. Next dir' % dirs[-1]

Probably not the most elegant solution, but hopefully it helps.

Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20110113/42dcf1da/attachment.html>


More information about the Tkinter-discuss mailing list