Mercurial > cpython-lru_cache-weakref
diff Lib/lib-tk/tkFileDialog.py @ 29472:1ab9978123be legacy-trunk
Properly deal with tuples in Open._fixresult. Fixes bug reported in
follow-up to #621891.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sat, 14 Jun 2003 21:34:32 +0000 |
| parents | ef531482bb37 |
| children | deb9715bc8ae |
line wrap: on
line diff
--- a/Lib/lib-tk/tkFileDialog.py Sat Jun 14 21:03:05 2003 +0000 +++ b/Lib/lib-tk/tkFileDialog.py Sat Jun 14 21:34:32 2003 +0000 @@ -76,6 +76,21 @@ 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 @@ 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?
