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
This commit is contained in:
Kurt B. Kaiser 2005-01-31 03:34:26 +00:00
parent b5646aa3fb
commit acdef858a5
3 changed files with 41 additions and 90 deletions

View File

@ -157,12 +157,12 @@ class EditorWindow(object):
vbar['command'] = text.yview vbar['command'] = text.yview
vbar.pack(side=RIGHT, fill=Y) vbar.pack(side=RIGHT, fill=Y)
text['yscrollcommand'] = vbar.set text['yscrollcommand'] = vbar.set
fontWeight='normal' fontWeight = 'normal'
if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'): if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'):
fontWeight='bold' fontWeight='bold'
text.config(font=(idleConf.GetOption('main','EditorWindow','font'), text.config(font=(idleConf.GetOption('main', 'EditorWindow', 'font'),
idleConf.GetOption('main','EditorWindow','font-size'), idleConf.GetOption('main', 'EditorWindow', 'font-size'),
fontWeight)) fontWeight))
text_frame.pack(side=LEFT, fill=BOTH, expand=1) text_frame.pack(side=LEFT, fill=BOTH, expand=1)
text.pack(side=TOP, fill=BOTH, expand=1) text.pack(side=TOP, fill=BOTH, expand=1)
text.focus_set() text.focus_set()
@ -173,19 +173,23 @@ class EditorWindow(object):
# which will cause Tabnanny to nag! # which will cause Tabnanny to nag!
# false -> tab characters are converted to spaces by indent # false -> tab characters are converted to spaces by indent
# and dedent cmds, and ditto TAB keystrokes # and dedent cmds, and ditto TAB keystrokes
self.usetabs = False # Although use-spaces=0 can be configured manually in config-main.def,
# configuration of tabs v. spaces is not supported in the configuration
# indentwidth is the number of characters per logical indent level. # dialog. IDLE promotes the preferred Python indentation: use spaces!
# Recommended Python default indent is four spaces. usespaces = idleConf.GetOption('main', 'Indent', 'use-spaces', type='bool')
self.indentwidth = 4 self.usetabs = not usespaces
# tabwidth is the display width of a literal tab character. # tabwidth is the display width of a literal tab character.
# CAUTION: telling Tk to use anything other than its default # CAUTION: telling Tk to use anything other than its default
# tab setting causes it to use an entirely different tabbing algorithm, # tab setting causes it to use an entirely different tabbing algorithm,
# treating tab stops as fixed distances from the left margin. # treating tab stops as fixed distances from the left margin.
# Nobody expects this, so for now tabwidth should never be changed. # Nobody expects this, so for now tabwidth should never be changed.
self.tabwidth = 8 # for IDLE use, must remain 8 until Tk is fixed. self.tabwidth = 8 # must remain 8 until Tk is fixed.
# indentwidth should be 8 when usetabs is True.
# 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; # If context_use_ps1 is true, parsing searches back for a ps1 line;
# else searches for a popular (if, def, ...) Python stmt. # else searches for a popular (if, def, ...) Python stmt.
@ -583,6 +587,13 @@ class EditorWindow(object):
accel=get_accelerator(keydefs, event) accel=get_accelerator(keydefs, event)
menu.entryconfig(index,accelerator=accel) 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): def reset_help_menu_entries(self):
"Update the additional help entries on the Help menu" "Update the additional help entries on the Help menu"
help_list = idleConf.GetAllExtraHelpSourcesList() help_list = idleConf.GetAllExtraHelpSourcesList()

View File

@ -3,6 +3,15 @@ What's New in IDLE 1.2a0?
*Release date: XX-XXX-2005* *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. - Add keybindings for del-word-left and del-word-right.
- Discourage using an indent width other than 8 when using tabs to indent - Discourage using an indent width other than 8 when using tabs to indent

View File

@ -6,7 +6,7 @@ saved as user defined sets. Select startup options including shell/editor
and default window size. Define additional help sources. and default window size. Define additional help sources.
Note that tab width in IDLE is currently fixed at eight due to Tk issues. 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 * from Tkinter import *
@ -21,9 +21,7 @@ from configSectionNameDialog import GetCfgSectionNameDialog
from configHelpSourceEdit import GetHelpSourceDialog from configHelpSourceEdit import GetHelpSourceDialog
class ConfigDialog(Toplevel): class ConfigDialog(Toplevel):
"""
configuration dialog for idle
"""
def __init__(self,parent,title): def __init__(self,parent,title):
Toplevel.__init__(self, parent) Toplevel.__init__(self, parent)
self.configure(borderwidth=5) self.configure(borderwidth=5)
@ -93,8 +91,6 @@ class ConfigDialog(Toplevel):
self.fontBold=BooleanVar(self) self.fontBold=BooleanVar(self)
self.fontName=StringVar(self) self.fontName=StringVar(self)
self.spaceNum=IntVar(self) self.spaceNum=IntVar(self)
#self.tabCols=IntVar(self)
self.indentBySpaces=BooleanVar(self)
self.editFont=tkFont.Font(self,('courier',10,'normal')) self.editFont=tkFont.Font(self,('courier',10,'normal'))
##widget creation ##widget creation
#body frame #body frame
@ -124,25 +120,12 @@ class ConfigDialog(Toplevel):
text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]', text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]',
justify=LEFT,font=self.editFont) justify=LEFT,font=self.editFont)
#frameIndent #frameIndent
labelIndentTitle=Label(frameIndent,text='Set Indentation Defaults')
frameIndentType=Frame(frameIndent)
frameIndentSize=Frame(frameIndent) frameIndentSize=Frame(frameIndent)
labelIndentTypeTitle=Label(frameIndentType, labelSpaceNumTitle=Label(frameIndentSize, justify=LEFT,
text='Choose indentation type :') text='Python Standard: 4 Spaces!')
radioUseSpaces=Radiobutton(frameIndentType,variable=self.indentBySpaces, self.scaleSpaceNum=Scale(frameIndentSize, variable=self.spaceNum,
value=1,text='Tab key inserts spaces') label='Indentation Width', orient='horizontal',
radioUseTabs=Radiobutton(frameIndentType,variable=self.indentBySpaces, tickinterval=2, from_=2, to=16)
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)
#widget packing #widget packing
#body #body
frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH) frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH)
@ -160,17 +143,9 @@ class ConfigDialog(Toplevel):
frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
self.labelFontSample.pack(expand=TRUE,fill=BOTH) self.labelFontSample.pack(expand=TRUE,fill=BOTH)
#frameIndent #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) 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) labelSpaceNumTitle.pack(side=TOP,anchor=W,padx=5)
self.scaleSpaceNum.pack(side=TOP,padx=5,fill=X) 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 return frame
def CreatePageHighlight(self): def CreatePageHighlight(self):
@ -390,7 +365,6 @@ class ConfigDialog(Toplevel):
radioEncNone=Radiobutton(frameEncoding,variable=self.encoding, radioEncNone=Radiobutton(frameEncoding,variable=self.encoding,
value="none",text="None") value="none",text="None")
#frameHelp #frameHelp
##labelHelpTitle=Label(frameHelp,text='Help Options')
frameHelpList=Frame(frameHelp) frameHelpList=Frame(frameHelp)
frameHelpListButtons=Frame(frameHelpList) frameHelpListButtons=Frame(frameHelpList)
labelHelpListTitle=Label(frameHelpList,text='Additional Help Sources:') labelHelpListTitle=Label(frameHelpList,text='Additional Help Sources:')
@ -406,13 +380,6 @@ class ConfigDialog(Toplevel):
width=8,command=self.HelpListItemAdd) width=8,command=self.HelpListItemAdd)
self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove', self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove',
state=DISABLED,width=8,command=self.HelpListItemRemove) 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 #widget packing
#body #body
frameRun.pack(side=TOP,padx=5,pady=5,fill=X) frameRun.pack(side=TOP,padx=5,pady=5,fill=X)
@ -446,7 +413,6 @@ class ConfigDialog(Toplevel):
radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5) radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5)
radioEncLocale.pack(side=RIGHT,anchor=E,pady=5) radioEncLocale.pack(side=RIGHT,anchor=E,pady=5)
#frameHelp #frameHelp
##labelHelpTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y) frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y)
frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
labelHelpListTitle.pack(side=TOP,anchor=W) labelHelpListTitle.pack(side=TOP,anchor=W)
@ -455,8 +421,6 @@ class ConfigDialog(Toplevel):
self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5) self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5)
self.buttonHelpListAdd.pack(side=TOP,anchor=W) self.buttonHelpListAdd.pack(side=TOP,anchor=W)
self.buttonHelpListRemove.pack(side=TOP,anchor=W,pady=5) 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 return frame
def AttachVarCallbacks(self): def AttachVarCallbacks(self):
@ -464,8 +428,6 @@ class ConfigDialog(Toplevel):
self.fontName.trace_variable('w',self.VarChanged_fontName) self.fontName.trace_variable('w',self.VarChanged_fontName)
self.fontBold.trace_variable('w',self.VarChanged_fontBold) self.fontBold.trace_variable('w',self.VarChanged_fontBold)
self.spaceNum.trace_variable('w',self.VarChanged_spaceNum) 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.colour.trace_variable('w',self.VarChanged_colour)
self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme) self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme)
self.customTheme.trace_variable('w',self.VarChanged_customTheme) self.customTheme.trace_variable('w',self.VarChanged_customTheme)
@ -494,18 +456,10 @@ class ConfigDialog(Toplevel):
value=self.fontBold.get() value=self.fontBold.get()
self.AddChangedItem('main','EditorWindow','font-bold',value) 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): def VarChanged_spaceNum(self,*params):
value=self.spaceNum.get() value=self.spaceNum.get()
self.AddChangedItem('main','Indent','num-spaces',value) 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): def VarChanged_colour(self,*params):
self.OnNewColourSet() self.OnNewColourSet()
@ -912,12 +866,6 @@ class ConfigDialog(Toplevel):
self.textHighlightSample.tag_config(element, **colours) self.textHighlightSample.tag_config(element, **colours)
self.SetColourSample() self.SetColourSample()
## def OnCheckUserHelpBrowser(self):
## if self.userHelpBrowser.get():
## self.entryHelpBrowser.config(state=NORMAL)
## else:
## self.entryHelpBrowser.config(state=DISABLED)
def HelpSourceSelected(self,event): def HelpSourceSelected(self,event):
self.SetHelpListButtonStates() self.SetHelpListButtonStates()
@ -996,17 +944,10 @@ class ConfigDialog(Toplevel):
self.SetFontSample() self.SetFontSample()
def LoadTabCfg(self): def LoadTabCfg(self):
##indent type radiobuttons
spaceIndent=idleConf.GetOption('main','Indent','use-spaces',
default=1,type='bool')
self.indentBySpaces.set(spaceIndent)
##indent sizes ##indent sizes
spaceNum=idleConf.GetOption('main','Indent','num-spaces', spaceNum=idleConf.GetOption('main','Indent','num-spaces',
default=4,type='int') default=4,type='int')
#tabCols=idleConf.GetOption('main','Indent','tab-cols',
# default=4,type='int')
self.spaceNum.set(spaceNum) self.spaceNum.set(spaceNum)
#self.tabCols.set(tabCols)
def LoadThemeCfg(self): def LoadThemeCfg(self):
##current theme type radiobutton ##current theme type radiobutton
@ -1096,11 +1037,6 @@ class ConfigDialog(Toplevel):
for helpItem in self.userHelpList: for helpItem in self.userHelpList:
self.listHelp.insert(END,helpItem[0]) self.listHelp.insert(END,helpItem[0])
self.SetHelpListButtonStates() 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): def LoadConfigs(self):
""" """
@ -1171,17 +1107,12 @@ class ConfigDialog(Toplevel):
self.ResetChangedItems() #clear the changed items dict self.ResetChangedItems() #clear the changed items dict
def ActivateConfigChanges(self): def ActivateConfigChanges(self):
#things that need to be done to make "Dynamically apply configuration changes"
#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
winInstances=self.parent.instance_dict.keys() winInstances=self.parent.instance_dict.keys()
for instance in winInstances: for instance in winInstances:
instance.ResetColorizer() instance.ResetColorizer()
instance.ResetFont() instance.ResetFont()
instance.set_notabs_indentwidth()
instance.ResetKeybindings() instance.ResetKeybindings()
instance.reset_help_menu_entries() instance.reset_help_menu_entries()