summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-11-08 17:51:33 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-11-08 17:51:33 (GMT)
commitbc0ad2d1a469f6c10c48d86d228b381ae8999169 (patch)
tree6e23d204fd0d3674205aa835fff2830805d86f99 /Lib
parentd5214b04f5cc49594a310df75ba8af6dd689ea24 (diff)
downloadcpython-bc0ad2d1a469f6c10c48d86d228b381ae8999169.zip
cpython-bc0ad2d1a469f6c10c48d86d228b381ae8999169.tar.gz
cpython-bc0ad2d1a469f6c10c48d86d228b381ae8999169.tar.bz2
Merge directory chooser into tkFileDialog.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/lib-tk/tkDirectoryChooser.py52
-rw-r--r--Lib/lib-tk/tkFileDialog.py20
2 files changed, 18 insertions, 54 deletions
diff --git a/Lib/lib-tk/tkDirectoryChooser.py b/Lib/lib-tk/tkDirectoryChooser.py
deleted file mode 100644
index 593ad8f..0000000
--- a/Lib/lib-tk/tkDirectoryChooser.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# tkDirectoryChooser.py
-# $Id$
-#
-# tk common directory dialogue
-#
-# this module provides interfaces to the native directory dialogue
-# available in Tk 8.3 and newer.
-#
-# written by Fredrik Lundh, November 2000.
-#
-
-#
-# options (all have default values):
-#
-# - initialdir: initial directory. preserved by dialog instance.
-#
-# - mustexist: if true, user must pick an existing directory
-#
-# - parent: which window to place the dialog on top of
-#
-# - title: dialog title
-#
-
-from tkCommonDialog import Dialog
-
-class Chooser(Dialog):
-
- command = "tk_chooseDirectory"
-
- def _fixresult(self, widget, result):
- if result:
- # keep directory until next time
- self.options["initialdir"] = result
- self.directory = result # compatibility
- return result
-
-#
-# convenience stuff
-
-def askdirectory(**options):
- "Ask for a directory name"
-
- return apply(Chooser, (), options).show()
-
-# --------------------------------------------------------------------
-# test stuff
-
-if __name__ == "__main__":
-
- print "directory", askdirectory()
-
diff --git a/Lib/lib-tk/tkFileDialog.py b/Lib/lib-tk/tkFileDialog.py
index eb2a900..9d2af51 100644
--- a/Lib/lib-tk/tkFileDialog.py
+++ b/Lib/lib-tk/tkFileDialog.py
@@ -5,7 +5,8 @@
# tk common file dialogues
#
# this module provides interfaces to the native file dialogues
-# available in Tk 4.2 and newer.
+# available in Tk 4.2 and newer, and the directory dialogue available
+# in Tk 8.3 and newer.
#
# written by Fredrik Lundh, May 1997.
#
@@ -28,6 +29,12 @@
#
# - title: dialog title
#
+# options for the directory chooser:
+#
+# - initialdir, parent, title: see above
+#
+# - mustexist: if true, user must pick an existing directory
+#
from tkCommonDialog import Dialog
@@ -64,11 +71,20 @@ class SaveAs(_Dialog):
command = "tk_getSaveFile"
-class Directory(_Dialog):
+
+# the directory dialog has its own _fix routines.
+class Directory(Dialog):
"Ask for a directory"
command = "tk_chooseDirectory"
+ def _fixresult(self, widget, result):
+ if result:
+ # keep directory until next time
+ self.options["initialdir"] = result
+ self.directory = result # compatibility
+ return result
+
#
# convenience stuff