summaryrefslogtreecommitdiff
path: root/Lib/lib-tk/tkFileDialog.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-10-13 10:28:04 +0000
committerMartin v. Löwis <martin@v.loewis.de>2002-10-13 10:28:04 +0000
commitbb39c775b1c2163e878e799b7869f4cade573a46 (patch)
tree1e57bfb9961c2da63f444dda483890d9062b48f3 /Lib/lib-tk/tkFileDialog.py
parentefb678a7aedc2c8ebae4be2853ccf2d2cc30ffb4 (diff)
downloadcpython-bb39c775b1c2163e878e799b7869f4cade573a46.tar.gz
Patch #621891: Add askopenfile{name}s.
Diffstat (limited to 'Lib/lib-tk/tkFileDialog.py')
-rw-r--r--Lib/lib-tk/tkFileDialog.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/Lib/lib-tk/tkFileDialog.py b/Lib/lib-tk/tkFileDialog.py
index 93cb277758..569254a456 100644
--- a/Lib/lib-tk/tkFileDialog.py
+++ b/Lib/lib-tk/tkFileDialog.py
@@ -29,12 +29,16 @@
#
# - title: dialog title
#
+# - multiple: if true user may select more than one file
+#
# options for the directory chooser:
#
# - initialdir, parent, title: see above
#
# - mustexist: if true, user must pick an existing directory
#
+#
+
from tkCommonDialog import Dialog
@@ -98,7 +102,18 @@ def asksaveasfilename(**options):
return SaveAs(**options).show()
-# FIXME: are the following two perhaps a bit too convenient?
+def askopenfilenames(**options):
+ """Ask for multiple filenames to open
+
+ Returns a list of filenames or empty list if
+ cancel button selected
+ """
+ options["multiple"]=1
+ files=Open(**options).show()
+ return files.split()
+
+
+# FIXME: are the following perhaps a bit too convenient?
def askopenfile(mode = "r", **options):
"Ask for a filename to open, and returned the opened file"
@@ -108,6 +123,23 @@ def askopenfile(mode = "r", **options):
return open(filename, mode)
return None
+def askopenfiles(mode = "r", **options):
+ """Ask for multiple filenames and return the open file
+ objects
+
+ returns a list of open file objects or an empty list if
+ cancel selected
+ """
+
+ files = askopenfilenames(**options)
+ if files:
+ ofiles=[]
+ for filename in files:
+ ofiles.append(open(filename, mode))
+ files=ofiles
+ return files
+
+
def asksaveasfile(mode = "w", **options):
"Ask for a filename to save as, and returned the opened file"