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