diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-10-16 02:01:23 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-10-16 02:01:23 (GMT) |
commit | 0234fd1c44ed60c8ea53df3ea266607c4b6bf964 (patch) | |
tree | 210454209770e66f5b4a4c50371683c7278b2dda | |
parent | cca5b69f93be6abb5db8d63acaba784e935cb85d (diff) | |
download | cpython-0234fd1c44ed60c8ea53df3ea266607c4b6bf964.zip cpython-0234fd1c44ed60c8ea53df3ea266607c4b6bf964.tar.gz cpython-0234fd1c44ed60c8ea53df3ea266607c4b6bf964.tar.bz2 |
Issue #16233: When the module browser is not invoked in an editor window with
a filename, pop up the Open Module box. If a module is opened, open a
corresponding browser.
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index d06e2da..2032b65 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -693,30 +693,29 @@ class EditorWindow(object): return # XXX Ought to insert current file's directory in front of path try: - (f, file, (suffix, mode, type)) = _find_module(name) + (f, file_path, (suffix, mode, mtype)) = _find_module(name) except (NameError, ImportError) as msg: tkMessageBox.showerror("Import error", str(msg), parent=self.text) return - if type != imp.PY_SOURCE: + if mtype != imp.PY_SOURCE: tkMessageBox.showerror("Unsupported type", "%s is not a source module" % name, parent=self.text) return if f: f.close() if self.flist: - self.flist.open(file) + self.flist.open(file_path) else: - self.io.loadfile(file) + self.io.loadfile(file_path) + return file_path def open_class_browser(self, event=None): filename = self.io.filename - if not filename: - tkMessageBox.showerror( - "No filename", - "This buffer has no associated filename", - master=self.text) - self.text.focus_set() - return None + if not (self.__class__.__name__ == 'PyShellEditorWindow' + and filename): + filename = self.open_module() + if filename is None: + return head, tail = os.path.split(filename) base, ext = os.path.splitext(tail) from idlelib import ClassBrowser |