Commit 82e44b10 authored by Guido van Rossum's avatar Guido van Rossum

Get rid of PopUp menu.

Create a simple Windows menu.  (Imperfect when Untitled windows exist.)
Add wakeup() method: deiconify, raise, focus.
parent e7b2e651
...@@ -18,7 +18,10 @@ class MultiIOBinding(IOBinding): ...@@ -18,7 +18,10 @@ class MultiIOBinding(IOBinding):
class MultiEditorWindow(EditorWindow): class MultiEditorWindow(EditorWindow):
IOBinding = MultiIOBinding 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): def __init__(self, flist, filename, key):
self.flist = flist self.flist = flist
...@@ -28,7 +31,6 @@ class MultiEditorWindow(EditorWindow): ...@@ -28,7 +31,6 @@ class MultiEditorWindow(EditorWindow):
EditorWindow.__init__(self, flist.root, filename) EditorWindow.__init__(self, flist.root, filename)
self.io.flist = flist self.io.flist = flist
self.io.edit = self 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("<<open-new-window>>", self.flist.new_callback)
self.text.bind("<<close-all-windows>>", self.flist.close_all_callback) self.text.bind("<<close-all-windows>>", self.flist.close_all_callback)
...@@ -39,9 +41,31 @@ class MultiEditorWindow(EditorWindow): ...@@ -39,9 +41,31 @@ class MultiEditorWindow(EditorWindow):
self.flist.filename_changed_edit(self) self.flist.filename_changed_edit(self)
EditorWindow.filename_change_hook(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: class FileList:
EditorWindow = MultiEditorWindow
def __init__(self, root): def __init__(self, root):
self.root = root self.root = root
self.dict = {} self.dict = {}
...@@ -62,9 +86,7 @@ class FileList: ...@@ -62,9 +86,7 @@ class FileList:
key = os.path.normcase(filename) key = os.path.normcase(filename)
if self.dict.has_key(key): if self.dict.has_key(key):
edit = self.dict[key] edit = self.dict[key]
edit.top.tkraise() edit.wakeup()
edit.top.wm_deiconify()
edit.text.focus_set()
return edit return edit
if not os.path.exists(filename): if not os.path.exists(filename):
tkMessageBox.showinfo( tkMessageBox.showinfo(
...@@ -76,13 +98,11 @@ class FileList: ...@@ -76,13 +98,11 @@ class FileList:
edit.io.loadfile(filename) edit.io.loadfile(filename)
self.dict[key] = edit self.dict[key] = edit
self.inversedict[edit] = key self.inversedict[edit] = key
edit.top.tkraise() edit.wakeup()
edit.top.wm_deiconify()
edit.text.focus_set()
return edit return edit
else: else:
key = None key = None
edit = MultiEditorWindow(self, filename, key) edit = self.EditorWindow(self, filename, key)
return edit return edit
def new_callback(self, event): def new_callback(self, event):
......
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