[Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.66, 1.67 NEWS.txt, 1.54, 1.55 configDialog.py, 1.60, 1.61
Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12586 Modified Files: EditorWindow.py NEWS.txt configDialog.py Log Message: Removed ability to configure tabs indent from Options dialog. This 'feature' has never worked and no one has complained. It is still possible to set a default tabs (v. spaces) indent 'manually' via config-main.def (or to turn on tabs for the current EditorWindow via the Format menu) but IDLE will encourage indentation via spaces. Enable setting the indentation width using the Options dialog. Bug # 783877 Remove some commented out old code from configDialog.py (related to old methods for invoking the HelpBrowser). M EditorWindow.py M NEWS.txt M configHandler.py Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- EditorWindow.py 28 Jan 2005 00:16:15 -0000 1.66 +++ EditorWindow.py 31 Jan 2005 03:34:26 -0000 1.67 @@ -157,12 +157,12 @@ vbar['command'] = text.yview vbar.pack(side=RIGHT, fill=Y) text['yscrollcommand'] = vbar.set - fontWeight='normal' - if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'): + fontWeight = 'normal' + if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'): fontWeight='bold' - text.config(font=(idleConf.GetOption('main','EditorWindow','font'), - idleConf.GetOption('main','EditorWindow','font-size'), - fontWeight)) + text.config(font=(idleConf.GetOption('main', 'EditorWindow', 'font'), + idleConf.GetOption('main', 'EditorWindow', 'font-size'), + fontWeight)) text_frame.pack(side=LEFT, fill=BOTH, expand=1) text.pack(side=TOP, fill=BOTH, expand=1) text.focus_set() @@ -173,19 +173,23 @@ # which will cause Tabnanny to nag! # false -> tab characters are converted to spaces by indent # and dedent cmds, and ditto TAB keystrokes - self.usetabs = False - - # indentwidth is the number of characters per logical indent level. - # Recommended Python default indent is four spaces. - self.indentwidth = 4 + # Although use-spaces=0 can be configured manually in config-main.def, + # configuration of tabs v. spaces is not supported in the configuration + # dialog. IDLE promotes the preferred Python indentation: use spaces! + usespaces = idleConf.GetOption('main', 'Indent', 'use-spaces', type='bool') + self.usetabs = not usespaces # tabwidth is the display width of a literal tab character. # CAUTION: telling Tk to use anything other than its default # tab setting causes it to use an entirely different tabbing algorithm, # treating tab stops as fixed distances from the left margin. # Nobody expects this, so for now tabwidth should never be changed. - self.tabwidth = 8 # for IDLE use, must remain 8 until Tk is fixed. - # indentwidth should be 8 when usetabs is True. + self.tabwidth = 8 # must remain 8 until Tk is fixed. + + # indentwidth is the number of screen characters per indent level. + # The recommended Python indentation is four spaces. + self.indentwidth = self.tabwidth + self.set_notabs_indentwidth() # If context_use_ps1 is true, parsing searches back for a ps1 line; # else searches for a popular (if, def, ...) Python stmt. @@ -583,6 +587,13 @@ accel=get_accelerator(keydefs, event) menu.entryconfig(index,accelerator=accel) + def set_notabs_indentwidth(self): + "Update the indentwidth if changed and not using tabs in this window" + # Called from configDialog.py + if not self.usetabs: + self.indentwidth = idleConf.GetOption('main', 'Indent','num-spaces', + type='int') + def reset_help_menu_entries(self): "Update the additional help entries on the Help menu" help_list = idleConf.GetAllExtraHelpSourcesList() Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- NEWS.txt 28 Jan 2005 00:16:16 -0000 1.54 +++ NEWS.txt 31 Jan 2005 03:34:26 -0000 1.55 @@ -3,6 +3,15 @@ *Release date: XX-XXX-2005* +- Removed ability to configure tabs indent from Options dialog. This 'feature' + has never worked and no one has complained. It is still possible to set a + default tabs (v. spaces) indent 'manually' via config-main.def (or to turn on + tabs for the current EditorWindow via the Format menu) but IDLE will + encourage indentation via spaces. + +- Enable setting the indentation width using the Options dialog. + Bug # 783877 + - Add keybindings for del-word-left and del-word-right. - Discourage using an indent width other than 8 when using tabs to indent Index: configDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configDialog.py,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- configDialog.py 16 Nov 2004 21:28:36 -0000 1.60 +++ configDialog.py 31 Jan 2005 03:34:26 -0000 1.61 @@ -6,7 +6,7 @@ and default window size. Define additional help sources. Note that tab width in IDLE is currently fixed at eight due to Tk issues. -Refer to comment in EditorWindow autoindent code for details. +Refer to comments in EditorWindow autoindent code for details. """ from Tkinter import * @@ -21,9 +21,7 @@ from configHelpSourceEdit import GetHelpSourceDialog class ConfigDialog(Toplevel): - """ - configuration dialog for idle - """ + def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) @@ -93,8 +91,6 @@ self.fontBold=BooleanVar(self) self.fontName=StringVar(self) self.spaceNum=IntVar(self) - #self.tabCols=IntVar(self) - self.indentBySpaces=BooleanVar(self) self.editFont=tkFont.Font(self,('courier',10,'normal')) ##widget creation #body frame @@ -124,25 +120,12 @@ text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]', justify=LEFT,font=self.editFont) #frameIndent - labelIndentTitle=Label(frameIndent,text='Set Indentation Defaults') - frameIndentType=Frame(frameIndent) frameIndentSize=Frame(frameIndent) - labelIndentTypeTitle=Label(frameIndentType, - text='Choose indentation type :') - radioUseSpaces=Radiobutton(frameIndentType,variable=self.indentBySpaces, - value=1,text='Tab key inserts spaces') - radioUseTabs=Radiobutton(frameIndentType,variable=self.indentBySpaces, - value=0,text='Tab key inserts tabs') - labelIndentSizeTitle=Label(frameIndentSize, - text='Choose indentation size :') - labelSpaceNumTitle=Label(frameIndentSize,justify=LEFT, - text='indent width') - self.scaleSpaceNum=Scale(frameIndentSize,variable=self.spaceNum, - orient='horizontal',tickinterval=2,from_=2,to=16) - #labeltabColsTitle=Label(frameIndentSize,justify=LEFT, - # text='when tab key inserts tabs,\ncolumns per tab') - #self.scaleTabCols=Scale(frameIndentSize,variable=self.tabCols, - # orient='horizontal',tickinterval=2,from_=2,to=8) + labelSpaceNumTitle=Label(frameIndentSize, justify=LEFT, + text='Python Standard: 4 Spaces!') + self.scaleSpaceNum=Scale(frameIndentSize, variable=self.spaceNum, + label='Indentation Width', orient='horizontal', + tickinterval=2, from_=2, to=16) #widget packing #body frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH) @@ -160,17 +143,9 @@ frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) self.labelFontSample.pack(expand=TRUE,fill=BOTH) #frameIndent - labelIndentTitle.pack(side=TOP,anchor=W,padx=5,pady=5) - frameIndentType.pack(side=TOP,padx=5,fill=X) frameIndentSize.pack(side=TOP,padx=5,pady=5,fill=BOTH) - labelIndentTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) - radioUseSpaces.pack(side=TOP,anchor=W,padx=5) - radioUseTabs.pack(side=TOP,anchor=W,padx=5) - labelIndentSizeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) labelSpaceNumTitle.pack(side=TOP,anchor=W,padx=5) self.scaleSpaceNum.pack(side=TOP,padx=5,fill=X) - #labeltabColsTitle.pack(side=TOP,anchor=W,padx=5) - #self.scaleTabCols.pack(side=TOP,padx=5,fill=X) return frame def CreatePageHighlight(self): @@ -390,7 +365,6 @@ radioEncNone=Radiobutton(frameEncoding,variable=self.encoding, value="none",text="None") #frameHelp - ##labelHelpTitle=Label(frameHelp,text='Help Options') frameHelpList=Frame(frameHelp) frameHelpListButtons=Frame(frameHelpList) labelHelpListTitle=Label(frameHelpList,text='Additional Help Sources:') @@ -406,13 +380,6 @@ width=8,command=self.HelpListItemAdd) self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove', state=DISABLED,width=8,command=self.HelpListItemRemove) - # the following is better handled by the BROWSER environment - # variable under unix/linux - #checkHelpBrowser=Checkbutton(frameHelp,variable=self.userHelpBrowser, - # onvalue=1,offvalue=0,text='user specified (html) help browser:', - # command=self.OnCheckUserHelpBrowser) - #self.entryHelpBrowser=Entry(frameHelp,textvariable=self.helpBrowser, - # width=40) #widget packing #body frameRun.pack(side=TOP,padx=5,pady=5,fill=X) @@ -446,7 +413,6 @@ radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5) radioEncLocale.pack(side=RIGHT,anchor=E,pady=5) #frameHelp - ##labelHelpTitle.pack(side=TOP,anchor=W,padx=5,pady=5) frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y) frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) labelHelpListTitle.pack(side=TOP,anchor=W) @@ -455,8 +421,6 @@ self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5) self.buttonHelpListAdd.pack(side=TOP,anchor=W) self.buttonHelpListRemove.pack(side=TOP,anchor=W,pady=5) - #checkHelpBrowser.pack(side=TOP,anchor=W,padx=5) - #self.entryHelpBrowser.pack(side=TOP,anchor=W,padx=5,pady=5) return frame def AttachVarCallbacks(self): @@ -464,8 +428,6 @@ self.fontName.trace_variable('w',self.VarChanged_fontName) self.fontBold.trace_variable('w',self.VarChanged_fontBold) self.spaceNum.trace_variable('w',self.VarChanged_spaceNum) - #self.tabCols.trace_variable('w',self.VarChanged_tabCols) - self.indentBySpaces.trace_variable('w',self.VarChanged_indentBySpaces) self.colour.trace_variable('w',self.VarChanged_colour) self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme) self.customTheme.trace_variable('w',self.VarChanged_customTheme) @@ -494,18 +456,10 @@ value=self.fontBold.get() self.AddChangedItem('main','EditorWindow','font-bold',value) - def VarChanged_indentBySpaces(self,*params): - value=self.indentBySpaces.get() - self.AddChangedItem('main','Indent','use-spaces',value) - def VarChanged_spaceNum(self,*params): value=self.spaceNum.get() self.AddChangedItem('main','Indent','num-spaces',value) - #def VarChanged_tabCols(self,*params): - # value=self.tabCols.get() - # self.AddChangedItem('main','Indent','tab-cols',value) - def VarChanged_colour(self,*params): self.OnNewColourSet() @@ -912,12 +866,6 @@ self.textHighlightSample.tag_config(element, **colours) self.SetColourSample() -## def OnCheckUserHelpBrowser(self): -## if self.userHelpBrowser.get(): -## self.entryHelpBrowser.config(state=NORMAL) -## else: -## self.entryHelpBrowser.config(state=DISABLED) - def HelpSourceSelected(self,event): self.SetHelpListButtonStates() @@ -996,17 +944,10 @@ self.SetFontSample() def LoadTabCfg(self): - ##indent type radiobuttons - spaceIndent=idleConf.GetOption('main','Indent','use-spaces', - default=1,type='bool') - self.indentBySpaces.set(spaceIndent) ##indent sizes spaceNum=idleConf.GetOption('main','Indent','num-spaces', default=4,type='int') - #tabCols=idleConf.GetOption('main','Indent','tab-cols', - # default=4,type='int') self.spaceNum.set(spaceNum) - #self.tabCols.set(tabCols) def LoadThemeCfg(self): ##current theme type radiobutton @@ -1096,11 +1037,6 @@ for helpItem in self.userHelpList: self.listHelp.insert(END,helpItem[0]) self.SetHelpListButtonStates() - #self.userHelpBrowser.set(idleConf.GetOption('main','General', - # 'user-help-browser',default=0,type='bool')) - #self.helpBrowser.set(idleConf.GetOption('main','General', - # 'user-help-browser-command',default='')) - #self.OnCheckUserHelpBrowser() def LoadConfigs(self): """ @@ -1171,17 +1107,12 @@ self.ResetChangedItems() #clear the changed items dict def ActivateConfigChanges(self): - #things that need to be done to make - #applied config changes dynamic: - #update editor/shell font and repaint - #dynamically update indentation setttings - #update theme and repaint - #update keybindings and re-bind - #update user help sources menu + "Dynamically apply configuration changes" winInstances=self.parent.instance_dict.keys() for instance in winInstances: instance.ResetColorizer() instance.ResetFont() + instance.set_notabs_indentwidth() instance.ResetKeybindings() instance.reset_help_menu_entries()
participants (1)
-
kbk@users.sourceforge.net