Commit 0234fd1c authored by Terry Jan Reedy's avatar Terry Jan Reedy

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.
parent cca5b69f
...@@ -693,30 +693,29 @@ class EditorWindow(object): ...@@ -693,30 +693,29 @@ class EditorWindow(object):
return return
# XXX Ought to insert current file's directory in front of path # XXX Ought to insert current file's directory in front of path
try: try:
(f, file, (suffix, mode, type)) = _find_module(name) (f, file_path, (suffix, mode, mtype)) = _find_module(name)
except (NameError, ImportError) as msg: except (NameError, ImportError) as msg:
tkMessageBox.showerror("Import error", str(msg), parent=self.text) tkMessageBox.showerror("Import error", str(msg), parent=self.text)
return return
if type != imp.PY_SOURCE: if mtype != imp.PY_SOURCE:
tkMessageBox.showerror("Unsupported type", tkMessageBox.showerror("Unsupported type",
"%s is not a source module" % name, parent=self.text) "%s is not a source module" % name, parent=self.text)
return return
if f: if f:
f.close() f.close()
if self.flist: if self.flist:
self.flist.open(file) self.flist.open(file_path)
else: else:
self.io.loadfile(file) self.io.loadfile(file_path)
return file_path
def open_class_browser(self, event=None): def open_class_browser(self, event=None):
filename = self.io.filename filename = self.io.filename
if not filename: if not (self.__class__.__name__ == 'PyShellEditorWindow'
tkMessageBox.showerror( and filename):
"No filename", filename = self.open_module()
"This buffer has no associated filename", if filename is None:
master=self.text) return
self.text.focus_set()
return None
head, tail = os.path.split(filename) head, tail = os.path.split(filename)
base, ext = os.path.splitext(tail) base, ext = os.path.splitext(tail)
from idlelib import ClassBrowser from idlelib import ClassBrowser
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment