Tkinter:select directory dialog?

Park997 park997 at aol.comnotospam
Wed Sep 18 15:26:45 EDT 2002


Thanks this did the trick. I am still using 
Python 2.0. The addition of askdirectory
to Python 2.2 was a good idea :-).

Wendell Cropper


>> from tkCommonDialog import Dialog
>> class Chooser(Dialog):
>>     command = "tk_chooseDirectory"
>>     def _fixresult(self, widget, result):
>>         if result:
>>             self.options["initialdir"] = result
>>         self.directory = result # compatibility
>>         return result
>>
>> def askdirectory(**options):
>>     return apply(Chooser, (), options).show()
>
>(hmm.  I think I've seen that code before...)
>
>the askdirectory function and a Directory class (same as
>the Chooser above) was added to the tkFileDialog module
>in Python 2.2:
>
>    from tkFileDialog import askdirectory
>
>    directory = askdirectory(
>        title="select directory",
>        mustexist=1
>    )
>
>    if not directory:
>        print "cancelled"
>    else:
>        print "selected", directory
>
></F>
>
><!-- (the eff-bot guide to) the python standard library:
>http://www.pythonware.com/people/fredrik/librarybook.htm
>-->
>
>





More information about the Python-list mailing list