From: Fred Drake Date: Wed, 6 May 1998 17:28:23 +0000 (+0000) Subject: When a file name is selected ("OK" button, in the filename entry), X-Git-Tag: v1.5.2a1~746 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=073b8290215f7753668575a8f9cba85a64221842;p=python When a file name is selected ("OK" button, in the filename entry), and the "key" keyword parameter was used to invoke .go(), use the directory of the selected file as the stored directory to return to when the same key is used again. This is useful since the user may well entry at least part of the path in the filename box instead of doing a lot of clicking around in the listboxes. --- diff --git a/Lib/lib-tk/FileDialog.py b/Lib/lib-tk/FileDialog.py index d3c96b8a00..74e9741251 100644 --- a/Lib/lib-tk/FileDialog.py +++ b/Lib/lib-tk/FileDialog.py @@ -122,7 +122,11 @@ class FileDialog: self.top.grab_set() self.how = None self.master.mainloop() # Exited by self.quit(how) - if key: dialogstates[key] = self.get_filter() + if key: + directory, pattern = self.get_filter() + if self.how: + directory = os.path.dirname(self.how) + dialogstates[key] = directory, pattern self.top.destroy() return self.how