diff options
author | Guido van Rossum <guido@python.org> | 1998-10-12 23:57:48 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-10-12 23:57:48 (GMT) |
commit | 82e44b10b8f5e8cf184b2223e15e8ce4c3ee62b5 (patch) | |
tree | 6352f1a7ea71b06a181d6eb6d25db78178c9a110 /Tools/idle/FileList.py | |
parent | e7b2e651dfa978cdb0d2c18640828f11f19ca8ad (diff) | |
download | cpython-82e44b10b8f5e8cf184b2223e15e8ce4c3ee62b5.zip cpython-82e44b10b8f5e8cf184b2223e15e8ce4c3ee62b5.tar.gz cpython-82e44b10b8f5e8cf184b2223e15e8ce4c3ee62b5.tar.bz2 |
Get rid of PopUp menu.
Create a simple Windows menu. (Imperfect when Untitled windows exist.)
Add wakeup() method: deiconify, raise, focus.
Diffstat (limited to 'Tools/idle/FileList.py')
-rw-r--r-- | Tools/idle/FileList.py | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/Tools/idle/FileList.py b/Tools/idle/FileList.py index 6ffeb30..f7a08e1 100644 --- a/Tools/idle/FileList.py +++ b/Tools/idle/FileList.py @@ -18,7 +18,10 @@ class MultiIOBinding(IOBinding): class MultiEditorWindow(EditorWindow): IOBinding = MultiIOBinding - from PopupMenu import PopupMenu + + # Override menu bar specs + menu_specs = EditorWindow.menu_specs[:] + menu_specs.insert(len(menu_specs)-1, ("windows", "Windows")) def __init__(self, flist, filename, key): self.flist = flist @@ -28,7 +31,6 @@ class MultiEditorWindow(EditorWindow): EditorWindow.__init__(self, flist.root, filename) self.io.flist = flist self.io.edit = self - self.popup = self.PopupMenu(self.text, self.flist) self.text.bind("<<open-new-window>>", self.flist.new_callback) self.text.bind("<<close-all-windows>>", self.flist.close_all_callback) @@ -38,10 +40,32 @@ class MultiEditorWindow(EditorWindow): def filename_change_hook(self): self.flist.filename_changed_edit(self) EditorWindow.filename_change_hook(self) + + def wakeup(self): + self.top.tkraise() + self.top.wm_deiconify() + self.text.focus_set() + + def createmenubar(self): + EditorWindow.createmenubar(self) + self.menudict['windows'].configure(postcommand=self.postwindowsmenu) + + def postwindowsmenu(self): + wmenu = self.menudict['windows'] + wmenu.delete(0, 'end') + self.fixedwindowsmenu(wmenu) + files = self.flist.dict.keys() + files.sort() + for file in files: + def openit(self=self, file=file): + self.flist.open(file) + wmenu.add_command(label=file, command=openit) class FileList: - + + EditorWindow = MultiEditorWindow + def __init__(self, root): self.root = root self.dict = {} @@ -62,9 +86,7 @@ class FileList: key = os.path.normcase(filename) if self.dict.has_key(key): edit = self.dict[key] - edit.top.tkraise() - edit.top.wm_deiconify() - edit.text.focus_set() + edit.wakeup() return edit if not os.path.exists(filename): tkMessageBox.showinfo( @@ -76,13 +98,11 @@ class FileList: edit.io.loadfile(filename) self.dict[key] = edit self.inversedict[edit] = key - edit.top.tkraise() - edit.top.wm_deiconify() - edit.text.focus_set() + edit.wakeup() return edit else: key = None - edit = MultiEditorWindow(self, filename, key) + edit = self.EditorWindow(self, filename, key) return edit def new_callback(self, event): |