2003-01-10 16:13:57 -04:00
|
|
|
"""IDLE Configuration Dialog: support user customization of IDLE by GUI
|
|
|
|
|
|
|
|
Customize font faces, sizes, and colorization attributes. Set indentation
|
|
|
|
defaults. Customize keybindings. Colorization and keybindings can be
|
|
|
|
saved as user defined sets. Select startup options including shell/editor
|
|
|
|
and default window size. Define additional help sources.
|
|
|
|
|
|
|
|
Note that tab width in IDLE is currently fixed at eight due to Tk issues.
|
2005-01-30 23:34:26 -04:00
|
|
|
Refer to comments in EditorWindow autoindent code for details.
|
2003-01-10 16:13:57 -04:00
|
|
|
|
2001-07-31 03:59:02 -03:00
|
|
|
"""
|
|
|
|
from Tkinter import *
|
2001-08-11 12:48:13 -03:00
|
|
|
import tkMessageBox, tkColorChooser, tkFont
|
2002-02-10 22:20:53 -04:00
|
|
|
import string, copy
|
2001-07-31 03:59:02 -03:00
|
|
|
|
2001-09-24 06:43:17 -03:00
|
|
|
from configHandler import idleConf
|
2001-10-26 03:47:09 -03:00
|
|
|
from dynOptionMenuWidget import DynOptionMenu
|
2001-12-05 03:54:07 -04:00
|
|
|
from tabpage import TabPageSet
|
2002-01-18 20:29:54 -04:00
|
|
|
from keybindingDialog import GetKeysDialog
|
2002-01-24 02:02:50 -04:00
|
|
|
from configSectionNameDialog import GetCfgSectionNameDialog
|
2002-02-05 00:52:32 -04:00
|
|
|
from configHelpSourceEdit import GetHelpSourceDialog
|
2003-01-10 16:13:57 -04:00
|
|
|
|
2001-07-31 03:59:02 -03:00
|
|
|
class ConfigDialog(Toplevel):
|
2005-01-30 23:34:26 -04:00
|
|
|
|
2001-11-21 01:56:26 -04:00
|
|
|
def __init__(self,parent,title):
|
2001-07-31 07:46:53 -03:00
|
|
|
Toplevel.__init__(self, parent)
|
|
|
|
self.configure(borderwidth=5)
|
|
|
|
self.geometry("+%d+%d" % (parent.winfo_rootx()+20,
|
|
|
|
parent.winfo_rooty()+30))
|
2005-07-22 18:49:32 -03:00
|
|
|
#Theme Elements. Each theme element key is its display name.
|
2001-11-03 10:54:25 -04:00
|
|
|
#The first value of the tuple is the sample area tag name.
|
2002-12-31 12:03:23 -04:00
|
|
|
#The second value is the display name list sort index.
|
2002-01-03 08:05:17 -04:00
|
|
|
self.themeElements={'Normal Text':('normal','00'),
|
|
|
|
'Python Keywords':('keyword','01'),
|
|
|
|
'Python Definitions':('definition','02'),
|
2004-03-08 14:15:31 -04:00
|
|
|
'Python Builtins':('builtin', '03'),
|
|
|
|
'Python Comments':('comment','04'),
|
|
|
|
'Python Strings':('string','05'),
|
|
|
|
'Selected Text':('hilite','06'),
|
|
|
|
'Found Text':('hit','07'),
|
|
|
|
'Cursor':('cursor','08'),
|
|
|
|
'Error Text':('error','09'),
|
|
|
|
'Shell Normal Text':('console','10'),
|
|
|
|
'Shell Stdout Text':('stdout','11'),
|
|
|
|
'Shell Stderr Text':('stderr','12'),
|
|
|
|
}
|
2002-01-31 21:33:36 -04:00
|
|
|
self.ResetChangedItems() #load initial values in changed items dict
|
2001-07-31 07:46:53 -03:00
|
|
|
self.CreateWidgets()
|
|
|
|
self.resizable(height=FALSE,width=FALSE)
|
|
|
|
self.transient(parent)
|
|
|
|
self.grab_set()
|
|
|
|
self.protocol("WM_DELETE_WINDOW", self.Cancel)
|
|
|
|
self.parent = parent
|
2001-12-05 03:54:07 -04:00
|
|
|
self.tabPages.focus_set()
|
2001-07-31 07:46:53 -03:00
|
|
|
#key bindings for this dialog
|
2002-01-21 02:38:21 -04:00
|
|
|
#self.bind('<Escape>',self.Cancel) #dismiss dialog, no save
|
|
|
|
#self.bind('<Alt-a>',self.Apply) #apply changes, save
|
|
|
|
#self.bind('<F1>',self.Help) #context help
|
2001-10-23 07:42:12 -03:00
|
|
|
self.LoadConfigs()
|
2002-12-31 12:03:23 -04:00
|
|
|
self.AttachVarCallbacks() #avoid callbacks during LoadConfigs
|
2001-07-31 07:46:53 -03:00
|
|
|
self.wait_window()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-07-31 07:46:53 -03:00
|
|
|
def CreateWidgets(self):
|
2001-12-05 03:54:07 -04:00
|
|
|
self.tabPages = TabPageSet(self,
|
|
|
|
pageNames=['Fonts/Tabs','Highlighting','Keys','General'])
|
2002-01-03 08:05:17 -04:00
|
|
|
self.tabPages.ChangePage()#activates default (first) page
|
2001-07-31 07:46:53 -03:00
|
|
|
frameActionButtons = Frame(self)
|
|
|
|
#action buttons
|
2001-08-03 01:43:44 -03:00
|
|
|
self.buttonHelp = Button(frameActionButtons,text='Help',
|
|
|
|
command=self.Help,takefocus=FALSE)
|
2001-08-11 12:48:13 -03:00
|
|
|
self.buttonOk = Button(frameActionButtons,text='Ok',
|
|
|
|
command=self.Ok,takefocus=FALSE)
|
|
|
|
self.buttonApply = Button(frameActionButtons,text='Apply',
|
2002-01-21 02:38:21 -04:00
|
|
|
command=self.Apply,takefocus=FALSE)
|
2001-07-31 07:46:53 -03:00
|
|
|
self.buttonCancel = Button(frameActionButtons,text='Cancel',
|
|
|
|
command=self.Cancel,takefocus=FALSE)
|
2001-12-05 03:54:07 -04:00
|
|
|
self.CreatePageFontTab()
|
|
|
|
self.CreatePageHighlight()
|
|
|
|
self.CreatePageKeys()
|
|
|
|
self.CreatePageGeneral()
|
2001-08-11 12:48:13 -03:00
|
|
|
self.buttonHelp.pack(side=RIGHT,padx=5,pady=5)
|
|
|
|
self.buttonOk.pack(side=LEFT,padx=5,pady=5)
|
|
|
|
self.buttonApply.pack(side=LEFT,padx=5,pady=5)
|
2001-07-31 07:46:53 -03:00
|
|
|
self.buttonCancel.pack(side=LEFT,padx=5,pady=5)
|
|
|
|
frameActionButtons.pack(side=BOTTOM)
|
2001-12-05 03:54:07 -04:00
|
|
|
self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-08-04 10:58:22 -03:00
|
|
|
def CreatePageFontTab(self):
|
2001-08-05 05:00:28 -03:00
|
|
|
#tkVars
|
2001-11-21 01:56:26 -04:00
|
|
|
self.fontSize=StringVar(self)
|
2002-01-22 01:56:40 -04:00
|
|
|
self.fontBold=BooleanVar(self)
|
|
|
|
self.fontName=StringVar(self)
|
2001-11-21 01:56:26 -04:00
|
|
|
self.spaceNum=IntVar(self)
|
2003-05-26 17:35:53 -03:00
|
|
|
self.editFont=tkFont.Font(self,('courier',10,'normal'))
|
2001-08-05 05:00:28 -03:00
|
|
|
##widget creation
|
|
|
|
#body frame
|
2001-12-05 03:54:07 -04:00
|
|
|
frame=self.tabPages.pages['Fonts/Tabs']['page']
|
2001-08-05 05:00:28 -03:00
|
|
|
#body section frames
|
|
|
|
frameFont=Frame(frame,borderwidth=2,relief=GROOVE)
|
|
|
|
frameIndent=Frame(frame,borderwidth=2,relief=GROOVE)
|
|
|
|
#frameFont
|
|
|
|
labelFontTitle=Label(frameFont,text='Set Base Editor Font')
|
|
|
|
frameFontName=Frame(frameFont)
|
2001-11-03 01:07:28 -04:00
|
|
|
frameFontParam=Frame(frameFont)
|
2001-08-05 05:00:28 -03:00
|
|
|
labelFontNameTitle=Label(frameFontName,justify=LEFT,
|
2001-08-11 12:48:13 -03:00
|
|
|
text='Font :')
|
|
|
|
self.listFontName=Listbox(frameFontName,height=5,takefocus=FALSE,
|
|
|
|
exportselection=FALSE)
|
2002-01-22 01:56:40 -04:00
|
|
|
self.listFontName.bind('<ButtonRelease-1>',self.OnListFontButtonRelease)
|
2001-08-11 12:48:13 -03:00
|
|
|
scrollFont=Scrollbar(frameFontName)
|
|
|
|
scrollFont.config(command=self.listFontName.yview)
|
|
|
|
self.listFontName.config(yscrollcommand=scrollFont.set)
|
2001-11-03 01:07:28 -04:00
|
|
|
labelFontSizeTitle=Label(frameFontParam,text='Size :')
|
|
|
|
self.optMenuFontSize=DynOptionMenu(frameFontParam,self.fontSize,None,
|
2002-01-22 01:56:40 -04:00
|
|
|
command=self.SetFontSample)
|
2001-11-03 01:07:28 -04:00
|
|
|
checkFontBold=Checkbutton(frameFontParam,variable=self.fontBold,
|
2002-01-22 01:56:40 -04:00
|
|
|
onvalue=1,offvalue=0,text='Bold',command=self.SetFontSample)
|
2001-09-24 06:43:17 -03:00
|
|
|
frameFontSample=Frame(frameFont,relief=SOLID,borderwidth=1)
|
|
|
|
self.labelFontSample=Label(frameFontSample,
|
|
|
|
text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]',
|
2001-10-23 07:42:12 -03:00
|
|
|
justify=LEFT,font=self.editFont)
|
2001-08-05 05:00:28 -03:00
|
|
|
#frameIndent
|
|
|
|
frameIndentSize=Frame(frameIndent)
|
2005-01-30 23:34:26 -04:00
|
|
|
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)
|
2001-08-05 05:00:28 -03:00
|
|
|
#widget packing
|
|
|
|
#body
|
2001-08-11 12:48:13 -03:00
|
|
|
frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH)
|
|
|
|
frameIndent.pack(side=LEFT,padx=5,pady=10,fill=Y)
|
2001-08-05 05:00:28 -03:00
|
|
|
#frameFont
|
|
|
|
labelFontTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
2001-11-03 01:07:28 -04:00
|
|
|
frameFontName.pack(side=TOP,padx=5,pady=5,fill=X)
|
|
|
|
frameFontParam.pack(side=TOP,padx=5,pady=5,fill=X)
|
2001-08-05 05:00:28 -03:00
|
|
|
labelFontNameTitle.pack(side=TOP,anchor=W)
|
2001-11-03 01:07:28 -04:00
|
|
|
self.listFontName.pack(side=LEFT,expand=TRUE,fill=X)
|
2001-08-11 12:48:13 -03:00
|
|
|
scrollFont.pack(side=LEFT,fill=Y)
|
2001-11-03 01:07:28 -04:00
|
|
|
labelFontSizeTitle.pack(side=LEFT,anchor=W)
|
|
|
|
self.optMenuFontSize.pack(side=LEFT,anchor=W)
|
|
|
|
checkFontBold.pack(side=LEFT,anchor=W,padx=20)
|
2001-08-05 05:00:28 -03:00
|
|
|
frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
|
2001-08-11 12:48:13 -03:00
|
|
|
self.labelFontSample.pack(expand=TRUE,fill=BOTH)
|
2001-08-05 05:00:28 -03:00
|
|
|
#frameIndent
|
|
|
|
frameIndentSize.pack(side=TOP,padx=5,pady=5,fill=BOTH)
|
|
|
|
labelSpaceNumTitle.pack(side=TOP,anchor=W,padx=5)
|
|
|
|
self.scaleSpaceNum.pack(side=TOP,padx=5,fill=X)
|
2001-08-03 01:43:44 -03:00
|
|
|
return frame
|
|
|
|
|
|
|
|
def CreatePageHighlight(self):
|
2001-11-21 01:56:26 -04:00
|
|
|
self.builtinTheme=StringVar(self)
|
|
|
|
self.customTheme=StringVar(self)
|
2002-01-22 01:56:40 -04:00
|
|
|
self.fgHilite=BooleanVar(self)
|
2001-11-21 01:56:26 -04:00
|
|
|
self.colour=StringVar(self)
|
|
|
|
self.fontName=StringVar(self)
|
2002-12-31 12:03:23 -04:00
|
|
|
self.themeIsBuiltin=BooleanVar(self)
|
2001-11-21 01:56:26 -04:00
|
|
|
self.highlightTarget=StringVar(self)
|
2001-08-03 01:43:44 -03:00
|
|
|
##widget creation
|
|
|
|
#body frame
|
2001-12-05 03:54:07 -04:00
|
|
|
frame=self.tabPages.pages['Highlighting']['page']
|
2001-08-03 01:43:44 -03:00
|
|
|
#body section frames
|
|
|
|
frameCustom=Frame(frame,borderwidth=2,relief=GROOVE)
|
|
|
|
frameTheme=Frame(frame,borderwidth=2,relief=GROOVE)
|
|
|
|
#frameCustom
|
2001-11-03 01:07:28 -04:00
|
|
|
self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1,
|
2002-03-02 03:16:21 -04:00
|
|
|
font=('courier',12,''),cursor='hand2',width=21,height=10,
|
|
|
|
takefocus=FALSE,highlightthickness=0,wrap=NONE)
|
2001-11-03 01:07:28 -04:00
|
|
|
text=self.textHighlightSample
|
|
|
|
text.bind('<Double-Button-1>',lambda e: 'break')
|
|
|
|
text.bind('<B1-Motion>',lambda e: 'break')
|
2002-02-10 22:20:53 -04:00
|
|
|
textAndTags=(('#you can click here','comment'),('\n','normal'),
|
2001-11-03 10:54:25 -04:00
|
|
|
('#to choose items','comment'),('\n','normal'),('def','keyword'),
|
|
|
|
(' ','normal'),('func','definition'),('(param):','normal'),
|
|
|
|
('\n ','normal'),('"""string"""','string'),('\n var0 = ','normal'),
|
2001-11-04 07:53:10 -04:00
|
|
|
("'string'",'string'),('\n var1 = ','normal'),("'selected'",'hilite'),
|
2004-03-08 14:15:31 -04:00
|
|
|
('\n var2 = ','normal'),("'found'",'hit'),
|
|
|
|
('\n var3 = ','normal'),('list', 'builtin'), ('(','normal'),
|
|
|
|
('None', 'builtin'),(')\n\n','normal'),
|
2001-11-04 03:03:08 -04:00
|
|
|
(' error ','error'),(' ','normal'),('cursor |','cursor'),
|
2001-11-04 07:53:10 -04:00
|
|
|
('\n ','normal'),('shell','console'),(' ','normal'),('stdout','stdout'),
|
|
|
|
(' ','normal'),('stderr','stderr'),('\n','normal'))
|
2001-11-03 10:54:25 -04:00
|
|
|
for txTa in textAndTags:
|
|
|
|
text.insert(END,txTa[0],txTa[1])
|
2002-12-31 12:03:23 -04:00
|
|
|
for element in self.themeElements.keys():
|
2001-11-03 10:54:25 -04:00
|
|
|
text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>',
|
|
|
|
lambda event,elem=element: event.widget.winfo_toplevel()
|
|
|
|
.highlightTarget.set(elem))
|
2001-11-03 01:07:28 -04:00
|
|
|
text.config(state=DISABLED)
|
|
|
|
self.frameColourSet=Frame(frameCustom,relief=SOLID,borderwidth=1)
|
2001-10-29 07:19:46 -04:00
|
|
|
frameFgBg=Frame(frameCustom)
|
2001-08-03 01:43:44 -03:00
|
|
|
labelCustomTitle=Label(frameCustom,text='Set Custom Highlighting')
|
2001-11-03 01:07:28 -04:00
|
|
|
buttonSetColour=Button(self.frameColourSet,text='Choose Colour for :',
|
2001-11-03 10:54:25 -04:00
|
|
|
command=self.GetColour,highlightthickness=0)
|
2001-11-03 01:07:28 -04:00
|
|
|
self.optMenuHighlightTarget=DynOptionMenu(self.frameColourSet,
|
2001-11-03 10:54:25 -04:00
|
|
|
self.highlightTarget,None,highlightthickness=0)#,command=self.SetHighlightTargetBinding
|
2001-10-29 07:19:46 -04:00
|
|
|
self.radioFg=Radiobutton(frameFgBg,variable=self.fgHilite,
|
2001-11-21 01:56:26 -04:00
|
|
|
value=1,text='Foreground',command=self.SetColourSampleBinding)
|
2001-10-29 07:19:46 -04:00
|
|
|
self.radioBg=Radiobutton(frameFgBg,variable=self.fgHilite,
|
2001-11-21 01:56:26 -04:00
|
|
|
value=0,text='Background',command=self.SetColourSampleBinding)
|
2001-10-29 07:19:46 -04:00
|
|
|
self.fgHilite.set(1)
|
2002-12-31 12:03:23 -04:00
|
|
|
buttonSaveCustomTheme=Button(frameCustom,
|
2002-02-05 00:52:32 -04:00
|
|
|
text='Save as New Custom Theme',command=self.SaveAsNewTheme)
|
2001-08-03 01:43:44 -03:00
|
|
|
#frameTheme
|
|
|
|
labelThemeTitle=Label(frameTheme,text='Select a Highlighting Theme')
|
|
|
|
labelTypeTitle=Label(frameTheme,text='Select : ')
|
2001-11-04 07:53:10 -04:00
|
|
|
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')
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuThemeBuiltin=DynOptionMenu(frameTheme,
|
2001-10-29 07:19:46 -04:00
|
|
|
self.builtinTheme,None,command=None)
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuThemeCustom=DynOptionMenu(frameTheme,
|
2001-10-29 07:19:46 -04:00
|
|
|
self.customTheme,None,command=None)
|
2002-02-17 21:43:11 -04:00
|
|
|
self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme',
|
|
|
|
command=self.DeleteCustomTheme)
|
2001-08-03 01:43:44 -03:00
|
|
|
##widget packing
|
|
|
|
#body
|
2001-08-04 10:58:22 -03:00
|
|
|
frameCustom.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH)
|
|
|
|
frameTheme.pack(side=LEFT,padx=5,pady=10,fill=Y)
|
2001-08-03 01:43:44 -03:00
|
|
|
#frameCustom
|
|
|
|
labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
2001-11-03 01:07:28 -04:00
|
|
|
self.frameColourSet.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=X)
|
2001-10-29 07:19:46 -04:00
|
|
|
frameFgBg.pack(side=TOP,padx=5,pady=0)
|
2001-11-03 01:07:28 -04:00
|
|
|
self.textHighlightSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,
|
|
|
|
fill=BOTH)
|
2001-11-03 10:54:25 -04:00
|
|
|
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)
|
2001-10-29 07:19:46 -04:00
|
|
|
self.radioFg.pack(side=LEFT,anchor=E)
|
|
|
|
self.radioBg.pack(side=RIGHT,anchor=W)
|
2002-12-31 12:03:23 -04:00
|
|
|
buttonSaveCustomTheme.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
2001-08-03 01:43:44 -03:00
|
|
|
#frameTheme
|
|
|
|
labelThemeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
|
|
|
labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
2001-10-29 04:05:34 -04:00
|
|
|
self.radioThemeBuiltin.pack(side=TOP,anchor=W,padx=5)
|
|
|
|
self.radioThemeCustom.pack(side=TOP,anchor=W,padx=5,pady=2)
|
2001-08-03 01:43:44 -03:00
|
|
|
self.optMenuThemeBuiltin.pack(side=TOP,fill=X,padx=5,pady=5)
|
|
|
|
self.optMenuThemeCustom.pack(side=TOP,fill=X,anchor=W,padx=5,pady=5)
|
2001-08-04 10:58:22 -03:00
|
|
|
self.buttonDeleteCustomTheme.pack(side=TOP,fill=X,padx=5,pady=5)
|
2001-08-03 01:43:44 -03:00
|
|
|
return frame
|
|
|
|
|
|
|
|
def CreatePageKeys(self):
|
2001-08-04 10:58:22 -03:00
|
|
|
#tkVars
|
2001-11-21 01:56:26 -04:00
|
|
|
self.bindingTarget=StringVar(self)
|
|
|
|
self.builtinKeys=StringVar(self)
|
|
|
|
self.customKeys=StringVar(self)
|
2002-12-31 12:03:23 -04:00
|
|
|
self.keysAreBuiltin=BooleanVar(self)
|
2002-01-22 01:56:40 -04:00
|
|
|
self.keyBinding=StringVar(self)
|
2001-08-04 10:58:22 -03:00
|
|
|
##widget creation
|
|
|
|
#body frame
|
2001-12-05 03:54:07 -04:00
|
|
|
frame=self.tabPages.pages['Keys']['page']
|
2001-08-04 10:58:22 -03:00
|
|
|
#body section frames
|
|
|
|
frameCustom=Frame(frame,borderwidth=2,relief=GROOVE)
|
|
|
|
frameKeySets=Frame(frame,borderwidth=2,relief=GROOVE)
|
|
|
|
#frameCustom
|
|
|
|
frameTarget=Frame(frameCustom)
|
|
|
|
labelCustomTitle=Label(frameCustom,text='Set Custom Key Bindings')
|
2002-01-18 20:29:54 -04:00
|
|
|
labelTargetTitle=Label(frameTarget,text='Action - Key(s)')
|
|
|
|
scrollTargetY=Scrollbar(frameTarget)
|
|
|
|
scrollTargetX=Scrollbar(frameTarget,orient=HORIZONTAL)
|
2002-02-05 00:52:32 -04:00
|
|
|
self.listBindings=Listbox(frameTarget,takefocus=FALSE,
|
|
|
|
exportselection=FALSE)
|
2002-01-21 02:38:21 -04:00
|
|
|
self.listBindings.bind('<ButtonRelease-1>',self.KeyBindingSelected)
|
2002-01-18 20:29:54 -04:00
|
|
|
scrollTargetY.config(command=self.listBindings.yview)
|
|
|
|
scrollTargetX.config(command=self.listBindings.xview)
|
|
|
|
self.listBindings.config(yscrollcommand=scrollTargetY.set)
|
|
|
|
self.listBindings.config(xscrollcommand=scrollTargetX.set)
|
2002-01-21 02:38:21 -04:00
|
|
|
self.buttonNewKeys=Button(frameCustom,text='Get New Keys for Selection',
|
|
|
|
command=self.GetNewKeys,state=DISABLED)
|
2002-02-05 00:52:32 -04:00
|
|
|
buttonSaveCustomKeys=Button(frameCustom,
|
|
|
|
text='Save as New Custom Key Set',command=self.SaveAsNewKeySet)
|
2001-08-04 10:58:22 -03:00
|
|
|
#frameKeySets
|
2001-08-05 05:00:28 -03:00
|
|
|
labelKeysTitle=Label(frameKeySets,text='Select a Key Set')
|
2001-08-04 10:58:22 -03:00
|
|
|
labelTypeTitle=Label(frameKeySets,text='Select : ')
|
2002-02-10 22:20:53 -04:00
|
|
|
self.radioKeysBuiltin=Radiobutton(frameKeySets,variable=self.keysAreBuiltin,
|
2001-11-04 07:53:10 -04:00
|
|
|
value=1,command=self.SetKeysType,text='a Built-in Key Set')
|
2002-02-10 22:20:53 -04:00
|
|
|
self.radioKeysCustom=Radiobutton(frameKeySets,variable=self.keysAreBuiltin,
|
2001-11-04 07:53:10 -04:00
|
|
|
value=0,command=self.SetKeysType,text='a Custom Key Set')
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuKeysBuiltin=DynOptionMenu(frameKeySets,
|
|
|
|
self.builtinKeys,None,command=None)
|
|
|
|
self.optMenuKeysCustom=DynOptionMenu(frameKeySets,
|
|
|
|
self.customKeys,None,command=None)
|
2002-02-17 21:43:11 -04:00
|
|
|
self.buttonDeleteCustomKeys=Button(frameKeySets,text='Delete Custom Key Set',
|
|
|
|
command=self.DeleteCustomKeys)
|
2001-08-04 10:58:22 -03:00
|
|
|
##widget packing
|
|
|
|
#body
|
|
|
|
frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
|
|
|
|
frameKeySets.pack(side=LEFT,padx=5,pady=5,fill=Y)
|
|
|
|
#frameCustom
|
|
|
|
labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
2002-12-31 12:03:23 -04:00
|
|
|
buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
|
|
|
self.buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
2002-01-18 20:29:54 -04:00
|
|
|
frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
|
|
|
|
#frame target
|
|
|
|
frameTarget.columnconfigure(0,weight=1)
|
|
|
|
frameTarget.rowconfigure(1,weight=1)
|
|
|
|
labelTargetTitle.grid(row=0,column=0,columnspan=2,sticky=W)
|
|
|
|
self.listBindings.grid(row=1,column=0,sticky=NSEW)
|
|
|
|
scrollTargetY.grid(row=1,column=1,sticky=NS)
|
|
|
|
scrollTargetX.grid(row=2,column=0,sticky=EW)
|
2001-08-04 10:58:22 -03:00
|
|
|
#frameKeySets
|
|
|
|
labelKeysTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
|
|
|
labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
2001-10-29 04:05:34 -04:00
|
|
|
self.radioKeysBuiltin.pack(side=TOP,anchor=W,padx=5)
|
|
|
|
self.radioKeysCustom.pack(side=TOP,anchor=W,padx=5,pady=2)
|
2001-08-04 10:58:22 -03:00
|
|
|
self.optMenuKeysBuiltin.pack(side=TOP,fill=X,padx=5,pady=5)
|
|
|
|
self.optMenuKeysCustom.pack(side=TOP,fill=X,anchor=W,padx=5,pady=5)
|
|
|
|
self.buttonDeleteCustomKeys.pack(side=TOP,fill=X,padx=5,pady=5)
|
2001-08-03 01:43:44 -03:00
|
|
|
return frame
|
|
|
|
|
|
|
|
def CreatePageGeneral(self):
|
2002-12-31 12:03:23 -04:00
|
|
|
#tkVars
|
|
|
|
self.winWidth=StringVar(self)
|
2001-11-21 01:56:26 -04:00
|
|
|
self.winHeight=StringVar(self)
|
2004-06-04 03:31:08 -03:00
|
|
|
self.paraWidth=StringVar(self)
|
2002-12-31 12:03:23 -04:00
|
|
|
self.startupEdit=IntVar(self)
|
2003-05-26 03:23:10 -03:00
|
|
|
self.autoSave=IntVar(self)
|
2003-05-09 21:49:56 -03:00
|
|
|
self.encoding=StringVar(self)
|
2002-02-05 00:52:32 -04:00
|
|
|
self.userHelpBrowser=BooleanVar(self)
|
|
|
|
self.helpBrowser=StringVar(self)
|
2001-08-07 00:28:25 -03:00
|
|
|
#widget creation
|
|
|
|
#body
|
2001-12-05 03:54:07 -04:00
|
|
|
frame=self.tabPages.pages['General']['page']
|
2002-12-31 12:03:23 -04:00
|
|
|
#body section frames
|
2001-08-07 00:28:25 -03:00
|
|
|
frameRun=Frame(frame,borderwidth=2,relief=GROOVE)
|
2003-05-26 03:23:10 -03:00
|
|
|
frameSave=Frame(frame,borderwidth=2,relief=GROOVE)
|
2001-08-07 00:28:25 -03:00
|
|
|
frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
|
2004-06-04 03:31:08 -03:00
|
|
|
frameParaSize=Frame(frame,borderwidth=2,relief=GROOVE)
|
2003-05-09 21:49:56 -03:00
|
|
|
frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE)
|
2002-02-05 00:52:32 -04:00
|
|
|
frameHelp=Frame(frame,borderwidth=2,relief=GROOVE)
|
2001-08-07 00:28:25 -03:00
|
|
|
#frameRun
|
2002-01-21 02:38:21 -04:00
|
|
|
labelRunTitle=Label(frameRun,text='Startup Preferences')
|
2003-05-26 03:23:10 -03:00
|
|
|
labelRunChoiceTitle=Label(frameRun,text='At Startup')
|
2002-01-21 02:38:21 -04:00
|
|
|
radioStartupEdit=Radiobutton(frameRun,variable=self.startupEdit,
|
2003-01-10 16:13:57 -04:00
|
|
|
value=1,command=self.SetKeysType,text="Open Edit Window")
|
2002-01-21 02:38:21 -04:00
|
|
|
radioStartupShell=Radiobutton(frameRun,variable=self.startupEdit,
|
2003-01-10 16:13:57 -04:00
|
|
|
value=0,command=self.SetKeysType,text='Open Shell Window')
|
2003-05-26 03:23:10 -03:00
|
|
|
#frameSave
|
|
|
|
labelSaveTitle=Label(frameSave,text='Autosave Preference')
|
|
|
|
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')
|
2001-08-07 00:28:25 -03:00
|
|
|
#frameWinSize
|
2002-01-21 02:38:21 -04:00
|
|
|
labelWinSizeTitle=Label(frameWinSize,text='Initial Window Size'+
|
|
|
|
' (in characters)')
|
2001-08-07 00:28:25 -03:00
|
|
|
labelWinWidthTitle=Label(frameWinSize,text='Width')
|
|
|
|
entryWinWidth=Entry(frameWinSize,textvariable=self.winWidth,
|
|
|
|
width=3)
|
|
|
|
labelWinHeightTitle=Label(frameWinSize,text='Height')
|
|
|
|
entryWinHeight=Entry(frameWinSize,textvariable=self.winHeight,
|
|
|
|
width=3)
|
2004-06-04 03:31:08 -03:00
|
|
|
#paragraphFormatWidth
|
|
|
|
labelParaWidthTitle=Label(frameParaSize,text='Paragraph reformat'+
|
|
|
|
' width (in characters)')
|
|
|
|
entryParaWidth=Entry(frameParaSize,textvariable=self.paraWidth,
|
|
|
|
width=3)
|
2003-05-09 21:49:56 -03:00
|
|
|
#frameEncoding
|
|
|
|
labelEncodingTitle=Label(frameEncoding,text="Default Source Encoding")
|
|
|
|
radioEncLocale=Radiobutton(frameEncoding,variable=self.encoding,
|
|
|
|
value="locale",text="Locale-defined")
|
|
|
|
radioEncUTF8=Radiobutton(frameEncoding,variable=self.encoding,
|
|
|
|
value="utf-8",text="UTF-8")
|
|
|
|
radioEncNone=Radiobutton(frameEncoding,variable=self.encoding,
|
|
|
|
value="none",text="None")
|
2002-02-05 00:52:32 -04:00
|
|
|
#frameHelp
|
|
|
|
frameHelpList=Frame(frameHelp)
|
|
|
|
frameHelpListButtons=Frame(frameHelpList)
|
2003-01-10 16:13:57 -04:00
|
|
|
labelHelpListTitle=Label(frameHelpList,text='Additional Help Sources:')
|
2002-02-05 00:52:32 -04:00
|
|
|
scrollHelpList=Scrollbar(frameHelpList)
|
|
|
|
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',
|
|
|
|
width=8,command=self.HelpListItemAdd)
|
|
|
|
self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove',
|
|
|
|
state=DISABLED,width=8,command=self.HelpListItemRemove)
|
2001-08-07 00:28:25 -03:00
|
|
|
#widget packing
|
|
|
|
#body
|
|
|
|
frameRun.pack(side=TOP,padx=5,pady=5,fill=X)
|
2003-05-26 03:23:10 -03:00
|
|
|
frameSave.pack(side=TOP,padx=5,pady=5,fill=X)
|
2001-08-07 00:28:25 -03:00
|
|
|
frameWinSize.pack(side=TOP,padx=5,pady=5,fill=X)
|
2004-06-04 03:31:08 -03:00
|
|
|
frameParaSize.pack(side=TOP,padx=5,pady=5,fill=X)
|
2003-05-26 03:23:10 -03:00
|
|
|
frameEncoding.pack(side=TOP,padx=5,pady=5,fill=X)
|
2002-02-05 00:52:32 -04:00
|
|
|
frameHelp.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
|
2001-08-07 00:28:25 -03:00
|
|
|
#frameRun
|
|
|
|
labelRunTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
|
|
|
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
2003-05-26 03:23:10 -03:00
|
|
|
radioStartupShell.pack(side=RIGHT,anchor=W,padx=5,pady=5)
|
|
|
|
radioStartupEdit.pack(side=RIGHT,anchor=W,padx=5,pady=5)
|
|
|
|
#frameSave
|
|
|
|
labelSaveTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
|
|
|
labelRunSaveTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
|
|
|
radioSaveAuto.pack(side=RIGHT,anchor=W,padx=5,pady=5)
|
|
|
|
radioSaveAsk.pack(side=RIGHT,anchor=W,padx=5,pady=5)
|
2001-08-07 00:28:25 -03:00
|
|
|
#frameWinSize
|
2002-01-18 20:29:54 -04:00
|
|
|
labelWinSizeTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
|
|
|
entryWinHeight.pack(side=RIGHT,anchor=E,padx=10,pady=5)
|
|
|
|
labelWinHeightTitle.pack(side=RIGHT,anchor=E,pady=5)
|
|
|
|
entryWinWidth.pack(side=RIGHT,anchor=E,padx=10,pady=5)
|
|
|
|
labelWinWidthTitle.pack(side=RIGHT,anchor=E,pady=5)
|
2004-06-04 03:31:08 -03:00
|
|
|
#paragraphFormatWidth
|
|
|
|
labelParaWidthTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
|
|
|
entryParaWidth.pack(side=RIGHT,anchor=E,padx=10,pady=5)
|
2003-05-09 21:49:56 -03:00
|
|
|
#frameEncoding
|
|
|
|
labelEncodingTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
|
|
|
radioEncNone.pack(side=RIGHT,anchor=E,pady=5)
|
|
|
|
radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5)
|
|
|
|
radioEncLocale.pack(side=RIGHT,anchor=E,pady=5)
|
2002-02-05 00:52:32 -04:00
|
|
|
#frameHelp
|
|
|
|
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)
|
|
|
|
scrollHelpList.pack(side=RIGHT,anchor=W,fill=Y)
|
|
|
|
self.listHelp.pack(side=LEFT,anchor=E,expand=TRUE,fill=BOTH)
|
|
|
|
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)
|
2001-08-03 01:43:44 -03:00
|
|
|
return frame
|
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def AttachVarCallbacks(self):
|
|
|
|
self.fontSize.trace_variable('w',self.VarChanged_fontSize)
|
|
|
|
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.colour.trace_variable('w',self.VarChanged_colour)
|
2002-02-10 22:20:53 -04:00
|
|
|
self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme)
|
|
|
|
self.customTheme.trace_variable('w',self.VarChanged_customTheme)
|
2002-12-31 12:03:23 -04:00
|
|
|
self.themeIsBuiltin.trace_variable('w',self.VarChanged_themeIsBuiltin)
|
2002-02-10 22:20:53 -04:00
|
|
|
self.highlightTarget.trace_variable('w',self.VarChanged_highlightTarget)
|
2002-01-22 01:56:40 -04:00
|
|
|
self.keyBinding.trace_variable('w',self.VarChanged_keyBinding)
|
2002-02-10 22:20:53 -04:00
|
|
|
self.builtinKeys.trace_variable('w',self.VarChanged_builtinKeys)
|
|
|
|
self.customKeys.trace_variable('w',self.VarChanged_customKeys)
|
2002-12-31 12:03:23 -04:00
|
|
|
self.keysAreBuiltin.trace_variable('w',self.VarChanged_keysAreBuiltin)
|
2002-01-22 01:56:40 -04:00
|
|
|
self.winWidth.trace_variable('w',self.VarChanged_winWidth)
|
|
|
|
self.winHeight.trace_variable('w',self.VarChanged_winHeight)
|
2004-06-04 03:31:08 -03:00
|
|
|
self.paraWidth.trace_variable('w',self.VarChanged_paraWidth)
|
2002-01-22 01:56:40 -04:00
|
|
|
self.startupEdit.trace_variable('w',self.VarChanged_startupEdit)
|
2003-05-26 03:23:10 -03:00
|
|
|
self.autoSave.trace_variable('w',self.VarChanged_autoSave)
|
2003-05-09 21:49:56 -03:00
|
|
|
self.encoding.trace_variable('w',self.VarChanged_encoding)
|
2002-02-10 22:20:53 -04:00
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def VarChanged_fontSize(self,*params):
|
|
|
|
value=self.fontSize.get()
|
|
|
|
self.AddChangedItem('main','EditorWindow','font-size',value)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def VarChanged_fontName(self,*params):
|
|
|
|
value=self.fontName.get()
|
|
|
|
self.AddChangedItem('main','EditorWindow','font',value)
|
|
|
|
|
|
|
|
def VarChanged_fontBold(self,*params):
|
|
|
|
value=self.fontBold.get()
|
|
|
|
self.AddChangedItem('main','EditorWindow','font-bold',value)
|
|
|
|
|
|
|
|
def VarChanged_spaceNum(self,*params):
|
|
|
|
value=self.spaceNum.get()
|
|
|
|
self.AddChangedItem('main','Indent','num-spaces',value)
|
|
|
|
|
|
|
|
def VarChanged_colour(self,*params):
|
2002-02-10 22:20:53 -04:00
|
|
|
self.OnNewColourSet()
|
|
|
|
|
|
|
|
def VarChanged_builtinTheme(self,*params):
|
|
|
|
value=self.builtinTheme.get()
|
|
|
|
self.AddChangedItem('main','Theme','name',value)
|
|
|
|
self.PaintThemeSample()
|
|
|
|
|
|
|
|
def VarChanged_customTheme(self,*params):
|
|
|
|
value=self.customTheme.get()
|
2002-02-17 21:43:11 -04:00
|
|
|
if value != '- no custom themes -':
|
|
|
|
self.AddChangedItem('main','Theme','name',value)
|
|
|
|
self.PaintThemeSample()
|
2002-02-10 22:20:53 -04:00
|
|
|
|
|
|
|
def VarChanged_themeIsBuiltin(self,*params):
|
|
|
|
value=self.themeIsBuiltin.get()
|
|
|
|
self.AddChangedItem('main','Theme','default',value)
|
2002-03-04 20:25:58 -04:00
|
|
|
if value:
|
|
|
|
self.VarChanged_builtinTheme()
|
|
|
|
else:
|
|
|
|
self.VarChanged_customTheme()
|
2002-02-10 22:20:53 -04:00
|
|
|
|
|
|
|
def VarChanged_highlightTarget(self,*params):
|
|
|
|
self.SetHighlightTarget()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def VarChanged_keyBinding(self,*params):
|
2002-01-22 07:35:50 -04:00
|
|
|
value=self.keyBinding.get()
|
|
|
|
keySet=self.customKeys.get()
|
|
|
|
event=self.listBindings.get(ANCHOR).split()[0]
|
2002-01-31 21:33:36 -04:00
|
|
|
if idleConf.IsCoreBinding(event):
|
|
|
|
#this is a core keybinding
|
|
|
|
self.AddChangedItem('keys',keySet,event,value)
|
|
|
|
else: #this is an extension key binding
|
|
|
|
extName=idleConf.GetExtnNameForEvent(event)
|
|
|
|
extKeybindSection=extName+'_cfgBindings'
|
|
|
|
self.AddChangedItem('extensions',extKeybindSection,event,value)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-10 22:20:53 -04:00
|
|
|
def VarChanged_builtinKeys(self,*params):
|
|
|
|
value=self.builtinKeys.get()
|
|
|
|
self.AddChangedItem('main','Keys','name',value)
|
|
|
|
self.LoadKeysList(value)
|
|
|
|
|
|
|
|
def VarChanged_customKeys(self,*params):
|
|
|
|
value=self.customKeys.get()
|
2002-02-17 21:43:11 -04:00
|
|
|
if value != '- no custom keys -':
|
|
|
|
self.AddChangedItem('main','Keys','name',value)
|
|
|
|
self.LoadKeysList(value)
|
2002-02-10 22:20:53 -04:00
|
|
|
|
|
|
|
def VarChanged_keysAreBuiltin(self,*params):
|
2002-12-31 12:03:23 -04:00
|
|
|
value=self.keysAreBuiltin.get()
|
2002-02-10 22:20:53 -04:00
|
|
|
self.AddChangedItem('main','Keys','default',value)
|
2002-12-31 12:03:23 -04:00
|
|
|
if value:
|
2002-03-04 20:25:58 -04:00
|
|
|
self.VarChanged_builtinKeys()
|
2002-02-10 22:20:53 -04:00
|
|
|
else:
|
2002-03-04 20:25:58 -04:00
|
|
|
self.VarChanged_customKeys()
|
2002-02-10 22:20:53 -04:00
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def VarChanged_winWidth(self,*params):
|
2002-01-22 07:35:50 -04:00
|
|
|
value=self.winWidth.get()
|
|
|
|
self.AddChangedItem('main','EditorWindow','width',value)
|
2002-01-22 01:56:40 -04:00
|
|
|
|
|
|
|
def VarChanged_winHeight(self,*params):
|
2002-01-22 07:35:50 -04:00
|
|
|
value=self.winHeight.get()
|
|
|
|
self.AddChangedItem('main','EditorWindow','height',value)
|
2002-01-22 01:56:40 -04:00
|
|
|
|
2004-06-04 03:31:08 -03:00
|
|
|
def VarChanged_paraWidth(self,*params):
|
|
|
|
value=self.paraWidth.get()
|
|
|
|
self.AddChangedItem('main','FormatParagraph','paragraph',value)
|
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def VarChanged_startupEdit(self,*params):
|
2002-01-22 07:35:50 -04:00
|
|
|
value=self.startupEdit.get()
|
|
|
|
self.AddChangedItem('main','General','editor-on-startup',value)
|
2002-01-22 01:56:40 -04:00
|
|
|
|
2003-05-26 03:23:10 -03:00
|
|
|
def VarChanged_autoSave(self,*params):
|
|
|
|
value=self.autoSave.get()
|
|
|
|
self.AddChangedItem('main','General','autosave',value)
|
|
|
|
|
2003-05-09 21:49:56 -03:00
|
|
|
def VarChanged_encoding(self,*params):
|
|
|
|
value=self.encoding.get()
|
|
|
|
self.AddChangedItem('main','EditorWindow','encoding',value)
|
|
|
|
|
2002-01-31 21:33:36 -04:00
|
|
|
def ResetChangedItems(self):
|
2002-03-02 03:16:21 -04:00
|
|
|
#When any config item is changed in this dialog, an entry
|
2002-12-31 12:03:23 -04:00
|
|
|
#should be made in the relevant section (config type) of this
|
|
|
|
#dictionary. The key should be the config file section name and the
|
2002-01-31 21:33:36 -04:00
|
|
|
#value a dictionary, whose key:value pairs are item=value pairs for
|
|
|
|
#that config file section.
|
|
|
|
self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
|
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def AddChangedItem(self,type,section,item,value):
|
2002-01-29 04:35:29 -04:00
|
|
|
value=str(value) #make sure we use a string
|
2002-01-22 01:56:40 -04:00
|
|
|
if not self.changedItems[type].has_key(section):
|
2002-12-31 12:03:23 -04:00
|
|
|
self.changedItems[type][section]={}
|
2002-01-22 01:56:40 -04:00
|
|
|
self.changedItems[type][section][item]=value
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-21 02:38:21 -04:00
|
|
|
def GetDefaultItems(self):
|
|
|
|
dItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
|
|
|
|
for configType in dItems.keys():
|
|
|
|
sections=idleConf.GetSectionList('default',configType)
|
|
|
|
for section in sections:
|
|
|
|
dItems[configType][section]={}
|
|
|
|
options=idleConf.defaultCfg[configType].GetOptionList(section)
|
2002-12-31 12:03:23 -04:00
|
|
|
for option in options:
|
2002-01-21 02:38:21 -04:00
|
|
|
dItems[configType][section][option]=(
|
|
|
|
idleConf.defaultCfg[configType].Get(section,option))
|
|
|
|
return dItems
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-21 02:38:21 -04:00
|
|
|
def SetThemeType(self):
|
|
|
|
if self.themeIsBuiltin.get():
|
|
|
|
self.optMenuThemeBuiltin.config(state=NORMAL)
|
|
|
|
self.optMenuThemeCustom.config(state=DISABLED)
|
|
|
|
self.buttonDeleteCustomTheme.config(state=DISABLED)
|
|
|
|
else:
|
|
|
|
self.optMenuThemeBuiltin.config(state=DISABLED)
|
2002-01-24 02:02:50 -04:00
|
|
|
self.radioThemeCustom.config(state=NORMAL)
|
2002-01-21 02:38:21 -04:00
|
|
|
self.optMenuThemeCustom.config(state=NORMAL)
|
|
|
|
self.buttonDeleteCustomTheme.config(state=NORMAL)
|
|
|
|
|
|
|
|
def SetKeysType(self):
|
2002-02-10 22:20:53 -04:00
|
|
|
if self.keysAreBuiltin.get():
|
2002-01-21 02:38:21 -04:00
|
|
|
self.optMenuKeysBuiltin.config(state=NORMAL)
|
|
|
|
self.optMenuKeysCustom.config(state=DISABLED)
|
|
|
|
self.buttonDeleteCustomKeys.config(state=DISABLED)
|
|
|
|
else:
|
|
|
|
self.optMenuKeysBuiltin.config(state=DISABLED)
|
2002-01-24 02:02:50 -04:00
|
|
|
self.radioKeysCustom.config(state=NORMAL)
|
2002-01-21 02:38:21 -04:00
|
|
|
self.optMenuKeysCustom.config(state=NORMAL)
|
|
|
|
self.buttonDeleteCustomKeys.config(state=NORMAL)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-24 02:02:50 -04:00
|
|
|
def GetNewKeys(self):
|
|
|
|
listIndex=self.listBindings.index(ANCHOR)
|
|
|
|
binding=self.listBindings.get(listIndex)
|
|
|
|
bindName=binding.split()[0] #first part, up to first space
|
2002-12-31 12:03:23 -04:00
|
|
|
if self.keysAreBuiltin.get():
|
2002-02-10 23:45:22 -04:00
|
|
|
currentKeySetName=self.builtinKeys.get()
|
2002-12-31 12:03:23 -04:00
|
|
|
else:
|
2002-02-10 23:45:22 -04:00
|
|
|
currentKeySetName=self.customKeys.get()
|
|
|
|
currentBindings=idleConf.GetCurrentKeySet()
|
|
|
|
if currentKeySetName in self.changedItems['keys'].keys(): #unsaved changes
|
|
|
|
keySetChanges=self.changedItems['keys'][currentKeySetName]
|
|
|
|
for event in keySetChanges.keys():
|
|
|
|
currentBindings[event]=keySetChanges[event].split()
|
|
|
|
currentKeySequences=currentBindings.values()
|
2002-02-05 00:52:32 -04:00
|
|
|
newKeys=GetKeysDialog(self,'Get New Keys',bindName,
|
|
|
|
currentKeySequences).result
|
|
|
|
if newKeys: #new keys were specified
|
2002-02-10 22:20:53 -04:00
|
|
|
if self.keysAreBuiltin.get(): #current key set is a built-in
|
2002-01-24 02:02:50 -04:00
|
|
|
message=('Your changes will be saved as a new Custom Key Set. '+
|
|
|
|
'Enter a name for your new Custom Key Set below.')
|
2002-02-05 00:52:32 -04:00
|
|
|
newKeySet=self.GetNewKeysName(message)
|
|
|
|
if not newKeySet: #user cancelled custom key set creation
|
2002-01-24 02:02:50 -04:00
|
|
|
self.listBindings.select_set(listIndex)
|
|
|
|
self.listBindings.select_anchor(listIndex)
|
|
|
|
return
|
2002-12-31 12:03:23 -04:00
|
|
|
else: #create new custom key set based on previously active key set
|
|
|
|
self.CreateNewKeySet(newKeySet)
|
2002-01-24 02:02:50 -04:00
|
|
|
self.listBindings.delete(listIndex)
|
2002-02-05 00:52:32 -04:00
|
|
|
self.listBindings.insert(listIndex,bindName+' - '+newKeys)
|
2002-01-24 02:02:50 -04:00
|
|
|
self.listBindings.select_set(listIndex)
|
|
|
|
self.listBindings.select_anchor(listIndex)
|
2002-02-10 22:20:53 -04:00
|
|
|
self.keyBinding.set(newKeys)
|
2002-01-24 02:02:50 -04:00
|
|
|
else:
|
|
|
|
self.listBindings.select_set(listIndex)
|
|
|
|
self.listBindings.select_anchor(listIndex)
|
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def GetNewKeysName(self,message):
|
2002-02-17 21:43:11 -04:00
|
|
|
usedNames=(idleConf.GetSectionList('user','keys')+
|
|
|
|
idleConf.GetSectionList('default','keys'))
|
2002-02-05 00:52:32 -04:00
|
|
|
newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set',
|
|
|
|
message,usedNames).result
|
|
|
|
return newKeySet
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def SaveAsNewKeySet(self):
|
|
|
|
newKeysName=self.GetNewKeysName('New Key Set Name:')
|
|
|
|
if newKeysName:
|
|
|
|
self.CreateNewKeySet(newKeysName)
|
|
|
|
|
2002-01-24 02:02:50 -04:00
|
|
|
def KeyBindingSelected(self,event):
|
|
|
|
self.buttonNewKeys.config(state=NORMAL)
|
|
|
|
|
|
|
|
def CreateNewKeySet(self,newKeySetName):
|
|
|
|
#creates new custom key set based on the previously active key set,
|
|
|
|
#and makes the new key set active
|
2002-12-31 12:03:23 -04:00
|
|
|
if self.keysAreBuiltin.get():
|
2002-02-10 22:20:53 -04:00
|
|
|
prevKeySetName=self.builtinKeys.get()
|
2002-12-31 12:03:23 -04:00
|
|
|
else:
|
2002-02-10 22:20:53 -04:00
|
|
|
prevKeySetName=self.customKeys.get()
|
|
|
|
prevKeys=idleConf.GetCoreKeys(prevKeySetName)
|
|
|
|
newKeys={}
|
|
|
|
for event in prevKeys.keys(): #add key set to changed items
|
2002-01-24 02:02:50 -04:00
|
|
|
eventName=event[2:-2] #trim off the angle brackets
|
2002-02-10 22:20:53 -04:00
|
|
|
binding=string.join(prevKeys[event])
|
|
|
|
newKeys[eventName]=binding
|
|
|
|
#handle any unsaved changes to prev key set
|
|
|
|
if prevKeySetName in self.changedItems['keys'].keys():
|
|
|
|
keySetChanges=self.changedItems['keys'][prevKeySetName]
|
|
|
|
for event in keySetChanges.keys():
|
|
|
|
newKeys[event]=keySetChanges[event]
|
|
|
|
#save the new theme
|
|
|
|
self.SaveNewKeySet(newKeySetName,newKeys)
|
2002-01-24 02:02:50 -04:00
|
|
|
#change gui over to the new key set
|
|
|
|
customKeyList=idleConf.GetSectionList('user','keys')
|
|
|
|
customKeyList.sort()
|
|
|
|
self.optMenuKeysCustom.SetMenu(customKeyList,newKeySetName)
|
2002-02-10 22:20:53 -04:00
|
|
|
self.keysAreBuiltin.set(0)
|
2002-01-24 02:02:50 -04:00
|
|
|
self.SetKeysType()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-10 22:20:53 -04:00
|
|
|
def LoadKeysList(self,keySetName):
|
|
|
|
reselect=0
|
|
|
|
newKeySet=0
|
|
|
|
if self.listBindings.curselection():
|
|
|
|
reselect=1
|
|
|
|
listIndex=self.listBindings.index(ANCHOR)
|
|
|
|
keySet=idleConf.GetKeySet(keySetName)
|
|
|
|
bindNames=keySet.keys()
|
|
|
|
bindNames.sort()
|
|
|
|
self.listBindings.delete(0,END)
|
2002-12-31 12:03:23 -04:00
|
|
|
for bindName in bindNames:
|
2002-02-10 22:20:53 -04:00
|
|
|
key=string.join(keySet[bindName]) #make key(s) into a string
|
|
|
|
bindName=bindName[2:-2] #trim off the angle brackets
|
|
|
|
if keySetName in self.changedItems['keys'].keys():
|
|
|
|
#handle any unsaved changes to this key set
|
|
|
|
if bindName in self.changedItems['keys'][keySetName].keys():
|
|
|
|
key=self.changedItems['keys'][keySetName][bindName]
|
|
|
|
self.listBindings.insert(END, bindName+' - '+key)
|
|
|
|
if reselect:
|
|
|
|
self.listBindings.see(listIndex)
|
|
|
|
self.listBindings.select_set(listIndex)
|
|
|
|
self.listBindings.select_anchor(listIndex)
|
|
|
|
|
2002-02-17 21:43:11 -04:00
|
|
|
def DeleteCustomKeys(self):
|
|
|
|
keySetName=self.customKeys.get()
|
|
|
|
if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+
|
2004-02-12 13:35:32 -04:00
|
|
|
'to delete the key set %r ?' % (keySetName),
|
2003-01-14 18:03:31 -04:00
|
|
|
parent=self):
|
2002-02-17 21:43:11 -04:00
|
|
|
return
|
|
|
|
#remove key set from config
|
|
|
|
idleConf.userCfg['keys'].remove_section(keySetName)
|
|
|
|
if self.changedItems['keys'].has_key(keySetName):
|
|
|
|
del(self.changedItems['keys'][keySetName])
|
|
|
|
#write changes
|
|
|
|
idleConf.userCfg['keys'].Save()
|
|
|
|
#reload user key set list
|
|
|
|
itemList=idleConf.GetSectionList('user','keys')
|
|
|
|
itemList.sort()
|
|
|
|
if not itemList:
|
|
|
|
self.radioKeysCustom.config(state=DISABLED)
|
|
|
|
self.optMenuKeysCustom.SetMenu(itemList,'- no custom keys -')
|
|
|
|
else:
|
|
|
|
self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
|
|
|
|
#revert to default key set
|
|
|
|
self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys','default'))
|
|
|
|
self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys','name'))
|
|
|
|
#user can't back out of these changes, they must be applied now
|
|
|
|
self.Apply()
|
|
|
|
self.SetKeysType()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-17 21:43:11 -04:00
|
|
|
def DeleteCustomTheme(self):
|
|
|
|
themeName=self.customTheme.get()
|
|
|
|
if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
|
2004-02-12 13:35:32 -04:00
|
|
|
'to delete the theme %r ?' % (themeName,),
|
2003-01-14 18:03:31 -04:00
|
|
|
parent=self):
|
2002-02-17 21:43:11 -04:00
|
|
|
return
|
|
|
|
#remove theme from config
|
|
|
|
idleConf.userCfg['highlight'].remove_section(themeName)
|
|
|
|
if self.changedItems['highlight'].has_key(themeName):
|
|
|
|
del(self.changedItems['highlight'][themeName])
|
|
|
|
#write changes
|
|
|
|
idleConf.userCfg['highlight'].Save()
|
|
|
|
#reload user theme list
|
|
|
|
itemList=idleConf.GetSectionList('user','highlight')
|
|
|
|
itemList.sort()
|
|
|
|
if not itemList:
|
|
|
|
self.radioThemeCustom.config(state=DISABLED)
|
|
|
|
self.optMenuThemeCustom.SetMenu(itemList,'- no custom themes -')
|
|
|
|
else:
|
|
|
|
self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
|
|
|
|
#revert to default theme
|
|
|
|
self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme','default'))
|
|
|
|
self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme','name'))
|
|
|
|
#user can't back out of these changes, they must be applied now
|
|
|
|
self.Apply()
|
|
|
|
self.SetThemeType()
|
|
|
|
|
2002-01-21 02:38:21 -04:00
|
|
|
def GetColour(self):
|
|
|
|
target=self.highlightTarget.get()
|
2002-02-10 22:20:53 -04:00
|
|
|
prevColour=self.frameColourSet.cget('bg')
|
2002-01-21 02:38:21 -04:00
|
|
|
rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
|
2002-02-10 22:20:53 -04:00
|
|
|
title='Pick new colour for : '+target,initialcolor=prevColour)
|
2002-12-31 12:03:23 -04:00
|
|
|
if colourString and (colourString!=prevColour):
|
2002-02-10 22:20:53 -04:00
|
|
|
#user didn't cancel, and they chose a new colour
|
2002-01-24 02:02:50 -04:00
|
|
|
if self.themeIsBuiltin.get(): #current theme is a built-in
|
|
|
|
message=('Your changes will be saved as a new Custom Theme. '+
|
|
|
|
'Enter a name for your new Custom Theme below.')
|
2002-02-05 00:52:32 -04:00
|
|
|
newTheme=self.GetNewThemeName(message)
|
|
|
|
if not newTheme: #user cancelled custom theme creation
|
2002-01-24 02:02:50 -04:00
|
|
|
return
|
2002-12-31 12:03:23 -04:00
|
|
|
else: #create new custom theme based on previously active theme
|
|
|
|
self.CreateNewTheme(newTheme)
|
2002-02-10 22:20:53 -04:00
|
|
|
self.colour.set(colourString)
|
|
|
|
else: #current theme is user defined
|
|
|
|
self.colour.set(colourString)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-10 22:20:53 -04:00
|
|
|
def OnNewColourSet(self):
|
|
|
|
newColour=self.colour.get()
|
|
|
|
self.frameColourSet.config(bg=newColour)#set sample
|
|
|
|
if self.fgHilite.get(): plane='foreground'
|
|
|
|
else: plane='background'
|
|
|
|
sampleElement=self.themeElements[self.highlightTarget.get()][0]
|
2003-07-09 15:48:24 -03:00
|
|
|
self.textHighlightSample.tag_config(sampleElement, **{plane:newColour})
|
2002-02-10 22:20:53 -04:00
|
|
|
theme=self.customTheme.get()
|
|
|
|
themeElement=sampleElement+'-'+plane
|
|
|
|
self.AddChangedItem('highlight',theme,themeElement,newColour)
|
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def GetNewThemeName(self,message):
|
2002-02-17 21:43:11 -04:00
|
|
|
usedNames=(idleConf.GetSectionList('user','highlight')+
|
|
|
|
idleConf.GetSectionList('default','highlight'))
|
2002-02-05 00:52:32 -04:00
|
|
|
newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
|
|
|
|
message,usedNames).result
|
|
|
|
return newTheme
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def SaveAsNewTheme(self):
|
|
|
|
newThemeName=self.GetNewThemeName('New Theme Name:')
|
|
|
|
if newThemeName:
|
|
|
|
self.CreateNewTheme(newThemeName)
|
|
|
|
|
2002-01-24 02:02:50 -04:00
|
|
|
def CreateNewTheme(self,newThemeName):
|
|
|
|
#creates new custom theme based on the previously active theme,
|
|
|
|
#and makes the new theme active
|
2002-12-31 12:03:23 -04:00
|
|
|
if self.themeIsBuiltin.get():
|
2002-01-24 02:02:50 -04:00
|
|
|
themeType='default'
|
|
|
|
themeName=self.builtinTheme.get()
|
2002-12-31 12:03:23 -04:00
|
|
|
else:
|
2002-01-24 02:02:50 -04:00
|
|
|
themeType='user'
|
|
|
|
themeName=self.customTheme.get()
|
|
|
|
newTheme=idleConf.GetThemeDict(themeType,themeName)
|
2002-02-10 22:20:53 -04:00
|
|
|
#apply any of the old theme's unsaved changes to the new theme
|
|
|
|
if themeName in self.changedItems['highlight'].keys():
|
|
|
|
themeChanges=self.changedItems['highlight'][themeName]
|
|
|
|
for element in themeChanges.keys():
|
|
|
|
newTheme[element]=themeChanges[element]
|
|
|
|
#save the new theme
|
|
|
|
self.SaveNewTheme(newThemeName,newTheme)
|
2002-01-24 02:02:50 -04:00
|
|
|
#change gui over to the new theme
|
|
|
|
customThemeList=idleConf.GetSectionList('user','highlight')
|
|
|
|
customThemeList.sort()
|
|
|
|
self.optMenuThemeCustom.SetMenu(customThemeList,newThemeName)
|
|
|
|
self.themeIsBuiltin.set(0)
|
|
|
|
self.SetThemeType()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def OnListFontButtonRelease(self,event):
|
2003-05-26 17:35:53 -03:00
|
|
|
font = self.listFontName.get(ANCHOR)
|
|
|
|
self.fontName.set(font.lower())
|
2002-01-21 02:38:21 -04:00
|
|
|
self.SetFontSample()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-22 01:56:40 -04:00
|
|
|
def SetFontSample(self,event=None):
|
|
|
|
fontName=self.fontName.get()
|
2002-12-31 12:03:23 -04:00
|
|
|
if self.fontBold.get():
|
2002-01-22 01:56:40 -04:00
|
|
|
fontWeight=tkFont.BOLD
|
2002-12-31 12:03:23 -04:00
|
|
|
else:
|
2002-01-22 01:56:40 -04:00
|
|
|
fontWeight=tkFont.NORMAL
|
|
|
|
self.editFont.config(size=self.fontSize.get(),
|
|
|
|
weight=fontWeight,family=fontName)
|
2002-01-21 02:38:21 -04:00
|
|
|
|
|
|
|
def SetHighlightTarget(self):
|
|
|
|
if self.highlightTarget.get()=='Cursor': #bg not possible
|
|
|
|
self.radioFg.config(state=DISABLED)
|
|
|
|
self.radioBg.config(state=DISABLED)
|
|
|
|
self.fgHilite.set(1)
|
|
|
|
else: #both fg and bg can be set
|
|
|
|
self.radioFg.config(state=NORMAL)
|
|
|
|
self.radioBg.config(state=NORMAL)
|
|
|
|
self.fgHilite.set(1)
|
|
|
|
self.SetColourSample()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-21 02:38:21 -04:00
|
|
|
def SetColourSampleBinding(self,*args):
|
|
|
|
self.SetColourSample()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-21 02:38:21 -04:00
|
|
|
def SetColourSample(self):
|
|
|
|
#set the colour smaple area
|
|
|
|
tag=self.themeElements[self.highlightTarget.get()][0]
|
|
|
|
if self.fgHilite.get(): plane='foreground'
|
|
|
|
else: plane='background'
|
|
|
|
colour=self.textHighlightSample.tag_cget(tag,plane)
|
|
|
|
self.frameColourSet.config(bg=colour)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-11-03 10:54:25 -04:00
|
|
|
def PaintThemeSample(self):
|
2001-11-04 07:53:10 -04:00
|
|
|
if self.themeIsBuiltin.get(): #a default theme
|
2001-11-04 03:03:08 -04:00
|
|
|
theme=self.builtinTheme.get()
|
|
|
|
else: #a user theme
|
|
|
|
theme=self.customTheme.get()
|
2002-02-10 22:20:53 -04:00
|
|
|
for elementTitle in self.themeElements.keys():
|
|
|
|
element=self.themeElements[elementTitle][0]
|
|
|
|
colours=idleConf.GetHighlight(theme,element)
|
|
|
|
if element=='cursor': #cursor sample needs special painting
|
2002-12-31 12:03:23 -04:00
|
|
|
colours['background']=idleConf.GetHighlight(theme,
|
2002-01-04 03:53:06 -04:00
|
|
|
'normal', fgBg='bg')
|
2002-02-10 22:20:53 -04:00
|
|
|
#handle any unsaved changes to this theme
|
|
|
|
if theme in self.changedItems['highlight'].keys():
|
|
|
|
themeDict=self.changedItems['highlight'][theme]
|
|
|
|
if themeDict.has_key(element+'-foreground'):
|
|
|
|
colours['foreground']=themeDict[element+'-foreground']
|
|
|
|
if themeDict.has_key(element+'-background'):
|
|
|
|
colours['background']=themeDict[element+'-background']
|
2003-07-09 15:48:24 -03:00
|
|
|
self.textHighlightSample.tag_config(element, **colours)
|
2002-02-10 22:20:53 -04:00
|
|
|
self.SetColourSample()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def HelpSourceSelected(self,event):
|
|
|
|
self.SetHelpListButtonStates()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def SetHelpListButtonStates(self):
|
|
|
|
if self.listHelp.size()<1: #no entries in list
|
|
|
|
self.buttonHelpListEdit.config(state=DISABLED)
|
|
|
|
self.buttonHelpListRemove.config(state=DISABLED)
|
|
|
|
else: #there are some entries
|
|
|
|
if self.listHelp.curselection(): #there currently is a selection
|
|
|
|
self.buttonHelpListEdit.config(state=NORMAL)
|
|
|
|
self.buttonHelpListRemove.config(state=NORMAL)
|
|
|
|
else: #there currently is not a selection
|
|
|
|
self.buttonHelpListEdit.config(state=DISABLED)
|
|
|
|
self.buttonHelpListRemove.config(state=DISABLED)
|
|
|
|
|
|
|
|
def HelpListItemAdd(self):
|
|
|
|
helpSource=GetHelpSourceDialog(self,'New Help Source').result
|
|
|
|
if helpSource:
|
|
|
|
self.userHelpList.append( (helpSource[0],helpSource[1]) )
|
2003-01-14 18:03:31 -04:00
|
|
|
self.listHelp.insert(END,helpSource[0])
|
2002-02-05 00:52:32 -04:00
|
|
|
self.UpdateUserHelpChangedItems()
|
|
|
|
self.SetHelpListButtonStates()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def HelpListItemEdit(self):
|
|
|
|
itemIndex=self.listHelp.index(ANCHOR)
|
|
|
|
helpSource=self.userHelpList[itemIndex]
|
2002-03-26 22:25:44 -04:00
|
|
|
newHelpSource=GetHelpSourceDialog(self,'Edit Help Source',
|
2002-02-05 00:52:32 -04:00
|
|
|
menuItem=helpSource[0],filePath=helpSource[1]).result
|
|
|
|
if (not newHelpSource) or (newHelpSource==helpSource):
|
|
|
|
return #no changes
|
|
|
|
self.userHelpList[itemIndex]=newHelpSource
|
|
|
|
self.listHelp.delete(itemIndex)
|
2003-01-14 18:03:31 -04:00
|
|
|
self.listHelp.insert(itemIndex,newHelpSource[0])
|
2002-02-05 00:52:32 -04:00
|
|
|
self.UpdateUserHelpChangedItems()
|
|
|
|
self.SetHelpListButtonStates()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def HelpListItemRemove(self):
|
|
|
|
itemIndex=self.listHelp.index(ANCHOR)
|
|
|
|
del(self.userHelpList[itemIndex])
|
|
|
|
self.listHelp.delete(itemIndex)
|
|
|
|
self.UpdateUserHelpChangedItems()
|
|
|
|
self.SetHelpListButtonStates()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-05 00:52:32 -04:00
|
|
|
def UpdateUserHelpChangedItems(self):
|
2003-01-14 18:03:31 -04:00
|
|
|
"Clear and rebuild the HelpFiles section in self.changedItems"
|
|
|
|
self.changedItems['main']['HelpFiles'] = {}
|
2002-02-05 00:52:32 -04:00
|
|
|
for num in range(1,len(self.userHelpList)+1):
|
|
|
|
self.AddChangedItem('main','HelpFiles',str(num),
|
2003-01-14 18:03:31 -04:00
|
|
|
string.join(self.userHelpList[num-1][:2],';'))
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-10-23 07:42:12 -03:00
|
|
|
def LoadFontCfg(self):
|
|
|
|
##base editor font selection list
|
2001-09-24 06:43:17 -03:00
|
|
|
fonts=list(tkFont.families(self))
|
|
|
|
fonts.sort()
|
|
|
|
for font in fonts:
|
|
|
|
self.listFontName.insert(END,font)
|
2001-10-26 03:47:09 -03:00
|
|
|
configuredFont=idleConf.GetOption('main','EditorWindow','font',
|
2001-10-23 07:42:12 -03:00
|
|
|
default='courier')
|
2003-05-26 17:35:53 -03:00
|
|
|
lc_configuredFont = configuredFont.lower()
|
|
|
|
self.fontName.set(lc_configuredFont)
|
|
|
|
lc_fonts = [s.lower() for s in fonts]
|
|
|
|
if lc_configuredFont in lc_fonts:
|
|
|
|
currentFontIndex = lc_fonts.index(lc_configuredFont)
|
2001-10-23 07:42:12 -03:00
|
|
|
self.listFontName.see(currentFontIndex)
|
|
|
|
self.listFontName.select_set(currentFontIndex)
|
2002-01-22 01:56:40 -04:00
|
|
|
self.listFontName.select_anchor(currentFontIndex)
|
2001-10-23 07:42:12 -03:00
|
|
|
##font size dropdown
|
2002-01-22 01:56:40 -04:00
|
|
|
fontSize=idleConf.GetOption('main','EditorWindow','font-size',
|
2003-05-26 17:35:53 -03:00
|
|
|
default='10')
|
2002-11-03 23:17:45 -04:00
|
|
|
self.optMenuFontSize.SetMenu(('7','8','9','10','11','12','13','14',
|
2001-10-26 03:47:09 -03:00
|
|
|
'16','18','20','22'),fontSize )
|
2002-01-22 01:56:40 -04:00
|
|
|
##fontWeight
|
|
|
|
self.fontBold.set(idleConf.GetOption('main','EditorWindow',
|
|
|
|
'font-bold',default=0,type='bool'))
|
2002-12-31 12:03:23 -04:00
|
|
|
##font sample
|
2001-10-23 07:42:12 -03:00
|
|
|
self.SetFontSample()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-10-23 07:42:12 -03:00
|
|
|
def LoadTabCfg(self):
|
|
|
|
##indent sizes
|
2001-10-26 03:47:09 -03:00
|
|
|
spaceNum=idleConf.GetOption('main','Indent','num-spaces',
|
2001-10-23 07:42:12 -03:00
|
|
|
default=4,type='int')
|
|
|
|
self.spaceNum.set(spaceNum)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-11-03 10:54:25 -04:00
|
|
|
def LoadThemeCfg(self):
|
2001-10-29 04:05:34 -04:00
|
|
|
##current theme type radiobutton
|
2001-11-04 07:53:10 -04:00
|
|
|
self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default',
|
2002-01-22 01:56:40 -04:00
|
|
|
type='bool',default=1))
|
2001-10-29 04:05:34 -04:00
|
|
|
##currently set theme
|
2002-01-03 08:05:17 -04:00
|
|
|
currentOption=idleConf.CurrentTheme()
|
2001-10-29 07:19:46 -04:00
|
|
|
##load available theme option menus
|
2001-11-04 07:53:10 -04:00
|
|
|
if self.themeIsBuiltin.get(): #default theme selected
|
2001-10-29 04:05:34 -04:00
|
|
|
itemList=idleConf.GetSectionList('default','highlight')
|
2002-01-24 02:02:50 -04:00
|
|
|
itemList.sort()
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuThemeBuiltin.SetMenu(itemList,currentOption)
|
|
|
|
itemList=idleConf.GetSectionList('user','highlight')
|
2002-01-24 02:02:50 -04:00
|
|
|
itemList.sort()
|
2001-10-29 04:05:34 -04:00
|
|
|
if not itemList:
|
|
|
|
self.radioThemeCustom.config(state=DISABLED)
|
2002-12-31 12:03:23 -04:00
|
|
|
self.customTheme.set('- no custom themes -')
|
2001-10-29 04:05:34 -04:00
|
|
|
else:
|
|
|
|
self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
|
2001-11-03 10:54:25 -04:00
|
|
|
else: #user theme selected
|
2001-10-29 04:05:34 -04:00
|
|
|
itemList=idleConf.GetSectionList('user','highlight')
|
2002-01-24 02:02:50 -04:00
|
|
|
itemList.sort()
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuThemeCustom.SetMenu(itemList,currentOption)
|
|
|
|
itemList=idleConf.GetSectionList('default','highlight')
|
2002-01-24 02:02:50 -04:00
|
|
|
itemList.sort()
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuThemeBuiltin.SetMenu(itemList,itemList[0])
|
2001-10-29 07:19:46 -04:00
|
|
|
self.SetThemeType()
|
|
|
|
##load theme element option menu
|
2001-11-03 10:54:25 -04:00
|
|
|
themeNames=self.themeElements.keys()
|
|
|
|
themeNames.sort(self.__ThemeNameIndexCompare)
|
2002-12-31 12:03:23 -04:00
|
|
|
self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
|
2001-11-03 10:54:25 -04:00
|
|
|
self.PaintThemeSample()
|
2002-01-04 03:53:06 -04:00
|
|
|
self.SetHighlightTarget()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-11-03 10:54:25 -04:00
|
|
|
def __ThemeNameIndexCompare(self,a,b):
|
|
|
|
if self.themeElements[a][1]<self.themeElements[b][1]: return -1
|
|
|
|
elif self.themeElements[a][1]==self.themeElements[b][1]: return 0
|
|
|
|
else: return 1
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-11-03 10:54:25 -04:00
|
|
|
def LoadKeyCfg(self):
|
2001-10-29 04:05:34 -04:00
|
|
|
##current keys type radiobutton
|
2002-02-10 22:20:53 -04:00
|
|
|
self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default',
|
2002-01-22 01:56:40 -04:00
|
|
|
type='bool',default=1))
|
2001-10-29 04:05:34 -04:00
|
|
|
##currently set keys
|
2002-01-03 08:05:17 -04:00
|
|
|
currentOption=idleConf.CurrentKeys()
|
2001-10-29 07:19:46 -04:00
|
|
|
##load available keyset option menus
|
2002-02-10 22:20:53 -04:00
|
|
|
if self.keysAreBuiltin.get(): #default theme selected
|
2001-10-29 04:05:34 -04:00
|
|
|
itemList=idleConf.GetSectionList('default','keys')
|
2002-01-24 02:02:50 -04:00
|
|
|
itemList.sort()
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuKeysBuiltin.SetMenu(itemList,currentOption)
|
|
|
|
itemList=idleConf.GetSectionList('user','keys')
|
2002-01-24 02:02:50 -04:00
|
|
|
itemList.sort()
|
2001-10-29 04:05:34 -04:00
|
|
|
if not itemList:
|
2002-12-31 12:03:23 -04:00
|
|
|
self.radioKeysCustom.config(state=DISABLED)
|
|
|
|
self.customKeys.set('- no custom keys -')
|
2001-10-29 04:05:34 -04:00
|
|
|
else:
|
|
|
|
self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
|
2002-01-31 21:33:36 -04:00
|
|
|
else: #user key set selected
|
2001-10-29 04:05:34 -04:00
|
|
|
itemList=idleConf.GetSectionList('user','keys')
|
2002-01-24 02:02:50 -04:00
|
|
|
itemList.sort()
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuKeysCustom.SetMenu(itemList,currentOption)
|
|
|
|
itemList=idleConf.GetSectionList('default','keys')
|
2002-01-24 02:02:50 -04:00
|
|
|
itemList.sort()
|
2001-10-29 04:05:34 -04:00
|
|
|
self.optMenuKeysBuiltin.SetMenu(itemList,itemList[0])
|
2002-12-31 12:03:23 -04:00
|
|
|
self.SetKeysType()
|
2002-01-18 20:29:54 -04:00
|
|
|
##load keyset element list
|
2002-02-10 22:20:53 -04:00
|
|
|
keySetName=idleConf.CurrentKeys()
|
|
|
|
self.LoadKeysList(keySetName)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-18 20:29:54 -04:00
|
|
|
def LoadGeneralCfg(self):
|
2002-01-21 02:38:21 -04:00
|
|
|
#startup state
|
|
|
|
self.startupEdit.set(idleConf.GetOption('main','General',
|
|
|
|
'editor-on-startup',default=1,type='bool'))
|
2003-05-26 03:23:10 -03:00
|
|
|
#autosave state
|
|
|
|
self.autoSave.set(idleConf.GetOption('main', 'General', 'autosave',
|
|
|
|
default=0, type='bool'))
|
2002-01-18 20:29:54 -04:00
|
|
|
#initial window size
|
2002-12-31 12:03:23 -04:00
|
|
|
self.winWidth.set(idleConf.GetOption('main','EditorWindow','width'))
|
2002-01-18 20:29:54 -04:00
|
|
|
self.winHeight.set(idleConf.GetOption('main','EditorWindow','height'))
|
2004-06-04 03:31:08 -03:00
|
|
|
#initial paragraph reformat size
|
|
|
|
self.paraWidth.set(idleConf.GetOption('main','FormatParagraph','paragraph'))
|
2003-05-09 21:49:56 -03:00
|
|
|
# default source encoding
|
2003-05-26 03:23:10 -03:00
|
|
|
self.encoding.set(idleConf.GetOption('main', 'EditorWindow',
|
|
|
|
'encoding', default='none'))
|
2003-01-14 18:03:31 -04:00
|
|
|
# additional help sources
|
|
|
|
self.userHelpList = idleConf.GetAllExtraHelpSourcesList()
|
2002-02-05 00:52:32 -04:00
|
|
|
for helpItem in self.userHelpList:
|
2003-01-14 18:03:31 -04:00
|
|
|
self.listHelp.insert(END,helpItem[0])
|
2002-02-05 00:52:32 -04:00
|
|
|
self.SetHelpListButtonStates()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2001-10-23 07:42:12 -03:00
|
|
|
def LoadConfigs(self):
|
|
|
|
"""
|
|
|
|
load configuration from default and user config files and populate
|
|
|
|
the widgets on the config dialog pages.
|
|
|
|
"""
|
|
|
|
### fonts / tabs page
|
2002-12-31 12:03:23 -04:00
|
|
|
self.LoadFontCfg()
|
|
|
|
self.LoadTabCfg()
|
2001-10-23 07:42:12 -03:00
|
|
|
### highlighting page
|
2001-11-03 10:54:25 -04:00
|
|
|
self.LoadThemeCfg()
|
2001-10-23 07:42:12 -03:00
|
|
|
### keys page
|
2001-11-03 10:54:25 -04:00
|
|
|
self.LoadKeyCfg()
|
2001-10-23 07:42:12 -03:00
|
|
|
### general page
|
2002-01-18 20:29:54 -04:00
|
|
|
self.LoadGeneralCfg()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-10 22:20:53 -04:00
|
|
|
def SaveNewKeySet(self,keySetName,keySet):
|
|
|
|
"""
|
|
|
|
save a newly created core key set.
|
|
|
|
keySetName - string, the name of the new key set
|
|
|
|
keySet - dictionary containing the new key set
|
|
|
|
"""
|
|
|
|
if not idleConf.userCfg['keys'].has_section(keySetName):
|
|
|
|
idleConf.userCfg['keys'].add_section(keySetName)
|
|
|
|
for event in keySet.keys():
|
|
|
|
value=keySet[event]
|
|
|
|
idleConf.userCfg['keys'].SetOption(keySetName,event,value)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-10 22:20:53 -04:00
|
|
|
def SaveNewTheme(self,themeName,theme):
|
|
|
|
"""
|
|
|
|
save a newly created theme.
|
|
|
|
themeName - string, the name of the new theme
|
|
|
|
theme - dictionary containing the new theme
|
|
|
|
"""
|
|
|
|
if not idleConf.userCfg['highlight'].has_section(themeName):
|
|
|
|
idleConf.userCfg['highlight'].add_section(themeName)
|
|
|
|
for element in theme.keys():
|
|
|
|
value=theme[element]
|
|
|
|
idleConf.userCfg['highlight'].SetOption(themeName,element,value)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-29 04:35:29 -04:00
|
|
|
def SetUserValue(self,configType,section,item,value):
|
|
|
|
if idleConf.defaultCfg[configType].has_option(section,item):
|
|
|
|
if idleConf.defaultCfg[configType].Get(section,item)==value:
|
|
|
|
#the setting equals a default setting, remove it from user cfg
|
|
|
|
return idleConf.userCfg[configType].RemoveOption(section,item)
|
|
|
|
#if we got here set the option
|
|
|
|
return idleConf.userCfg[configType].SetOption(section,item,value)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-02-10 22:20:53 -04:00
|
|
|
def SaveAllChangedConfigs(self):
|
2003-01-10 16:13:57 -04:00
|
|
|
"Save configuration changes to the user config file."
|
2002-03-26 22:25:44 -04:00
|
|
|
idleConf.userCfg['main'].Save()
|
2002-01-21 02:38:21 -04:00
|
|
|
for configType in self.changedItems.keys():
|
2003-01-10 16:13:57 -04:00
|
|
|
cfgTypeHasChanges = False
|
2002-01-21 02:38:21 -04:00
|
|
|
for section in self.changedItems[configType].keys():
|
2003-01-10 16:13:57 -04:00
|
|
|
if section == 'HelpFiles':
|
|
|
|
#this section gets completely replaced
|
|
|
|
idleConf.userCfg['main'].remove_section('HelpFiles')
|
2003-01-14 18:03:31 -04:00
|
|
|
cfgTypeHasChanges = True
|
2002-01-21 02:38:21 -04:00
|
|
|
for item in self.changedItems[configType][section].keys():
|
2003-01-10 16:13:57 -04:00
|
|
|
value = self.changedItems[configType][section][item]
|
2002-01-29 04:35:29 -04:00
|
|
|
if self.SetUserValue(configType,section,item,value):
|
2003-01-10 16:13:57 -04:00
|
|
|
cfgTypeHasChanges = True
|
2002-12-31 12:03:23 -04:00
|
|
|
if cfgTypeHasChanges:
|
|
|
|
idleConf.userCfg[configType].Save()
|
2004-11-16 17:28:36 -04:00
|
|
|
for configType in ['keys', 'highlight']:
|
|
|
|
# save these even if unchanged!
|
|
|
|
idleConf.userCfg[configType].Save()
|
2002-01-31 21:33:36 -04:00
|
|
|
self.ResetChangedItems() #clear the changed items dict
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2005-11-18 18:05:48 -04:00
|
|
|
def DeactivateCurrentConfig(self):
|
|
|
|
#Before a config is saved, some cleanup of current
|
|
|
|
#config must be done - remove the previous keybindings
|
|
|
|
winInstances=self.parent.instance_dict.keys()
|
|
|
|
for instance in winInstances:
|
|
|
|
instance.RemoveKeybindings()
|
|
|
|
|
2002-02-17 21:43:11 -04:00
|
|
|
def ActivateConfigChanges(self):
|
2005-01-30 23:34:26 -04:00
|
|
|
"Dynamically apply configuration changes"
|
2004-04-11 00:16:07 -03:00
|
|
|
winInstances=self.parent.instance_dict.keys()
|
2002-03-02 03:16:21 -04:00
|
|
|
for instance in winInstances:
|
|
|
|
instance.ResetColorizer()
|
2002-03-11 20:21:56 -04:00
|
|
|
instance.ResetFont()
|
2005-01-30 23:34:26 -04:00
|
|
|
instance.set_notabs_indentwidth()
|
2005-11-18 18:05:48 -04:00
|
|
|
instance.ApplyKeybindings()
|
2003-01-14 18:03:31 -04:00
|
|
|
instance.reset_help_menu_entries()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-01-21 02:38:21 -04:00
|
|
|
def Cancel(self):
|
|
|
|
self.destroy()
|
|
|
|
|
|
|
|
def Ok(self):
|
|
|
|
self.Apply()
|
|
|
|
self.destroy()
|
|
|
|
|
|
|
|
def Apply(self):
|
2005-11-18 18:05:48 -04:00
|
|
|
self.DeactivateCurrentConfig()
|
2002-02-10 22:20:53 -04:00
|
|
|
self.SaveAllChangedConfigs()
|
2002-02-17 21:43:11 -04:00
|
|
|
self.ActivateConfigChanges()
|
2002-01-21 02:38:21 -04:00
|
|
|
|
|
|
|
def Help(self):
|
2001-09-24 06:43:17 -03:00
|
|
|
pass
|
|
|
|
|
2001-07-31 03:59:02 -03:00
|
|
|
if __name__ == '__main__':
|
2001-07-31 07:46:53 -03:00
|
|
|
#test the dialog
|
|
|
|
root=Tk()
|
|
|
|
Button(root,text='Dialog',
|
2001-11-21 01:56:26 -04:00
|
|
|
command=lambda:ConfigDialog(root,'Settings')).pack()
|
2004-04-11 00:16:07 -03:00
|
|
|
root.instance_dict={}
|
2001-07-31 07:46:53 -03:00
|
|
|
root.mainloop()
|