tkinter - tkFileDialog - how to get dir instead of file
martin.franklin at westgeo.com
Wed Oct 31 10:42:27 CET 2001
Matthew Dixon Cowles wrote:
> On Mon, 29 Oct 2001 23:14:44 +0100, maxm <maxm at mxm.dk> wrote:
>>I am writing my first tkinter program and so far it's been pretty
> That's great, you're ahead of the game.
>>But now I need to open a directory and not a file. I cannot see a
>>simple way to get this from the standard module "tkFileDialog".
>>Do I really have to write a special class for this?
> Alas, you probably do. Tk provides a directory chooser but Python
> doesn't (yet) expose it. I filed a feature request on SourceForge for
> it but it doesn't look like anything has been done about it yet,
> including by me.
Or you could use this:-
from Tkinter import *
from tkCommonDialog import Dialog
command = "tk_chooseDirectory"
def _fixresult(self, widget, result):
self.options["initialdir"] = result
self.directory = result # compatibility
return apply(Chooser, (), options).show()
More information about the Python-list