mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
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:
parent
b5646aa3fb
commit
acdef858a5
3 changed files with 41 additions and 90 deletions
|
|
@ -157,12 +157,12 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
|
|||
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 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
|
|||
# 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 @@ def ResetKeybindings(self):
|
|||
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()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,15 @@ What's New in IDLE 1.2a0?
|
|||
|
||||
*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
|
||||
|
|
|
|||
|
|
@ -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 @@ def CreatePageFontTab(self):
|
|||
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 @@ def CreatePageFontTab(self):
|
|||
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 @@ def CreatePageFontTab(self):
|
|||
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 @@ def CreatePageGeneral(self):
|
|||
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 @@ def CreatePageGeneral(self):
|
|||
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 @@ def CreatePageGeneral(self):
|
|||
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 @@ def CreatePageGeneral(self):
|
|||
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 @@ def AttachVarCallbacks(self):
|
|||
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 @@ def VarChanged_fontBold(self,*params):
|
|||
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 @@ def PaintThemeSample(self):
|
|||
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 @@ def LoadFontCfg(self):
|
|||
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 @@ def LoadGeneralCfg(self):
|
|||
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 @@ def SaveAllChangedConfigs(self):
|
|||
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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue