summaryrefslogtreecommitdiff
path: root/Lib/lib-tk/tkFileDialog.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-06-14 21:34:32 +0000
committerMartin v. Löwis <martin@v.loewis.de>2003-06-14 21:34:32 +0000
commite0b2c6c43f7e9c9fbd17ad441ce19086bb9de4d5 (patch)
tree8f781501ccd5434e9a53f17d70aed4f256fea2cf /Lib/lib-tk/tkFileDialog.py
parentdd51b4a2e7c55aa6b57c0f83659f88eff22d65f9 (diff)
downloadcpython-e0b2c6c43f7e9c9fbd17ad441ce19086bb9de4d5.tar.gz
Properly deal with tuples in Open._fixresult. Fixes bug reported in
follow-up to #621891.
Diffstat (limited to 'Lib/lib-tk/tkFileDialog.py')
-rw-r--r--Lib/lib-tk/tkFileDialog.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/lib-tk/tkFileDialog.py b/Lib/lib-tk/tkFileDialog.py
index 63487d2037..fb0014c5da 100644
--- a/Lib/lib-tk/tkFileDialog.py
+++ b/Lib/lib-tk/tkFileDialog.py
@@ -76,6 +76,21 @@ class Open(_Dialog):
command = "tk_getOpenFile"
+ def _fixresult(self, widget, result):
+ if isinstance(result, tuple):
+ # multiple results:
+ result = tuple([getattr(r, "string", r) for r in result])
+ if result:
+ import os
+ path, file = os.path.split(result[0])
+ self.options["initialdir"] = path
+ # don't set initialfile or filename, as we have multiple of these
+ return result
+ if not widget.tk.wantobjects() and "multiple" in self.options:
+ # Need to split result explicitly
+ return self._fixresult(widget, widget.tk.splitlist(result))
+ return _Dialog._fixresult(widget, result)
+
class SaveAs(_Dialog):
"Ask for a filename to save as"
@@ -115,9 +130,7 @@ def askopenfilenames(**options):
cancel button selected
"""
options["multiple"]=1
- files=Open(**options).show()
- return files.split()
-
+ return Open(**options).show()
# FIXME: are the following perhaps a bit too convenient?