[Python-checkins] r65473 - sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py
guilherme.polo
python-checkins at python.org
Mon Aug 4 03:53:15 CEST 2008
Author: guilherme.polo
Date: Mon Aug 4 03:53:15 2008
New Revision: 65473
Log:
Fixed an annoying bug that was causing FileList to print "Don't know this EditorWindow ..."
Modified:
sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py Mon Aug 4 03:53:15 2008
@@ -102,6 +102,13 @@
self.recent_files_path = os.path.join(idleConf.GetUserCfgDir(),
'recent-files.lst')
+ if flist:
+ flist.inversedict[self] = key
+ if key:
+ flist.dict[key] = self
+
+ self.menudict = None
+
# create a Notebook where the text pages for this EditorWindow will
# reside
self.text_notebook = TabbedPageSet(self.top)
@@ -115,16 +122,9 @@
# The following "width" attribute is used by PyShell, so keep it here
self.width = idleConf.GetOption('main', 'EditorPage', 'width')
- self._createmenubar()
-
self.top.protocol("WM_DELETE_WINDOW", self.close)
self.top.bind("<<close-window>>", self.close_event)
- if flist:
- flist.inversedict[self] = key
- if key:
- flist.dict[key] = self
-
self._create_statusbar()
self.top.after_idle(self.set_line_and_column)
@@ -165,13 +165,6 @@
# Making the initial values larger slows things down more often.
self.num_context_lines = 50, 500, 5000000
- # Create the recent files submenu
- self.recent_files_menu = Menu(self.menubar)
- self.menudict['file'].insert_cascade(3, label='Recent Files',
- underline=0,
- menu=self.recent_files_menu)
- self.update_recent_files_list()
-
self.set_indentation_params(self.ispythonsource(filename))
self.extensions = {}
@@ -233,10 +226,21 @@
vbar = Scrollbar(page.frame, name='vbar')
page.editpage = EditorPage(page.frame, self, title=page_title,
name='text', padx=5, wrap='none')
+
+ if self.menudict is None:
+ # This EditorWindow is being created now, perform the following
+ # tasks before.
+ self.menudict = {}
+ self._createmenubar(page.editpage.text)
+ # Create the recent files submenu
+ self.recent_files_menu = Menu(self.menubar)
+ self.menudict['file'].insert_cascade(3, label='Recent Files',
+ underline=0, menu=self.recent_files_menu)
+ self.update_recent_files_list()
+
page.editpage.post_init(filename=filename)
text = page.editpage.text
-
vbar['command'] = text.yview
vbar.pack(side=RIGHT, fill=Y)
text['yscrollcommand'] = vbar.set
@@ -563,11 +567,11 @@
else:
raise NameError, name
- def get_var_obj(self, name, vartype=None): # XXX depends on self.text
+ def get_var_obj(self, name, vartype=None, text=None):
var = self.tkinter_vars.get(name)
if not var and vartype:
# create a Tkinter variable object with self.text as master:
- self.tkinter_vars[name] = var = vartype(self.text)
+ self.tkinter_vars[name] = var = vartype(text or self.text)
return var
# Tk implementations of "virtual text methods" -- each platform
@@ -669,9 +673,9 @@
self.status_bar.set_label('line', 'Ln: ?', side=RIGHT)
self.status_bar.pack(side=BOTTOM, fill=X)
- def _createmenubar(self):
+ def _createmenubar(self, text):
mbar = self.menubar
- self.menudict = menudict = {}
+ menudict = self.menudict
for name, label in self.menu_specs:
underline, label = prepstr(label)
menudict[name] = menu = Menu(mbar, name=name, tearoff=0)
@@ -682,11 +686,11 @@
menudict['application'] = menu = Menu(mbar, name='apple')
mbar.add_cascade(label='IDLE', menu=menu)
- self._fill_menus()
+ self._fill_menus(text=text)
self.base_helpmenu_length = self.menudict['help'].index(END)
self.reset_help_menu_entries()
- def _fill_menus(self, menudefs=None, keydefs=None):
+ def _fill_menus(self, menudefs=None, keydefs=None, text=None):
"""Add appropriate entries to the menus and submenus
Menus that are absent or None in self.menudict are ignored.
@@ -713,7 +717,7 @@
def command(eventname=eventname):
self.text.event_generate(eventname)
if checkbutton:
- var = self.get_var_obj(eventname, BooleanVar)
+ var = self.get_var_obj(eventname, BooleanVar, text)
menu.add_checkbutton(label=label, underline=underline,
command=command, accelerator=accelerator,
variable=var)
More information about the Python-checkins
mailing list