Merge with 3.4
This commit is contained in:
commit
5427df266b
@ -31,18 +31,20 @@ class ConfigDialog(Toplevel):
|
||||
"""
|
||||
Toplevel.__init__(self, parent)
|
||||
self.parent = parent
|
||||
if _htest:
|
||||
parent.instance_dict = {}
|
||||
self.wm_withdraw()
|
||||
|
||||
self.configure(borderwidth=5)
|
||||
self.title('IDLE Preferences')
|
||||
if _htest:
|
||||
parent.instance_dict = {}
|
||||
self.geometry("+%d+%d" % (parent.winfo_rootx()+20,
|
||||
self.geometry(
|
||||
"+%d+%d" % (parent.winfo_rootx() + 20,
|
||||
parent.winfo_rooty() + (30 if not _htest else 150)))
|
||||
#Theme Elements. Each theme element key is its display name.
|
||||
#The first value of the tuple is the sample area tag name.
|
||||
#The second value is the display name list sort index.
|
||||
self.themeElements={'Normal Text':('normal','00'),
|
||||
self.themeElements={
|
||||
'Normal Text':('normal', '00'),
|
||||
'Python Keywords':('keyword', '01'),
|
||||
'Python Definitions':('definition', '02'),
|
||||
'Python Builtins':('builtin', '03'),
|
||||
@ -90,15 +92,15 @@ class ConfigDialog(Toplevel):
|
||||
## self.buttonHelp = Button(frameActionButtons, text='Help',
|
||||
## command=self.Help, takefocus=FALSE,
|
||||
## **paddingArgs)
|
||||
self.buttonOk = Button(frameActionButtons,text='Ok',
|
||||
command=self.Ok,takefocus=FALSE,
|
||||
**paddingArgs)
|
||||
self.buttonApply = Button(frameActionButtons,text='Apply',
|
||||
command=self.Apply,takefocus=FALSE,
|
||||
**paddingArgs)
|
||||
self.buttonCancel = Button(frameActionButtons,text='Cancel',
|
||||
command=self.Cancel,takefocus=FALSE,
|
||||
**paddingArgs)
|
||||
self.buttonOk = Button(
|
||||
frameActionButtons, text='Ok',
|
||||
command=self.Ok, takefocus=FALSE, **paddingArgs)
|
||||
self.buttonApply = Button(
|
||||
frameActionButtons, text='Apply',
|
||||
command=self.Apply, takefocus=FALSE, **paddingArgs)
|
||||
self.buttonCancel = Button(
|
||||
frameActionButtons, text='Cancel',
|
||||
command=self.Cancel, takefocus=FALSE, **paddingArgs)
|
||||
self.CreatePageFontTab()
|
||||
self.CreatePageHighlight()
|
||||
self.CreatePageKeys()
|
||||
@ -123,37 +125,40 @@ class ConfigDialog(Toplevel):
|
||||
#body frame
|
||||
frame = self.tabPages.pages['Fonts/Tabs'].frame
|
||||
#body section frames
|
||||
frameFont=LabelFrame(frame,borderwidth=2,relief=GROOVE,
|
||||
text=' Base Editor Font ')
|
||||
frameIndent=LabelFrame(frame,borderwidth=2,relief=GROOVE,
|
||||
text=' Indentation Width ')
|
||||
frameFont = LabelFrame(
|
||||
frame, borderwidth=2, relief=GROOVE, text=' Base Editor Font ')
|
||||
frameIndent = LabelFrame(
|
||||
frame, borderwidth=2, relief=GROOVE, text=' Indentation Width ')
|
||||
#frameFont
|
||||
frameFontName = Frame(frameFont)
|
||||
frameFontParam = Frame(frameFont)
|
||||
labelFontNameTitle=Label(frameFontName,justify=LEFT,
|
||||
text='Font Face :')
|
||||
self.listFontName=Listbox(frameFontName,height=5,takefocus=FALSE,
|
||||
exportselection=FALSE)
|
||||
self.listFontName.bind('<ButtonRelease-1>',self.OnListFontButtonRelease)
|
||||
labelFontNameTitle = Label(
|
||||
frameFontName, justify=LEFT, text='Font Face :')
|
||||
self.listFontName = Listbox(
|
||||
frameFontName, height=5, takefocus=FALSE, exportselection=FALSE)
|
||||
self.listFontName.bind(
|
||||
'<ButtonRelease-1>', self.OnListFontButtonRelease)
|
||||
scrollFont = Scrollbar(frameFontName)
|
||||
scrollFont.config(command=self.listFontName.yview)
|
||||
self.listFontName.config(yscrollcommand=scrollFont.set)
|
||||
labelFontSizeTitle = Label(frameFontParam, text='Size :')
|
||||
self.optMenuFontSize=DynOptionMenu(frameFontParam,self.fontSize,None,
|
||||
command=self.SetFontSample)
|
||||
checkFontBold=Checkbutton(frameFontParam,variable=self.fontBold,
|
||||
onvalue=1,offvalue=0,text='Bold',command=self.SetFontSample)
|
||||
self.optMenuFontSize = DynOptionMenu(
|
||||
frameFontParam, self.fontSize, None, command=self.SetFontSample)
|
||||
checkFontBold = Checkbutton(
|
||||
frameFontParam, variable=self.fontBold, onvalue=1,
|
||||
offvalue=0, text='Bold', command=self.SetFontSample)
|
||||
frameFontSample = Frame(frameFont, relief=SOLID, borderwidth=1)
|
||||
self.labelFontSample=Label(frameFontSample,
|
||||
text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]',
|
||||
justify=LEFT,font=self.editFont)
|
||||
self.labelFontSample = Label(
|
||||
frameFontSample, justify=LEFT, font=self.editFont,
|
||||
text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]')
|
||||
#frameIndent
|
||||
frameIndentSize = Frame(frameIndent)
|
||||
labelSpaceNumTitle=Label(frameIndentSize, justify=LEFT,
|
||||
labelSpaceNumTitle = Label(
|
||||
frameIndentSize, justify=LEFT,
|
||||
text='Python Standard: 4 Spaces!')
|
||||
self.scaleSpaceNum=Scale(frameIndentSize, variable=self.spaceNum,
|
||||
orient='horizontal',
|
||||
tickinterval=2, from_=2, to=16)
|
||||
self.scaleSpaceNum = Scale(
|
||||
frameIndentSize, variable=self.spaceNum,
|
||||
orient='horizontal', tickinterval=2, from_=2, to=16)
|
||||
|
||||
#widget packing
|
||||
#body
|
||||
@ -195,54 +200,69 @@ class ConfigDialog(Toplevel):
|
||||
frameTheme = LabelFrame(frame, borderwidth=2, relief=GROOVE,
|
||||
text=' Highlighting Theme ')
|
||||
#frameCustom
|
||||
self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1,
|
||||
self.textHighlightSample=Text(
|
||||
frameCustom, relief=SOLID, borderwidth=1,
|
||||
font=('courier', 12, ''), cursor='hand2', width=21, height=11,
|
||||
takefocus=FALSE, highlightthickness=0, wrap=NONE)
|
||||
text=self.textHighlightSample
|
||||
text.bind('<Double-Button-1>', lambda e: 'break')
|
||||
text.bind('<B1-Motion>', lambda e: 'break')
|
||||
textAndTags=(('#you can click here','comment'),('\n','normal'),
|
||||
('#to choose items','comment'),('\n','normal'),('def','keyword'),
|
||||
(' ','normal'),('func','definition'),('(param):','normal'),
|
||||
('\n ','normal'),('"""string"""','string'),('\n var0 = ','normal'),
|
||||
("'string'",'string'),('\n var1 = ','normal'),("'selected'",'hilite'),
|
||||
('\n var2 = ','normal'),("'found'",'hit'),
|
||||
('\n var3 = ','normal'),('list', 'builtin'), ('(','normal'),
|
||||
textAndTags=(
|
||||
('#you can click here', 'comment'), ('\n', 'normal'),
|
||||
('#to choose items', 'comment'), ('\n', 'normal'),
|
||||
('def', 'keyword'), (' ', 'normal'),
|
||||
('func', 'definition'), ('(param):\n ', 'normal'),
|
||||
('"""string"""', 'string'), ('\n var0 = ', 'normal'),
|
||||
("'string'", 'string'), ('\n var1 = ', 'normal'),
|
||||
("'selected'", 'hilite'), ('\n var2 = ', 'normal'),
|
||||
("'found'", 'hit'), ('\n var3 = ', 'normal'),
|
||||
('list', 'builtin'), ('(', 'normal'),
|
||||
('None', 'keyword'), (')\n\n', 'normal'),
|
||||
(' error ','error'),(' ','normal'),('cursor |','cursor'),
|
||||
('\n ','normal'),('shell','console'),(' ','normal'),('stdout','stdout'),
|
||||
(' ','normal'),('stderr','stderr'),('\n','normal'))
|
||||
(' error ', 'error'), (' ', 'normal'),
|
||||
('cursor |', 'cursor'), ('\n ', 'normal'),
|
||||
('shell', 'console'), (' ', 'normal'),
|
||||
('stdout', 'stdout'), (' ', 'normal'),
|
||||
('stderr', 'stderr'), ('\n', 'normal'))
|
||||
for txTa in textAndTags:
|
||||
text.insert(END, txTa[0], txTa[1])
|
||||
for element in self.themeElements:
|
||||
text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>',
|
||||
lambda event,elem=element: event.widget.winfo_toplevel()
|
||||
.highlightTarget.set(elem))
|
||||
def tem(event, elem=element):
|
||||
event.widget.winfo_toplevel().highlightTarget.set(elem)
|
||||
text.tag_bind(
|
||||
self.themeElements[element][0], '<ButtonPress-1>', tem)
|
||||
text.config(state=DISABLED)
|
||||
self.frameColourSet = Frame(frameCustom, relief=SOLID, borderwidth=1)
|
||||
frameFgBg = Frame(frameCustom)
|
||||
buttonSetColour=Button(self.frameColourSet,text='Choose Colour for :',
|
||||
buttonSetColour = Button(
|
||||
self.frameColourSet, text='Choose Colour for :',
|
||||
command=self.GetColour, highlightthickness=0)
|
||||
self.optMenuHighlightTarget=DynOptionMenu(self.frameColourSet,
|
||||
self.highlightTarget,None,highlightthickness=0)#,command=self.SetHighlightTargetBinding
|
||||
self.radioFg=Radiobutton(frameFgBg,variable=self.fgHilite,
|
||||
value=1,text='Foreground',command=self.SetColourSampleBinding)
|
||||
self.radioBg=Radiobutton(frameFgBg,variable=self.fgHilite,
|
||||
value=0,text='Background',command=self.SetColourSampleBinding)
|
||||
self.optMenuHighlightTarget = DynOptionMenu(
|
||||
self.frameColourSet, self.highlightTarget, None,
|
||||
highlightthickness=0) #, command=self.SetHighlightTargetBinding
|
||||
self.radioFg = Radiobutton(
|
||||
frameFgBg, variable=self.fgHilite, value=1,
|
||||
text='Foreground', command=self.SetColourSampleBinding)
|
||||
self.radioBg=Radiobutton(
|
||||
frameFgBg, variable=self.fgHilite, value=0,
|
||||
text='Background', command=self.SetColourSampleBinding)
|
||||
self.fgHilite.set(1)
|
||||
buttonSaveCustomTheme=Button(frameCustom,
|
||||
text='Save as New Custom Theme',command=self.SaveAsNewTheme)
|
||||
buttonSaveCustomTheme = Button(
|
||||
frameCustom, text='Save as New Custom Theme',
|
||||
command=self.SaveAsNewTheme)
|
||||
#frameTheme
|
||||
labelTypeTitle = Label(frameTheme, text='Select : ')
|
||||
self.radioThemeBuiltin=Radiobutton(frameTheme,variable=self.themeIsBuiltin,
|
||||
value=1,command=self.SetThemeType,text='a Built-in Theme')
|
||||
self.radioThemeCustom=Radiobutton(frameTheme,variable=self.themeIsBuiltin,
|
||||
value=0,command=self.SetThemeType,text='a Custom Theme')
|
||||
self.optMenuThemeBuiltin=DynOptionMenu(frameTheme,
|
||||
self.builtinTheme,None,command=None)
|
||||
self.optMenuThemeCustom=DynOptionMenu(frameTheme,
|
||||
self.customTheme,None,command=None)
|
||||
self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme',
|
||||
self.radioThemeBuiltin = Radiobutton(
|
||||
frameTheme, variable=self.themeIsBuiltin, value=1,
|
||||
command=self.SetThemeType, text='a Built-in Theme')
|
||||
self.radioThemeCustom = Radiobutton(
|
||||
frameTheme, variable=self.themeIsBuiltin, value=0,
|
||||
command=self.SetThemeType, text='a Custom Theme')
|
||||
self.optMenuThemeBuiltin = DynOptionMenu(
|
||||
frameTheme, self.builtinTheme, None, command=None)
|
||||
self.optMenuThemeCustom=DynOptionMenu(
|
||||
frameTheme, self.customTheme, None, command=None)
|
||||
self.buttonDeleteCustomTheme=Button(
|
||||
frameTheme, text='Delete Custom Theme',
|
||||
command=self.DeleteCustomTheme)
|
||||
|
||||
##widget packing
|
||||
@ -252,10 +272,11 @@ class ConfigDialog(Toplevel):
|
||||
#frameCustom
|
||||
self.frameColourSet.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=X)
|
||||
frameFgBg.pack(side=TOP, padx=5, pady=0)
|
||||
self.textHighlightSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,
|
||||
fill=BOTH)
|
||||
self.textHighlightSample.pack(
|
||||
side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
|
||||
buttonSetColour.pack(side=TOP, expand=TRUE, fill=X, padx=8, pady=4)
|
||||
self.optMenuHighlightTarget.pack(side=TOP,expand=TRUE,fill=X,padx=8,pady=3)
|
||||
self.optMenuHighlightTarget.pack(
|
||||
side=TOP, expand=TRUE, fill=X, padx=8, pady=3)
|
||||
self.radioFg.pack(side=LEFT, anchor=E)
|
||||
self.radioBg.pack(side=RIGHT, anchor=W)
|
||||
buttonSaveCustomTheme.pack(side=BOTTOM, fill=X, padx=5, pady=5)
|
||||
@ -280,39 +301,45 @@ class ConfigDialog(Toplevel):
|
||||
#body frame
|
||||
frame = self.tabPages.pages['Keys'].frame
|
||||
#body section frames
|
||||
frameCustom=LabelFrame(frame,borderwidth=2,relief=GROOVE,
|
||||
frameCustom = LabelFrame(
|
||||
frame, borderwidth=2, relief=GROOVE,
|
||||
text=' Custom Key Bindings ')
|
||||
frameKeySets=LabelFrame(frame,borderwidth=2,relief=GROOVE,
|
||||
text=' Key Set ')
|
||||
frameKeySets = LabelFrame(
|
||||
frame, borderwidth=2, relief=GROOVE, text=' Key Set ')
|
||||
#frameCustom
|
||||
frameTarget = Frame(frameCustom)
|
||||
labelTargetTitle = Label(frameTarget, text='Action - Key(s)')
|
||||
scrollTargetY = Scrollbar(frameTarget)
|
||||
scrollTargetX = Scrollbar(frameTarget, orient=HORIZONTAL)
|
||||
self.listBindings=Listbox(frameTarget,takefocus=FALSE,
|
||||
exportselection=FALSE)
|
||||
self.listBindings = Listbox(
|
||||
frameTarget, takefocus=FALSE, exportselection=FALSE)
|
||||
self.listBindings.bind('<ButtonRelease-1>', self.KeyBindingSelected)
|
||||
scrollTargetY.config(command=self.listBindings.yview)
|
||||
scrollTargetX.config(command=self.listBindings.xview)
|
||||
self.listBindings.config(yscrollcommand=scrollTargetY.set)
|
||||
self.listBindings.config(xscrollcommand=scrollTargetX.set)
|
||||
self.buttonNewKeys=Button(frameCustom,text='Get New Keys for Selection',
|
||||
self.buttonNewKeys = Button(
|
||||
frameCustom, text='Get New Keys for Selection',
|
||||
command=self.GetNewKeys, state=DISABLED)
|
||||
#frameKeySets
|
||||
frames = [Frame(frameKeySets, padx=2, pady=2, borderwidth=0)
|
||||
for i in range(2)]
|
||||
self.radioKeysBuiltin=Radiobutton(frames[0],variable=self.keysAreBuiltin,
|
||||
value=1,command=self.SetKeysType,text='Use a Built-in Key Set')
|
||||
self.radioKeysCustom=Radiobutton(frames[0],variable=self.keysAreBuiltin,
|
||||
value=0,command=self.SetKeysType,text='Use a Custom Key Set')
|
||||
self.optMenuKeysBuiltin=DynOptionMenu(frames[0],
|
||||
self.builtinKeys,None,command=None)
|
||||
self.optMenuKeysCustom=DynOptionMenu(frames[0],
|
||||
self.customKeys,None,command=None)
|
||||
self.buttonDeleteCustomKeys=Button(frames[1],text='Delete Custom Key Set',
|
||||
self.radioKeysBuiltin = Radiobutton(
|
||||
frames[0], variable=self.keysAreBuiltin, value=1,
|
||||
command=self.SetKeysType, text='Use a Built-in Key Set')
|
||||
self.radioKeysCustom = Radiobutton(
|
||||
frames[0], variable=self.keysAreBuiltin, value=0,
|
||||
command=self.SetKeysType, text='Use a Custom Key Set')
|
||||
self.optMenuKeysBuiltin = DynOptionMenu(
|
||||
frames[0], self.builtinKeys, None, command=None)
|
||||
self.optMenuKeysCustom = DynOptionMenu(
|
||||
frames[0], self.customKeys, None, command=None)
|
||||
self.buttonDeleteCustomKeys = Button(
|
||||
frames[1], text='Delete Custom Key Set',
|
||||
command=self.DeleteCustomKeys)
|
||||
buttonSaveCustomKeys=Button(frames[1],
|
||||
text='Save as New Custom Key Set',command=self.SaveAsNewKeySet)
|
||||
buttonSaveCustomKeys = Button(
|
||||
frames[1], text='Save as New Custom Key Set',
|
||||
command=self.SaveAsNewKeySet)
|
||||
|
||||
##widget packing
|
||||
#body
|
||||
@ -364,45 +391,53 @@ class ConfigDialog(Toplevel):
|
||||
text=' Additional Help Sources ')
|
||||
#frameRun
|
||||
labelRunChoiceTitle = Label(frameRun, text='At Startup')
|
||||
radioStartupEdit=Radiobutton(frameRun,variable=self.startupEdit,
|
||||
value=1,command=self.SetKeysType,text="Open Edit Window")
|
||||
radioStartupShell=Radiobutton(frameRun,variable=self.startupEdit,
|
||||
value=0,command=self.SetKeysType,text='Open Shell Window')
|
||||
radioStartupEdit = Radiobutton(
|
||||
frameRun, variable=self.startupEdit, value=1,
|
||||
command=self.SetKeysType, text="Open Edit Window")
|
||||
radioStartupShell = Radiobutton(
|
||||
frameRun, variable=self.startupEdit, value=0,
|
||||
command=self.SetKeysType, text='Open Shell Window')
|
||||
#frameSave
|
||||
labelRunSaveTitle = Label(frameSave, text='At Start of Run (F5) ')
|
||||
radioSaveAsk=Radiobutton(frameSave,variable=self.autoSave,
|
||||
value=0,command=self.SetKeysType,text="Prompt to Save")
|
||||
radioSaveAuto=Radiobutton(frameSave,variable=self.autoSave,
|
||||
value=1,command=self.SetKeysType,text='No Prompt')
|
||||
radioSaveAsk = Radiobutton(
|
||||
frameSave, variable=self.autoSave, value=0,
|
||||
command=self.SetKeysType, text="Prompt to Save")
|
||||
radioSaveAuto = Radiobutton(
|
||||
frameSave, variable=self.autoSave, value=1,
|
||||
command=self.SetKeysType, text='No Prompt')
|
||||
#frameWinSize
|
||||
labelWinSizeTitle=Label(frameWinSize,text='Initial Window Size'+
|
||||
' (in characters)')
|
||||
labelWinSizeTitle = Label(
|
||||
frameWinSize, text='Initial Window Size (in characters)')
|
||||
labelWinWidthTitle = Label(frameWinSize, text='Width')
|
||||
entryWinWidth=Entry(frameWinSize,textvariable=self.winWidth,
|
||||
width=3)
|
||||
entryWinWidth = Entry(
|
||||
frameWinSize, textvariable=self.winWidth, width=3)
|
||||
labelWinHeightTitle = Label(frameWinSize, text='Height')
|
||||
entryWinHeight=Entry(frameWinSize,textvariable=self.winHeight,
|
||||
width=3)
|
||||
entryWinHeight = Entry(
|
||||
frameWinSize, textvariable=self.winHeight, width=3)
|
||||
#paragraphFormatWidth
|
||||
labelParaWidthTitle=Label(frameParaSize,text='Paragraph reformat'+
|
||||
' width (in characters)')
|
||||
entryParaWidth=Entry(frameParaSize,textvariable=self.paraWidth,
|
||||
width=3)
|
||||
labelParaWidthTitle = Label(
|
||||
frameParaSize, text='Paragraph reformat width (in characters)')
|
||||
entryParaWidth = Entry(
|
||||
frameParaSize, textvariable=self.paraWidth, width=3)
|
||||
#frameHelp
|
||||
frameHelpList = Frame(frameHelp)
|
||||
frameHelpListButtons = Frame(frameHelpList)
|
||||
scrollHelpList = Scrollbar(frameHelpList)
|
||||
self.listHelp=Listbox(frameHelpList,height=5,takefocus=FALSE,
|
||||
self.listHelp = Listbox(
|
||||
frameHelpList, height=5, takefocus=FALSE,
|
||||
exportselection=FALSE)
|
||||
scrollHelpList.config(command=self.listHelp.yview)
|
||||
self.listHelp.config(yscrollcommand=scrollHelpList.set)
|
||||
self.listHelp.bind('<ButtonRelease-1>', self.HelpSourceSelected)
|
||||
self.buttonHelpListEdit=Button(frameHelpListButtons,text='Edit',
|
||||
state=DISABLED,width=8,command=self.HelpListItemEdit)
|
||||
self.buttonHelpListAdd=Button(frameHelpListButtons,text='Add',
|
||||
self.buttonHelpListEdit = Button(
|
||||
frameHelpListButtons, text='Edit', state=DISABLED,
|
||||
width=8, command=self.HelpListItemEdit)
|
||||
self.buttonHelpListAdd = Button(
|
||||
frameHelpListButtons, text='Add',
|
||||
width=8, command=self.HelpListItemAdd)
|
||||
self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove',
|
||||
state=DISABLED,width=8,command=self.HelpListItemRemove)
|
||||
self.buttonHelpListRemove = Button(
|
||||
frameHelpListButtons, text='Remove', state=DISABLED,
|
||||
width=8, command=self.HelpListItemRemove)
|
||||
|
||||
#widget packing
|
||||
#body
|
||||
@ -561,13 +596,14 @@ class ConfigDialog(Toplevel):
|
||||
#dictionary. The key should be the config file section name and the
|
||||
#value a dictionary, whose key:value pairs are item=value pairs for
|
||||
#that config file section.
|
||||
self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
|
||||
self.changedItems = {'main':{}, 'highlight':{}, 'keys':{},
|
||||
'extensions':{}}
|
||||
|
||||
def AddChangedItem(self,type,section,item,value):
|
||||
def AddChangedItem(self, typ, section, item, value):
|
||||
value = str(value) #make sure we use a string
|
||||
if section not in self.changedItems[type]:
|
||||
self.changedItems[type][section]={}
|
||||
self.changedItems[type][section][item]=value
|
||||
if section not in self.changedItems[typ]:
|
||||
self.changedItems[typ][section] = {}
|
||||
self.changedItems[typ][section][item] = value
|
||||
|
||||
def GetDefaultItems(self):
|
||||
dItems={'main':{}, 'highlight':{}, 'keys':{}, 'extensions':{}}
|
||||
@ -621,7 +657,7 @@ class ConfigDialog(Toplevel):
|
||||
currentKeySequences).result
|
||||
if newKeys: #new keys were specified
|
||||
if self.keysAreBuiltin.get(): #current key set is a built-in
|
||||
message=('Your changes will be saved as a new Custom Key Set. '+
|
||||
message = ('Your changes will be saved as a new Custom Key Set.'
|
||||
' Enter a name for your new Custom Key Set below.')
|
||||
newKeySet = self.GetNewKeysName(message)
|
||||
if not newKeySet: #user cancelled custom key set creation
|
||||
@ -642,8 +678,8 @@ class ConfigDialog(Toplevel):
|
||||
def GetNewKeysName(self, message):
|
||||
usedNames = (idleConf.GetSectionList('user', 'keys') +
|
||||
idleConf.GetSectionList('default', 'keys'))
|
||||
newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set',
|
||||
message,usedNames).result
|
||||
newKeySet = GetCfgSectionNameDialog(
|
||||
self, 'New Custom Key Set', message, usedNames).result
|
||||
return newKeySet
|
||||
|
||||
def SaveAsNewKeySet(self):
|
||||
@ -706,9 +742,9 @@ class ConfigDialog(Toplevel):
|
||||
|
||||
def DeleteCustomKeys(self):
|
||||
keySetName=self.customKeys.get()
|
||||
if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+
|
||||
'to delete the key set %r ?' % (keySetName),
|
||||
parent=self):
|
||||
delmsg = 'Are you sure you wish to delete the key set %r ?'
|
||||
if not tkMessageBox.askyesno(
|
||||
'Delete Key Set', delmsg % keySetName, parent=self):
|
||||
return
|
||||
#remove key set from config
|
||||
idleConf.userCfg['keys'].remove_section(keySetName)
|
||||
@ -733,9 +769,9 @@ class ConfigDialog(Toplevel):
|
||||
|
||||
def DeleteCustomTheme(self):
|
||||
themeName = self.customTheme.get()
|
||||
if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
|
||||
'to delete the theme %r ?' % (themeName,),
|
||||
parent=self):
|
||||
delmsg = 'Are you sure you wish to delete the theme %r ?'
|
||||
if not tkMessageBox.askyesno(
|
||||
'Delete Theme', delmsg % themeName, parent=self):
|
||||
return
|
||||
#remove theme from config
|
||||
idleConf.userCfg['highlight'].remove_section(themeName)
|
||||
@ -761,12 +797,13 @@ class ConfigDialog(Toplevel):
|
||||
def GetColour(self):
|
||||
target = self.highlightTarget.get()
|
||||
prevColour = self.frameColourSet.cget('bg')
|
||||
rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
|
||||
title='Pick new colour for : '+target,initialcolor=prevColour)
|
||||
rgbTuplet, colourString = tkColorChooser.askcolor(
|
||||
parent=self, title='Pick new colour for : '+target,
|
||||
initialcolor=prevColour)
|
||||
if colourString and (colourString != prevColour):
|
||||
#user didn't cancel, and they chose a new colour
|
||||
if self.themeIsBuiltin.get(): #current theme is a built-in
|
||||
message=('Your changes will be saved as a new Custom Theme. '+
|
||||
message = ('Your changes will be saved as a new Custom Theme. '
|
||||
'Enter a name for your new Custom Theme below.')
|
||||
newTheme = self.GetNewThemeName(message)
|
||||
if not newTheme: #user cancelled custom theme creation
|
||||
@ -780,8 +817,7 @@ class ConfigDialog(Toplevel):
|
||||
def OnNewColourSet(self):
|
||||
newColour=self.colour.get()
|
||||
self.frameColourSet.config(bg=newColour) #set sample
|
||||
if self.fgHilite.get(): plane='foreground'
|
||||
else: plane='background'
|
||||
plane ='foreground' if self.fgHilite.get() else 'background'
|
||||
sampleElement = self.themeElements[self.highlightTarget.get()][0]
|
||||
self.textHighlightSample.tag_config(sampleElement, **{plane:newColour})
|
||||
theme = self.customTheme.get()
|
||||
@ -791,8 +827,8 @@ class ConfigDialog(Toplevel):
|
||||
def GetNewThemeName(self, message):
|
||||
usedNames = (idleConf.GetSectionList('user', 'highlight') +
|
||||
idleConf.GetSectionList('default', 'highlight'))
|
||||
newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
|
||||
message,usedNames).result
|
||||
newTheme = GetCfgSectionNameDialog(
|
||||
self, 'New Custom Theme', message, usedNames).result
|
||||
return newTheme
|
||||
|
||||
def SaveAsNewTheme(self):
|
||||
@ -831,10 +867,7 @@ class ConfigDialog(Toplevel):
|
||||
|
||||
def SetFontSample(self, event=None):
|
||||
fontName = self.fontName.get()
|
||||
if self.fontBold.get():
|
||||
fontWeight=tkFont.BOLD
|
||||
else:
|
||||
fontWeight=tkFont.NORMAL
|
||||
fontWeight = tkFont.BOLD if self.fontBold.get() else tkFont.NORMAL
|
||||
newFont = (fontName, self.fontSize.get(), fontWeight)
|
||||
self.labelFontSample.config(font=newFont)
|
||||
self.textHighlightSample.configure(font=newFont)
|
||||
@ -856,8 +889,7 @@ class ConfigDialog(Toplevel):
|
||||
def SetColourSample(self):
|
||||
#set the colour smaple area
|
||||
tag = self.themeElements[self.highlightTarget.get()][0]
|
||||
if self.fgHilite.get(): plane='foreground'
|
||||
else: plane='background'
|
||||
plane = 'foreground' if self.fgHilite.get() else 'background'
|
||||
colour = self.textHighlightSample.tag_cget(tag, plane)
|
||||
self.frameColourSet.config(bg=colour)
|
||||
|
||||
@ -870,8 +902,8 @@ class ConfigDialog(Toplevel):
|
||||
element = self.themeElements[elementTitle][0]
|
||||
colours = idleConf.GetHighlight(theme, element)
|
||||
if element == 'cursor': #cursor sample needs special painting
|
||||
colours['background']=idleConf.GetHighlight(theme,
|
||||
'normal', fgBg='bg')
|
||||
colours['background'] = idleConf.GetHighlight(
|
||||
theme, 'normal', fgBg='bg')
|
||||
#handle any unsaved changes to this theme
|
||||
if theme in self.changedItems['highlight']:
|
||||
themeDict = self.changedItems['highlight'][theme]
|
||||
@ -908,8 +940,9 @@ class ConfigDialog(Toplevel):
|
||||
def HelpListItemEdit(self):
|
||||
itemIndex = self.listHelp.index(ANCHOR)
|
||||
helpSource = self.userHelpList[itemIndex]
|
||||
newHelpSource=GetHelpSourceDialog(self,'Edit Help Source',
|
||||
menuItem=helpSource[0],filePath=helpSource[1]).result
|
||||
newHelpSource = GetHelpSourceDialog(
|
||||
self, 'Edit Help Source', menuItem=helpSource[0],
|
||||
filePath=helpSource[1]).result
|
||||
if (not newHelpSource) or (newHelpSource == helpSource):
|
||||
return #no changes
|
||||
self.userHelpList[itemIndex] = newHelpSource
|
||||
@ -929,7 +962,8 @@ class ConfigDialog(Toplevel):
|
||||
"Clear and rebuild the HelpFiles section in self.changedItems"
|
||||
self.changedItems['main']['HelpFiles'] = {}
|
||||
for num in range(1, len(self.userHelpList) + 1):
|
||||
self.AddChangedItem('main','HelpFiles',str(num),
|
||||
self.AddChangedItem(
|
||||
'main', 'HelpFiles', str(num),
|
||||
';'.join(self.userHelpList[num-1][:2]))
|
||||
|
||||
def LoadFontCfg(self):
|
||||
@ -938,8 +972,8 @@ class ConfigDialog(Toplevel):
|
||||
fonts.sort()
|
||||
for font in fonts:
|
||||
self.listFontName.insert(END, font)
|
||||
configuredFont=idleConf.GetOption('main','EditorWindow','font',
|
||||
default='courier')
|
||||
configuredFont = idleConf.GetOption(
|
||||
'main', 'EditorWindow', 'font', default='courier')
|
||||
lc_configuredFont = configuredFont.lower()
|
||||
self.fontName.set(lc_configuredFont)
|
||||
lc_fonts = [s.lower() for s in fonts]
|
||||
@ -949,26 +983,26 @@ class ConfigDialog(Toplevel):
|
||||
self.listFontName.select_set(currentFontIndex)
|
||||
self.listFontName.select_anchor(currentFontIndex)
|
||||
##font size dropdown
|
||||
fontSize=idleConf.GetOption('main', 'EditorWindow', 'font-size',
|
||||
type='int', default='10')
|
||||
self.optMenuFontSize.SetMenu(('7','8','9','10','11','12','13','14',
|
||||
'16','18','20','22'), fontSize )
|
||||
fontSize = idleConf.GetOption(
|
||||
'main', 'EditorWindow', 'font-size', type='int', default='10')
|
||||
self.optMenuFontSize.SetMenu(('7', '8', '9', '10', '11', '12', '13',
|
||||
'14', '16', '18', '20', '22'), fontSize )
|
||||
##fontWeight
|
||||
self.fontBold.set(idleConf.GetOption('main','EditorWindow',
|
||||
'font-bold',default=0,type='bool'))
|
||||
self.fontBold.set(idleConf.GetOption(
|
||||
'main', 'EditorWindow', 'font-bold', default=0, type='bool'))
|
||||
##font sample
|
||||
self.SetFontSample()
|
||||
|
||||
def LoadTabCfg(self):
|
||||
##indent sizes
|
||||
spaceNum=idleConf.GetOption('main','Indent','num-spaces',
|
||||
default=4,type='int')
|
||||
spaceNum = idleConf.GetOption(
|
||||
'main', 'Indent', 'num-spaces', default=4, type='int')
|
||||
self.spaceNum.set(spaceNum)
|
||||
|
||||
def LoadThemeCfg(self):
|
||||
##current theme type radiobutton
|
||||
self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default',
|
||||
type='bool',default=1))
|
||||
self.themeIsBuiltin.set(idleConf.GetOption(
|
||||
'main', 'Theme', 'default', type='bool', default=1))
|
||||
##currently set theme
|
||||
currentOption = idleConf.CurrentTheme()
|
||||
##load available theme option menus
|
||||
@ -1000,8 +1034,8 @@ class ConfigDialog(Toplevel):
|
||||
|
||||
def LoadKeyCfg(self):
|
||||
##current keys type radiobutton
|
||||
self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default',
|
||||
type='bool',default=1))
|
||||
self.keysAreBuiltin.set(idleConf.GetOption(
|
||||
'main', 'Keys', 'default', type='bool', default=1))
|
||||
##currently set keys
|
||||
currentOption = idleConf.CurrentKeys()
|
||||
##load available keyset option menus
|
||||
@ -1030,22 +1064,22 @@ class ConfigDialog(Toplevel):
|
||||
|
||||
def LoadGeneralCfg(self):
|
||||
#startup state
|
||||
self.startupEdit.set(idleConf.GetOption('main','General',
|
||||
'editor-on-startup',default=1,type='bool'))
|
||||
self.startupEdit.set(idleConf.GetOption(
|
||||
'main', 'General', 'editor-on-startup', default=1, type='bool'))
|
||||
#autosave state
|
||||
self.autoSave.set(idleConf.GetOption('main', 'General', 'autosave',
|
||||
default=0, type='bool'))
|
||||
self.autoSave.set(idleConf.GetOption(
|
||||
'main', 'General', 'autosave', default=0, type='bool'))
|
||||
#initial window size
|
||||
self.winWidth.set(idleConf.GetOption('main','EditorWindow','width',
|
||||
type='int'))
|
||||
self.winHeight.set(idleConf.GetOption('main','EditorWindow','height',
|
||||
type='int'))
|
||||
self.winWidth.set(idleConf.GetOption(
|
||||
'main', 'EditorWindow', 'width', type='int'))
|
||||
self.winHeight.set(idleConf.GetOption(
|
||||
'main', 'EditorWindow', 'height', type='int'))
|
||||
#initial paragraph reformat size
|
||||
self.paraWidth.set(idleConf.GetOption('main','FormatParagraph','paragraph',
|
||||
type='int'))
|
||||
self.paraWidth.set(idleConf.GetOption(
|
||||
'main', 'FormatParagraph', 'paragraph', type='int'))
|
||||
# default source encoding
|
||||
self.encoding.set(idleConf.GetOption('main', 'EditorWindow',
|
||||
'encoding', default='none'))
|
||||
self.encoding.set(idleConf.GetOption(
|
||||
'main', 'EditorWindow', 'encoding', default='none'))
|
||||
# additional help sources
|
||||
self.userHelpList = idleConf.GetAllExtraHelpSourcesList()
|
||||
for helpItem in self.userHelpList:
|
||||
|
Loading…
x
Reference in New Issue
Block a user