diff options
author | Guido van Rossum <guido@python.org> | 1998-10-12 23:56:08 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-10-12 23:56:08 (GMT) |
commit | e7b2e651dfa978cdb0d2c18640828f11f19ca8ad (patch) | |
tree | f948db3af397f5400079c87b3cee3565998834b3 | |
parent | 219ffde846304915e173bd99833e30d012a58b82 (diff) | |
download | cpython-e7b2e651dfa978cdb0d2c18640828f11f19ca8ad.zip cpython-e7b2e651dfa978cdb0d2c18640828f11f19ca8ad.tar.gz cpython-e7b2e651dfa978cdb0d2c18640828f11f19ca8ad.tar.bz2 |
Generalize menu creation.
-rw-r--r-- | Tools/idle/EditorWindow.py | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/Tools/idle/EditorWindow.py b/Tools/idle/EditorWindow.py index a17354d..b122c2f 100644 --- a/Tools/idle/EditorWindow.py +++ b/Tools/idle/EditorWindow.py @@ -40,6 +40,8 @@ class EditorWindow: self.top.protocol("WM_DELETE_WINDOW", self.close) self.top.bind("<<close-window>>", self.close_event) self.text.bind("<<center-insert>>", self.center_insert_event) + self.text.bind("<<help>>", self.help_dialog) + self.text.bind("<<about-idle>>", self.about_dialog) vbar['command'] = text.yview vbar.pack(side=RIGHT, fill=Y) @@ -75,32 +77,25 @@ class EditorWindow: self.saved_change_hook() + menu_specs = [ + ("file", "File"), + ("edit", "Edit"), + ("help", "Help"), + ] + def createmenubar(self): mbar = self.menubar + self.menudict = mdict = {} + for name, label in self.menu_specs: + mdict[name] = menu = Menu(mbar, name=name) + mbar.add_cascade(label=label, menu=menu) + self.Bindings.fill_menus(self.text, mdict) - self.filemenu = Menu(mbar) - - self.editmenu = Menu(mbar) - - self.helpmenu = Menu(mbar, name="help") - self.helpmenu.add_command(label="Help...", command=self.help_dialog) - self.helpmenu.add_separator() - self.helpmenu.add_command(label="About...", command=self.about_dialog) - - mbar.add_cascade(label="File", menu=self.filemenu) - mbar.add_cascade(label="Edit", menu=self.editmenu) - mbar.add_cascade(label="Help", menu=self.helpmenu) - - dict = {"file": self.filemenu, - "edit": self.editmenu, - "help": self.helpmenu} - self.Bindings.fill_menus(self.text, dict) - - def about_dialog(self): + def about_dialog(self, event=None): tkMessageBox.showinfo(self.about_title, self.about_text, master=self.text) - def help_dialog(self): + def help_dialog(self, event=None): from HelpWindow import HelpWindow HelpWindow(root=self.root) |