Directory chooser for Tkinter

Stephen stephen-news at telekinesys.com
Thu Jun 7 13:44:46 EDT 2001


I was surprised by the lack of a directory chooser. Also I found
very few references to it on the web. Is there any reason for
not including the following code in tkFileChooser.py?

The tk_chooseDirectory appeared in all versions of tk since 8.3
(and earlier on some platforms afaik)

Stephen.

# directory dialog
#
# - initialdir: initial directory.  preserved by dialog instance.
# - initialfile: initial file (ignored by the open dialog).  preserved
#   by dialog instance.
# - parent: which window to place the dialog on top of
# - title: dialog title

def askOpenDirectory(**options):
    "return directory chosen or empty string if cancelled"
    class OpenDirectory(Dialog):
        command = "tk_chooseDirectory"
    return apply(OpenDirectory, (), options).show()



More information about the Python-list mailing list