]> granicus.if.org Git - python/commitdiff
Patch #478654: Expose tk_chooseDirectory.
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 7 Nov 2001 22:38:08 +0000 (22:38 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 7 Nov 2001 22:38:08 +0000 (22:38 +0000)
Also delegate kw arguments through ** calls.

Lib/lib-tk/tkFileDialog.py
Misc/NEWS

index e07e5d073924d750d76dddad234ab4fc7ccbe81e..eb2a90027e285b1dcad960543dcf4b572ee46517 100644 (file)
@@ -64,6 +64,10 @@ class SaveAs(_Dialog):
 
     command = "tk_getSaveFile"
 
+class Directory(_Dialog):
+    "Ask for a directory"
+
+    command = "tk_chooseDirectory"
 
 #
 # convenience stuff
@@ -71,19 +75,19 @@ class SaveAs(_Dialog):
 def askopenfilename(**options):
     "Ask for a filename to open"
 
-    return apply(Open, (), options).show()
+    return Open(**options).show()
 
 def asksaveasfilename(**options):
     "Ask for a filename to save as"
 
-    return apply(SaveAs, (), options).show()
+    return SaveAs(**options).show()
 
 # FIXME: are the following two perhaps a bit too convenient?
 
 def askopenfile(mode = "r", **options):
     "Ask for a filename to open, and returned the opened file"
 
-    filename = apply(Open, (), options).show()
+    filename = Open(**options).show()
     if filename:
         return open(filename, mode)
     return None
@@ -91,11 +95,14 @@ def askopenfile(mode = "r", **options):
 def asksaveasfile(mode = "w", **options):
     "Ask for a filename to save as, and returned the opened file"
 
-    filename = apply(SaveAs, (), options).show()
+    filename = SaveAs(**options).show()
     if filename:
         return open(filename, mode)
     return None
 
+def askdirectory (**options):
+    "Ask for a directory, and return the file name"
+    return Directory(**options).show()
 
 # --------------------------------------------------------------------
 # test stuff
index a9f5a9915fac85facd73760cdca370c99716a142..e873dad6882c9a12b7afb5e4a9f308b27638e81f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -51,6 +51,9 @@ Extension modules
 
 Library
 
+- tkFileDialog exposes a Directory class and askdirectory 
+  convenience function.
+
 - Symbolic group names in regular expressions must be unique.  For
   example, the regexp r'(?P<abc>)(?P<abc>)' is not allowed, because a
   single name can't mean both "group 1" and "group 2" simultaneously.