Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 1 | """IDLE Configuration Dialog: support user customization of IDLE by GUI |
| 2 | |
| 3 | Customize font faces, sizes, and colorization attributes. Set indentation |
| 4 | defaults. Customize keybindings. Colorization and keybindings can be |
| 5 | saved as user defined sets. Select startup options including shell/editor |
| 6 | and default window size. Define additional help sources. |
| 7 | |
| 8 | Note that tab width in IDLE is currently fixed at eight due to Tk issues. |
| 9 | Refer to comment in EditorWindow autoindent code for details. |
| 10 | |
Steven M. Gava | 44d3d1a | 2001-07-31 06:59:02 +0000 | [diff] [blame] | 11 | """ |
| 12 | from Tkinter import * |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 13 | import tkMessageBox, tkColorChooser, tkFont |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 14 | import string, copy |
Steven M. Gava | 44d3d1a | 2001-07-31 06:59:02 +0000 | [diff] [blame] | 15 | |
Steven M. Gava | c11ccf3 | 2001-09-24 09:43:17 +0000 | [diff] [blame] | 16 | from configHandler import idleConf |
Steven M. Gava | 485f7b6 | 2001-10-26 06:47:09 +0000 | [diff] [blame] | 17 | from dynOptionMenuWidget import DynOptionMenu |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 18 | from tabpage import TabPageSet |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 19 | from keybindingDialog import GetKeysDialog |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 20 | from configSectionNameDialog import GetCfgSectionNameDialog |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 21 | from configHelpSourceEdit import GetHelpSourceDialog |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 22 | |
Steven M. Gava | 44d3d1a | 2001-07-31 06:59:02 +0000 | [diff] [blame] | 23 | class ConfigDialog(Toplevel): |
Steven M. Gava | 44d3d1a | 2001-07-31 06:59:02 +0000 | [diff] [blame] | 24 | """ |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 25 | configuration dialog for idle |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 26 | """ |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 27 | def __init__(self,parent,title): |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 28 | Toplevel.__init__(self, parent) |
| 29 | self.configure(borderwidth=5) |
| 30 | self.geometry("+%d+%d" % (parent.winfo_rootx()+20, |
| 31 | parent.winfo_rooty()+30)) |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 32 | #Theme Elements. Each theme element key is it's display name. |
| 33 | #The first value of the tuple is the sample area tag name. |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 34 | #The second value is the display name list sort index. |
Steven M. Gava | ad4f532 | 2002-01-03 12:05:17 +0000 | [diff] [blame] | 35 | self.themeElements={'Normal Text':('normal','00'), |
| 36 | 'Python Keywords':('keyword','01'), |
| 37 | 'Python Definitions':('definition','02'), |
Kurt B. Kaiser | 73360a3 | 2004-03-08 18:15:31 +0000 | [diff] [blame] | 38 | 'Python Builtins':('builtin', '03'), |
| 39 | 'Python Comments':('comment','04'), |
| 40 | 'Python Strings':('string','05'), |
| 41 | 'Selected Text':('hilite','06'), |
| 42 | 'Found Text':('hit','07'), |
| 43 | 'Cursor':('cursor','08'), |
| 44 | 'Error Text':('error','09'), |
| 45 | 'Shell Normal Text':('console','10'), |
| 46 | 'Shell Stdout Text':('stdout','11'), |
| 47 | 'Shell Stderr Text':('stderr','12'), |
| 48 | } |
Steven M. Gava | a498af2 | 2002-02-01 01:33:36 +0000 | [diff] [blame] | 49 | self.ResetChangedItems() #load initial values in changed items dict |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 50 | self.CreateWidgets() |
| 51 | self.resizable(height=FALSE,width=FALSE) |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 52 | self.transient(parent) |
| 53 | self.grab_set() |
| 54 | self.protocol("WM_DELETE_WINDOW", self.Cancel) |
| 55 | self.parent = parent |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 56 | self.tabPages.focus_set() |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 57 | #key bindings for this dialog |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 58 | #self.bind('<Escape>',self.Cancel) #dismiss dialog, no save |
| 59 | #self.bind('<Alt-a>',self.Apply) #apply changes, save |
| 60 | #self.bind('<F1>',self.Help) #context help |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 61 | self.LoadConfigs() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 62 | self.AttachVarCallbacks() #avoid callbacks during LoadConfigs |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 63 | self.wait_window() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 64 | |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 65 | def CreateWidgets(self): |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 66 | self.tabPages = TabPageSet(self, |
| 67 | pageNames=['Fonts/Tabs','Highlighting','Keys','General']) |
Steven M. Gava | ad4f532 | 2002-01-03 12:05:17 +0000 | [diff] [blame] | 68 | self.tabPages.ChangePage()#activates default (first) page |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 69 | frameActionButtons = Frame(self) |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 70 | #action buttons |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 71 | self.buttonHelp = Button(frameActionButtons,text='Help', |
| 72 | command=self.Help,takefocus=FALSE) |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 73 | self.buttonOk = Button(frameActionButtons,text='Ok', |
| 74 | command=self.Ok,takefocus=FALSE) |
| 75 | self.buttonApply = Button(frameActionButtons,text='Apply', |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 76 | command=self.Apply,takefocus=FALSE) |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 77 | self.buttonCancel = Button(frameActionButtons,text='Cancel', |
| 78 | command=self.Cancel,takefocus=FALSE) |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 79 | self.CreatePageFontTab() |
| 80 | self.CreatePageHighlight() |
| 81 | self.CreatePageKeys() |
| 82 | self.CreatePageGeneral() |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 83 | self.buttonHelp.pack(side=RIGHT,padx=5,pady=5) |
| 84 | self.buttonOk.pack(side=LEFT,padx=5,pady=5) |
| 85 | self.buttonApply.pack(side=LEFT,padx=5,pady=5) |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 86 | self.buttonCancel.pack(side=LEFT,padx=5,pady=5) |
| 87 | frameActionButtons.pack(side=BOTTOM) |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 88 | self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 89 | |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 90 | def CreatePageFontTab(self): |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 91 | #tkVars |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 92 | self.fontSize=StringVar(self) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 93 | self.fontBold=BooleanVar(self) |
| 94 | self.fontName=StringVar(self) |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 95 | self.spaceNum=IntVar(self) |
Steven M. Gava | 9d142ad | 2002-03-12 02:33:52 +0000 | [diff] [blame] | 96 | #self.tabCols=IntVar(self) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 97 | self.indentBySpaces=BooleanVar(self) |
Kurt B. Kaiser | 0539169 | 2003-05-26 20:35:53 +0000 | [diff] [blame] | 98 | self.editFont=tkFont.Font(self,('courier',10,'normal')) |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 99 | ##widget creation |
| 100 | #body frame |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 101 | frame=self.tabPages.pages['Fonts/Tabs']['page'] |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 102 | #body section frames |
| 103 | frameFont=Frame(frame,borderwidth=2,relief=GROOVE) |
| 104 | frameIndent=Frame(frame,borderwidth=2,relief=GROOVE) |
| 105 | #frameFont |
| 106 | labelFontTitle=Label(frameFont,text='Set Base Editor Font') |
| 107 | frameFontName=Frame(frameFont) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 108 | frameFontParam=Frame(frameFont) |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 109 | labelFontNameTitle=Label(frameFontName,justify=LEFT, |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 110 | text='Font :') |
| 111 | self.listFontName=Listbox(frameFontName,height=5,takefocus=FALSE, |
| 112 | exportselection=FALSE) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 113 | self.listFontName.bind('<ButtonRelease-1>',self.OnListFontButtonRelease) |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 114 | scrollFont=Scrollbar(frameFontName) |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 115 | scrollFont.config(command=self.listFontName.yview) |
| 116 | self.listFontName.config(yscrollcommand=scrollFont.set) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 117 | labelFontSizeTitle=Label(frameFontParam,text='Size :') |
| 118 | self.optMenuFontSize=DynOptionMenu(frameFontParam,self.fontSize,None, |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 119 | command=self.SetFontSample) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 120 | checkFontBold=Checkbutton(frameFontParam,variable=self.fontBold, |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 121 | onvalue=1,offvalue=0,text='Bold',command=self.SetFontSample) |
Steven M. Gava | c11ccf3 | 2001-09-24 09:43:17 +0000 | [diff] [blame] | 122 | frameFontSample=Frame(frameFont,relief=SOLID,borderwidth=1) |
| 123 | self.labelFontSample=Label(frameFontSample, |
| 124 | text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]', |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 125 | justify=LEFT,font=self.editFont) |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 126 | #frameIndent |
| 127 | labelIndentTitle=Label(frameIndent,text='Set Indentation Defaults') |
| 128 | frameIndentType=Frame(frameIndent) |
| 129 | frameIndentSize=Frame(frameIndent) |
| 130 | labelIndentTypeTitle=Label(frameIndentType, |
| 131 | text='Choose indentation type :') |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 132 | radioUseSpaces=Radiobutton(frameIndentType,variable=self.indentBySpaces, |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 133 | value=1,text='Tab key inserts spaces') |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 134 | radioUseTabs=Radiobutton(frameIndentType,variable=self.indentBySpaces, |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 135 | value=0,text='Tab key inserts tabs') |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 136 | labelIndentSizeTitle=Label(frameIndentSize, |
| 137 | text='Choose indentation size :') |
| 138 | labelSpaceNumTitle=Label(frameIndentSize,justify=LEFT, |
Kurt B. Kaiser | 39df7c4 | 2002-09-14 02:58:07 +0000 | [diff] [blame] | 139 | text='indent width') |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 140 | self.scaleSpaceNum=Scale(frameIndentSize,variable=self.spaceNum, |
Kurt B. Kaiser | 39df7c4 | 2002-09-14 02:58:07 +0000 | [diff] [blame] | 141 | orient='horizontal',tickinterval=2,from_=2,to=16) |
Steven M. Gava | 63f6714 | 2002-03-12 00:52:42 +0000 | [diff] [blame] | 142 | #labeltabColsTitle=Label(frameIndentSize,justify=LEFT, |
| 143 | # text='when tab key inserts tabs,\ncolumns per tab') |
| 144 | #self.scaleTabCols=Scale(frameIndentSize,variable=self.tabCols, |
| 145 | # orient='horizontal',tickinterval=2,from_=2,to=8) |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 146 | #widget packing |
| 147 | #body |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 148 | frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH) |
| 149 | frameIndent.pack(side=LEFT,padx=5,pady=10,fill=Y) |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 150 | #frameFont |
| 151 | labelFontTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 152 | frameFontName.pack(side=TOP,padx=5,pady=5,fill=X) |
| 153 | frameFontParam.pack(side=TOP,padx=5,pady=5,fill=X) |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 154 | labelFontNameTitle.pack(side=TOP,anchor=W) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 155 | self.listFontName.pack(side=LEFT,expand=TRUE,fill=X) |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 156 | scrollFont.pack(side=LEFT,fill=Y) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 157 | labelFontSizeTitle.pack(side=LEFT,anchor=W) |
| 158 | self.optMenuFontSize.pack(side=LEFT,anchor=W) |
| 159 | checkFontBold.pack(side=LEFT,anchor=W,padx=20) |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 160 | frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) |
Steven M. Gava | c01e30f | 2001-08-11 15:48:13 +0000 | [diff] [blame] | 161 | self.labelFontSample.pack(expand=TRUE,fill=BOTH) |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 162 | #frameIndent |
| 163 | labelIndentTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
| 164 | frameIndentType.pack(side=TOP,padx=5,fill=X) |
| 165 | frameIndentSize.pack(side=TOP,padx=5,pady=5,fill=BOTH) |
| 166 | labelIndentTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
| 167 | radioUseSpaces.pack(side=TOP,anchor=W,padx=5) |
| 168 | radioUseTabs.pack(side=TOP,anchor=W,padx=5) |
| 169 | labelIndentSizeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
| 170 | labelSpaceNumTitle.pack(side=TOP,anchor=W,padx=5) |
| 171 | self.scaleSpaceNum.pack(side=TOP,padx=5,fill=X) |
Steven M. Gava | 63f6714 | 2002-03-12 00:52:42 +0000 | [diff] [blame] | 172 | #labeltabColsTitle.pack(side=TOP,anchor=W,padx=5) |
| 173 | #self.scaleTabCols.pack(side=TOP,padx=5,fill=X) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 174 | return frame |
| 175 | |
| 176 | def CreatePageHighlight(self): |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 177 | self.builtinTheme=StringVar(self) |
| 178 | self.customTheme=StringVar(self) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 179 | self.fgHilite=BooleanVar(self) |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 180 | self.colour=StringVar(self) |
| 181 | self.fontName=StringVar(self) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 182 | self.themeIsBuiltin=BooleanVar(self) |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 183 | self.highlightTarget=StringVar(self) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 184 | ##widget creation |
| 185 | #body frame |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 186 | frame=self.tabPages.pages['Highlighting']['page'] |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 187 | #body section frames |
| 188 | frameCustom=Frame(frame,borderwidth=2,relief=GROOVE) |
| 189 | frameTheme=Frame(frame,borderwidth=2,relief=GROOVE) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 190 | #frameCustom |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 191 | self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1, |
Steven M. Gava | b77d343 | 2002-03-02 07:16:21 +0000 | [diff] [blame] | 192 | font=('courier',12,''),cursor='hand2',width=21,height=10, |
| 193 | takefocus=FALSE,highlightthickness=0,wrap=NONE) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 194 | text=self.textHighlightSample |
| 195 | text.bind('<Double-Button-1>',lambda e: 'break') |
| 196 | text.bind('<B1-Motion>',lambda e: 'break') |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 197 | textAndTags=(('#you can click here','comment'),('\n','normal'), |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 198 | ('#to choose items','comment'),('\n','normal'),('def','keyword'), |
| 199 | (' ','normal'),('func','definition'),('(param):','normal'), |
| 200 | ('\n ','normal'),('"""string"""','string'),('\n var0 = ','normal'), |
Steven M. Gava | d0342cd | 2001-11-04 11:53:10 +0000 | [diff] [blame] | 201 | ("'string'",'string'),('\n var1 = ','normal'),("'selected'",'hilite'), |
Kurt B. Kaiser | 73360a3 | 2004-03-08 18:15:31 +0000 | [diff] [blame] | 202 | ('\n var2 = ','normal'),("'found'",'hit'), |
| 203 | ('\n var3 = ','normal'),('list', 'builtin'), ('(','normal'), |
| 204 | ('None', 'builtin'),(')\n\n','normal'), |
Steven M. Gava | 9930061 | 2001-11-04 07:03:08 +0000 | [diff] [blame] | 205 | (' error ','error'),(' ','normal'),('cursor |','cursor'), |
Steven M. Gava | d0342cd | 2001-11-04 11:53:10 +0000 | [diff] [blame] | 206 | ('\n ','normal'),('shell','console'),(' ','normal'),('stdout','stdout'), |
| 207 | (' ','normal'),('stderr','stderr'),('\n','normal')) |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 208 | for txTa in textAndTags: |
| 209 | text.insert(END,txTa[0],txTa[1]) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 210 | for element in self.themeElements.keys(): |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 211 | text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>', |
| 212 | lambda event,elem=element: event.widget.winfo_toplevel() |
| 213 | .highlightTarget.set(elem)) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 214 | text.config(state=DISABLED) |
| 215 | self.frameColourSet=Frame(frameCustom,relief=SOLID,borderwidth=1) |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 216 | frameFgBg=Frame(frameCustom) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 217 | labelCustomTitle=Label(frameCustom,text='Set Custom Highlighting') |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 218 | buttonSetColour=Button(self.frameColourSet,text='Choose Colour for :', |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 219 | command=self.GetColour,highlightthickness=0) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 220 | self.optMenuHighlightTarget=DynOptionMenu(self.frameColourSet, |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 221 | self.highlightTarget,None,highlightthickness=0)#,command=self.SetHighlightTargetBinding |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 222 | self.radioFg=Radiobutton(frameFgBg,variable=self.fgHilite, |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 223 | value=1,text='Foreground',command=self.SetColourSampleBinding) |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 224 | self.radioBg=Radiobutton(frameFgBg,variable=self.fgHilite, |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 225 | value=0,text='Background',command=self.SetColourSampleBinding) |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 226 | self.fgHilite.set(1) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 227 | buttonSaveCustomTheme=Button(frameCustom, |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 228 | text='Save as New Custom Theme',command=self.SaveAsNewTheme) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 229 | #frameTheme |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 230 | labelThemeTitle=Label(frameTheme,text='Select a Highlighting Theme') |
| 231 | labelTypeTitle=Label(frameTheme,text='Select : ') |
Steven M. Gava | d0342cd | 2001-11-04 11:53:10 +0000 | [diff] [blame] | 232 | self.radioThemeBuiltin=Radiobutton(frameTheme,variable=self.themeIsBuiltin, |
| 233 | value=1,command=self.SetThemeType,text='a Built-in Theme') |
| 234 | self.radioThemeCustom=Radiobutton(frameTheme,variable=self.themeIsBuiltin, |
| 235 | value=0,command=self.SetThemeType,text='a Custom Theme') |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 236 | self.optMenuThemeBuiltin=DynOptionMenu(frameTheme, |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 237 | self.builtinTheme,None,command=None) |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 238 | self.optMenuThemeCustom=DynOptionMenu(frameTheme, |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 239 | self.customTheme,None,command=None) |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 240 | self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme', |
| 241 | command=self.DeleteCustomTheme) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 242 | ##widget packing |
| 243 | #body |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 244 | frameCustom.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH) |
| 245 | frameTheme.pack(side=LEFT,padx=5,pady=10,fill=Y) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 246 | #frameCustom |
| 247 | labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 248 | self.frameColourSet.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=X) |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 249 | frameFgBg.pack(side=TOP,padx=5,pady=0) |
Steven M. Gava | e16d94b | 2001-11-03 05:07:28 +0000 | [diff] [blame] | 250 | self.textHighlightSample.pack(side=TOP,padx=5,pady=5,expand=TRUE, |
| 251 | fill=BOTH) |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 252 | buttonSetColour.pack(side=TOP,expand=TRUE,fill=X,padx=8,pady=4) |
| 253 | self.optMenuHighlightTarget.pack(side=TOP,expand=TRUE,fill=X,padx=8,pady=3) |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 254 | self.radioFg.pack(side=LEFT,anchor=E) |
| 255 | self.radioBg.pack(side=RIGHT,anchor=W) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 256 | buttonSaveCustomTheme.pack(side=BOTTOM,fill=X,padx=5,pady=5) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 257 | #frameTheme |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 258 | labelThemeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
| 259 | labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 260 | self.radioThemeBuiltin.pack(side=TOP,anchor=W,padx=5) |
| 261 | self.radioThemeCustom.pack(side=TOP,anchor=W,padx=5,pady=2) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 262 | self.optMenuThemeBuiltin.pack(side=TOP,fill=X,padx=5,pady=5) |
| 263 | self.optMenuThemeCustom.pack(side=TOP,fill=X,anchor=W,padx=5,pady=5) |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 264 | self.buttonDeleteCustomTheme.pack(side=TOP,fill=X,padx=5,pady=5) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 265 | return frame |
| 266 | |
| 267 | def CreatePageKeys(self): |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 268 | #tkVars |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 269 | self.bindingTarget=StringVar(self) |
| 270 | self.builtinKeys=StringVar(self) |
| 271 | self.customKeys=StringVar(self) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 272 | self.keysAreBuiltin=BooleanVar(self) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 273 | self.keyBinding=StringVar(self) |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 274 | ##widget creation |
| 275 | #body frame |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 276 | frame=self.tabPages.pages['Keys']['page'] |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 277 | #body section frames |
| 278 | frameCustom=Frame(frame,borderwidth=2,relief=GROOVE) |
| 279 | frameKeySets=Frame(frame,borderwidth=2,relief=GROOVE) |
| 280 | #frameCustom |
| 281 | frameTarget=Frame(frameCustom) |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 282 | labelCustomTitle=Label(frameCustom,text='Set Custom Key Bindings') |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 283 | labelTargetTitle=Label(frameTarget,text='Action - Key(s)') |
| 284 | scrollTargetY=Scrollbar(frameTarget) |
| 285 | scrollTargetX=Scrollbar(frameTarget,orient=HORIZONTAL) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 286 | self.listBindings=Listbox(frameTarget,takefocus=FALSE, |
| 287 | exportselection=FALSE) |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 288 | self.listBindings.bind('<ButtonRelease-1>',self.KeyBindingSelected) |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 289 | scrollTargetY.config(command=self.listBindings.yview) |
| 290 | scrollTargetX.config(command=self.listBindings.xview) |
| 291 | self.listBindings.config(yscrollcommand=scrollTargetY.set) |
| 292 | self.listBindings.config(xscrollcommand=scrollTargetX.set) |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 293 | self.buttonNewKeys=Button(frameCustom,text='Get New Keys for Selection', |
| 294 | command=self.GetNewKeys,state=DISABLED) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 295 | buttonSaveCustomKeys=Button(frameCustom, |
| 296 | text='Save as New Custom Key Set',command=self.SaveAsNewKeySet) |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 297 | #frameKeySets |
Steven M. Gava | f213ccb | 2001-08-05 08:00:28 +0000 | [diff] [blame] | 298 | labelKeysTitle=Label(frameKeySets,text='Select a Key Set') |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 299 | labelTypeTitle=Label(frameKeySets,text='Select : ') |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 300 | self.radioKeysBuiltin=Radiobutton(frameKeySets,variable=self.keysAreBuiltin, |
Steven M. Gava | d0342cd | 2001-11-04 11:53:10 +0000 | [diff] [blame] | 301 | value=1,command=self.SetKeysType,text='a Built-in Key Set') |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 302 | self.radioKeysCustom=Radiobutton(frameKeySets,variable=self.keysAreBuiltin, |
Steven M. Gava | d0342cd | 2001-11-04 11:53:10 +0000 | [diff] [blame] | 303 | value=0,command=self.SetKeysType,text='a Custom Key Set') |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 304 | self.optMenuKeysBuiltin=DynOptionMenu(frameKeySets, |
| 305 | self.builtinKeys,None,command=None) |
| 306 | self.optMenuKeysCustom=DynOptionMenu(frameKeySets, |
| 307 | self.customKeys,None,command=None) |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 308 | self.buttonDeleteCustomKeys=Button(frameKeySets,text='Delete Custom Key Set', |
| 309 | command=self.DeleteCustomKeys) |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 310 | ##widget packing |
| 311 | #body |
| 312 | frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH) |
| 313 | frameKeySets.pack(side=LEFT,padx=5,pady=5,fill=Y) |
| 314 | #frameCustom |
| 315 | labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 316 | buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5) |
| 317 | self.buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5) |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 318 | frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH) |
| 319 | #frame target |
| 320 | frameTarget.columnconfigure(0,weight=1) |
| 321 | frameTarget.rowconfigure(1,weight=1) |
| 322 | labelTargetTitle.grid(row=0,column=0,columnspan=2,sticky=W) |
| 323 | self.listBindings.grid(row=1,column=0,sticky=NSEW) |
| 324 | scrollTargetY.grid(row=1,column=1,sticky=NS) |
| 325 | scrollTargetX.grid(row=2,column=0,sticky=EW) |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 326 | #frameKeySets |
| 327 | labelKeysTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
| 328 | labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 329 | self.radioKeysBuiltin.pack(side=TOP,anchor=W,padx=5) |
| 330 | self.radioKeysCustom.pack(side=TOP,anchor=W,padx=5,pady=2) |
Steven M. Gava | 60fc707 | 2001-08-04 13:58:22 +0000 | [diff] [blame] | 331 | self.optMenuKeysBuiltin.pack(side=TOP,fill=X,padx=5,pady=5) |
| 332 | self.optMenuKeysCustom.pack(side=TOP,fill=X,anchor=W,padx=5,pady=5) |
| 333 | self.buttonDeleteCustomKeys.pack(side=TOP,fill=X,padx=5,pady=5) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 334 | return frame |
| 335 | |
| 336 | def CreatePageGeneral(self): |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 337 | #tkVars |
| 338 | self.winWidth=StringVar(self) |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 339 | self.winHeight=StringVar(self) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 340 | self.startupEdit=IntVar(self) |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 341 | self.autoSave=IntVar(self) |
Kurt B. Kaiser | a053f33 | 2003-05-10 00:49:56 +0000 | [diff] [blame] | 342 | self.encoding=StringVar(self) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 343 | self.userHelpBrowser=BooleanVar(self) |
| 344 | self.helpBrowser=StringVar(self) |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 345 | #widget creation |
| 346 | #body |
Steven M. Gava | 2d4e03b | 2001-12-05 07:54:07 +0000 | [diff] [blame] | 347 | frame=self.tabPages.pages['General']['page'] |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 348 | #body section frames |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 349 | frameRun=Frame(frame,borderwidth=2,relief=GROOVE) |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 350 | frameSave=Frame(frame,borderwidth=2,relief=GROOVE) |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 351 | frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE) |
Kurt B. Kaiser | a053f33 | 2003-05-10 00:49:56 +0000 | [diff] [blame] | 352 | frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 353 | frameHelp=Frame(frame,borderwidth=2,relief=GROOVE) |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 354 | #frameRun |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 355 | labelRunTitle=Label(frameRun,text='Startup Preferences') |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 356 | labelRunChoiceTitle=Label(frameRun,text='At Startup') |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 357 | radioStartupEdit=Radiobutton(frameRun,variable=self.startupEdit, |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 358 | value=1,command=self.SetKeysType,text="Open Edit Window") |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 359 | radioStartupShell=Radiobutton(frameRun,variable=self.startupEdit, |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 360 | value=0,command=self.SetKeysType,text='Open Shell Window') |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 361 | #frameSave |
| 362 | labelSaveTitle=Label(frameSave,text='Autosave Preference') |
| 363 | labelRunSaveTitle=Label(frameSave,text='At Start of Run (F5) ') |
| 364 | radioSaveAsk=Radiobutton(frameSave,variable=self.autoSave, |
| 365 | value=0,command=self.SetKeysType,text="Prompt to Save") |
| 366 | radioSaveAuto=Radiobutton(frameSave,variable=self.autoSave, |
| 367 | value=1,command=self.SetKeysType,text='No Prompt') |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 368 | #frameWinSize |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 369 | labelWinSizeTitle=Label(frameWinSize,text='Initial Window Size'+ |
| 370 | ' (in characters)') |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 371 | labelWinWidthTitle=Label(frameWinSize,text='Width') |
| 372 | entryWinWidth=Entry(frameWinSize,textvariable=self.winWidth, |
| 373 | width=3) |
| 374 | labelWinHeightTitle=Label(frameWinSize,text='Height') |
| 375 | entryWinHeight=Entry(frameWinSize,textvariable=self.winHeight, |
| 376 | width=3) |
Kurt B. Kaiser | a053f33 | 2003-05-10 00:49:56 +0000 | [diff] [blame] | 377 | #frameEncoding |
| 378 | labelEncodingTitle=Label(frameEncoding,text="Default Source Encoding") |
| 379 | radioEncLocale=Radiobutton(frameEncoding,variable=self.encoding, |
| 380 | value="locale",text="Locale-defined") |
| 381 | radioEncUTF8=Radiobutton(frameEncoding,variable=self.encoding, |
| 382 | value="utf-8",text="UTF-8") |
| 383 | radioEncNone=Radiobutton(frameEncoding,variable=self.encoding, |
| 384 | value="none",text="None") |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 385 | #frameHelp |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 386 | ##labelHelpTitle=Label(frameHelp,text='Help Options') |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 387 | frameHelpList=Frame(frameHelp) |
| 388 | frameHelpListButtons=Frame(frameHelpList) |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 389 | labelHelpListTitle=Label(frameHelpList,text='Additional Help Sources:') |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 390 | scrollHelpList=Scrollbar(frameHelpList) |
| 391 | self.listHelp=Listbox(frameHelpList,height=5,takefocus=FALSE, |
| 392 | exportselection=FALSE) |
| 393 | scrollHelpList.config(command=self.listHelp.yview) |
| 394 | self.listHelp.config(yscrollcommand=scrollHelpList.set) |
| 395 | self.listHelp.bind('<ButtonRelease-1>',self.HelpSourceSelected) |
| 396 | self.buttonHelpListEdit=Button(frameHelpListButtons,text='Edit', |
| 397 | state=DISABLED,width=8,command=self.HelpListItemEdit) |
| 398 | self.buttonHelpListAdd=Button(frameHelpListButtons,text='Add', |
| 399 | width=8,command=self.HelpListItemAdd) |
| 400 | self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove', |
| 401 | state=DISABLED,width=8,command=self.HelpListItemRemove) |
Steven M. Gava | 0c5bc8c | 2002-03-27 02:25:44 +0000 | [diff] [blame] | 402 | # the following is better handled by the BROWSER environment |
| 403 | # variable under unix/linux |
| 404 | #checkHelpBrowser=Checkbutton(frameHelp,variable=self.userHelpBrowser, |
| 405 | # onvalue=1,offvalue=0,text='user specified (html) help browser:', |
| 406 | # command=self.OnCheckUserHelpBrowser) |
| 407 | #self.entryHelpBrowser=Entry(frameHelp,textvariable=self.helpBrowser, |
| 408 | # width=40) |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 409 | #widget packing |
| 410 | #body |
| 411 | frameRun.pack(side=TOP,padx=5,pady=5,fill=X) |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 412 | frameSave.pack(side=TOP,padx=5,pady=5,fill=X) |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 413 | frameWinSize.pack(side=TOP,padx=5,pady=5,fill=X) |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 414 | frameEncoding.pack(side=TOP,padx=5,pady=5,fill=X) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 415 | frameHelp.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 416 | #frameRun |
| 417 | labelRunTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
| 418 | labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5) |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 419 | radioStartupShell.pack(side=RIGHT,anchor=W,padx=5,pady=5) |
| 420 | radioStartupEdit.pack(side=RIGHT,anchor=W,padx=5,pady=5) |
| 421 | #frameSave |
| 422 | labelSaveTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
| 423 | labelRunSaveTitle.pack(side=LEFT,anchor=W,padx=5,pady=5) |
| 424 | radioSaveAuto.pack(side=RIGHT,anchor=W,padx=5,pady=5) |
| 425 | radioSaveAsk.pack(side=RIGHT,anchor=W,padx=5,pady=5) |
Steven M. Gava | 230e578 | 2001-08-07 03:28:25 +0000 | [diff] [blame] | 426 | #frameWinSize |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 427 | labelWinSizeTitle.pack(side=LEFT,anchor=W,padx=5,pady=5) |
| 428 | entryWinHeight.pack(side=RIGHT,anchor=E,padx=10,pady=5) |
| 429 | labelWinHeightTitle.pack(side=RIGHT,anchor=E,pady=5) |
| 430 | entryWinWidth.pack(side=RIGHT,anchor=E,padx=10,pady=5) |
| 431 | labelWinWidthTitle.pack(side=RIGHT,anchor=E,pady=5) |
Kurt B. Kaiser | a053f33 | 2003-05-10 00:49:56 +0000 | [diff] [blame] | 432 | #frameEncoding |
| 433 | labelEncodingTitle.pack(side=LEFT,anchor=W,padx=5,pady=5) |
| 434 | radioEncNone.pack(side=RIGHT,anchor=E,pady=5) |
| 435 | radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5) |
| 436 | radioEncLocale.pack(side=RIGHT,anchor=E,pady=5) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 437 | #frameHelp |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 438 | ##labelHelpTitle.pack(side=TOP,anchor=W,padx=5,pady=5) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 439 | frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y) |
| 440 | frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) |
| 441 | labelHelpListTitle.pack(side=TOP,anchor=W) |
| 442 | scrollHelpList.pack(side=RIGHT,anchor=W,fill=Y) |
| 443 | self.listHelp.pack(side=LEFT,anchor=E,expand=TRUE,fill=BOTH) |
| 444 | self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5) |
| 445 | self.buttonHelpListAdd.pack(side=TOP,anchor=W) |
| 446 | self.buttonHelpListRemove.pack(side=TOP,anchor=W,pady=5) |
Steven M. Gava | 0c5bc8c | 2002-03-27 02:25:44 +0000 | [diff] [blame] | 447 | #checkHelpBrowser.pack(side=TOP,anchor=W,padx=5) |
| 448 | #self.entryHelpBrowser.pack(side=TOP,anchor=W,padx=5,pady=5) |
Steven M. Gava | 952d0a5 | 2001-08-03 04:43:44 +0000 | [diff] [blame] | 449 | return frame |
| 450 | |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 451 | def AttachVarCallbacks(self): |
| 452 | self.fontSize.trace_variable('w',self.VarChanged_fontSize) |
| 453 | self.fontName.trace_variable('w',self.VarChanged_fontName) |
| 454 | self.fontBold.trace_variable('w',self.VarChanged_fontBold) |
| 455 | self.spaceNum.trace_variable('w',self.VarChanged_spaceNum) |
Steven M. Gava | 9d142ad | 2002-03-12 02:33:52 +0000 | [diff] [blame] | 456 | #self.tabCols.trace_variable('w',self.VarChanged_tabCols) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 457 | self.indentBySpaces.trace_variable('w',self.VarChanged_indentBySpaces) |
| 458 | self.colour.trace_variable('w',self.VarChanged_colour) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 459 | self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme) |
| 460 | self.customTheme.trace_variable('w',self.VarChanged_customTheme) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 461 | self.themeIsBuiltin.trace_variable('w',self.VarChanged_themeIsBuiltin) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 462 | self.highlightTarget.trace_variable('w',self.VarChanged_highlightTarget) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 463 | self.keyBinding.trace_variable('w',self.VarChanged_keyBinding) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 464 | self.builtinKeys.trace_variable('w',self.VarChanged_builtinKeys) |
| 465 | self.customKeys.trace_variable('w',self.VarChanged_customKeys) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 466 | self.keysAreBuiltin.trace_variable('w',self.VarChanged_keysAreBuiltin) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 467 | self.winWidth.trace_variable('w',self.VarChanged_winWidth) |
| 468 | self.winHeight.trace_variable('w',self.VarChanged_winHeight) |
| 469 | self.startupEdit.trace_variable('w',self.VarChanged_startupEdit) |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 470 | self.autoSave.trace_variable('w',self.VarChanged_autoSave) |
Kurt B. Kaiser | a053f33 | 2003-05-10 00:49:56 +0000 | [diff] [blame] | 471 | self.encoding.trace_variable('w',self.VarChanged_encoding) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 472 | |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 473 | def VarChanged_fontSize(self,*params): |
| 474 | value=self.fontSize.get() |
| 475 | self.AddChangedItem('main','EditorWindow','font-size',value) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 476 | |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 477 | def VarChanged_fontName(self,*params): |
| 478 | value=self.fontName.get() |
| 479 | self.AddChangedItem('main','EditorWindow','font',value) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 480 | |
| 481 | def VarChanged_fontBold(self,*params): |
| 482 | value=self.fontBold.get() |
| 483 | self.AddChangedItem('main','EditorWindow','font-bold',value) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 484 | |
| 485 | def VarChanged_indentBySpaces(self,*params): |
| 486 | value=self.indentBySpaces.get() |
| 487 | self.AddChangedItem('main','Indent','use-spaces',value) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 488 | |
| 489 | def VarChanged_spaceNum(self,*params): |
| 490 | value=self.spaceNum.get() |
| 491 | self.AddChangedItem('main','Indent','num-spaces',value) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 492 | |
Steven M. Gava | 9d142ad | 2002-03-12 02:33:52 +0000 | [diff] [blame] | 493 | #def VarChanged_tabCols(self,*params): |
| 494 | # value=self.tabCols.get() |
| 495 | # self.AddChangedItem('main','Indent','tab-cols',value) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 496 | |
| 497 | def VarChanged_colour(self,*params): |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 498 | self.OnNewColourSet() |
| 499 | |
| 500 | def VarChanged_builtinTheme(self,*params): |
| 501 | value=self.builtinTheme.get() |
| 502 | self.AddChangedItem('main','Theme','name',value) |
| 503 | self.PaintThemeSample() |
| 504 | |
| 505 | def VarChanged_customTheme(self,*params): |
| 506 | value=self.customTheme.get() |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 507 | if value != '- no custom themes -': |
| 508 | self.AddChangedItem('main','Theme','name',value) |
| 509 | self.PaintThemeSample() |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 510 | |
| 511 | def VarChanged_themeIsBuiltin(self,*params): |
| 512 | value=self.themeIsBuiltin.get() |
| 513 | self.AddChangedItem('main','Theme','default',value) |
Steven M. Gava | f31eec0 | 2002-03-05 00:25:58 +0000 | [diff] [blame] | 514 | if value: |
| 515 | self.VarChanged_builtinTheme() |
| 516 | else: |
| 517 | self.VarChanged_customTheme() |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 518 | |
| 519 | def VarChanged_highlightTarget(self,*params): |
| 520 | self.SetHighlightTarget() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 521 | |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 522 | def VarChanged_keyBinding(self,*params): |
Steven M. Gava | bbf5ef5 | 2002-01-22 11:35:50 +0000 | [diff] [blame] | 523 | value=self.keyBinding.get() |
| 524 | keySet=self.customKeys.get() |
| 525 | event=self.listBindings.get(ANCHOR).split()[0] |
Steven M. Gava | a498af2 | 2002-02-01 01:33:36 +0000 | [diff] [blame] | 526 | if idleConf.IsCoreBinding(event): |
| 527 | #this is a core keybinding |
| 528 | self.AddChangedItem('keys',keySet,event,value) |
| 529 | else: #this is an extension key binding |
| 530 | extName=idleConf.GetExtnNameForEvent(event) |
| 531 | extKeybindSection=extName+'_cfgBindings' |
| 532 | self.AddChangedItem('extensions',extKeybindSection,event,value) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 533 | |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 534 | def VarChanged_builtinKeys(self,*params): |
| 535 | value=self.builtinKeys.get() |
| 536 | self.AddChangedItem('main','Keys','name',value) |
| 537 | self.LoadKeysList(value) |
| 538 | |
| 539 | def VarChanged_customKeys(self,*params): |
| 540 | value=self.customKeys.get() |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 541 | if value != '- no custom keys -': |
| 542 | self.AddChangedItem('main','Keys','name',value) |
| 543 | self.LoadKeysList(value) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 544 | |
| 545 | def VarChanged_keysAreBuiltin(self,*params): |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 546 | value=self.keysAreBuiltin.get() |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 547 | self.AddChangedItem('main','Keys','default',value) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 548 | if value: |
Steven M. Gava | f31eec0 | 2002-03-05 00:25:58 +0000 | [diff] [blame] | 549 | self.VarChanged_builtinKeys() |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 550 | else: |
Steven M. Gava | f31eec0 | 2002-03-05 00:25:58 +0000 | [diff] [blame] | 551 | self.VarChanged_customKeys() |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 552 | |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 553 | def VarChanged_winWidth(self,*params): |
Steven M. Gava | bbf5ef5 | 2002-01-22 11:35:50 +0000 | [diff] [blame] | 554 | value=self.winWidth.get() |
| 555 | self.AddChangedItem('main','EditorWindow','width',value) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 556 | |
| 557 | def VarChanged_winHeight(self,*params): |
Steven M. Gava | bbf5ef5 | 2002-01-22 11:35:50 +0000 | [diff] [blame] | 558 | value=self.winHeight.get() |
| 559 | self.AddChangedItem('main','EditorWindow','height',value) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 560 | |
| 561 | def VarChanged_startupEdit(self,*params): |
Steven M. Gava | bbf5ef5 | 2002-01-22 11:35:50 +0000 | [diff] [blame] | 562 | value=self.startupEdit.get() |
| 563 | self.AddChangedItem('main','General','editor-on-startup',value) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 564 | |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 565 | def VarChanged_autoSave(self,*params): |
| 566 | value=self.autoSave.get() |
| 567 | self.AddChangedItem('main','General','autosave',value) |
| 568 | |
Kurt B. Kaiser | a053f33 | 2003-05-10 00:49:56 +0000 | [diff] [blame] | 569 | def VarChanged_encoding(self,*params): |
| 570 | value=self.encoding.get() |
| 571 | self.AddChangedItem('main','EditorWindow','encoding',value) |
| 572 | |
Steven M. Gava | a498af2 | 2002-02-01 01:33:36 +0000 | [diff] [blame] | 573 | def ResetChangedItems(self): |
Steven M. Gava | b77d343 | 2002-03-02 07:16:21 +0000 | [diff] [blame] | 574 | #When any config item is changed in this dialog, an entry |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 575 | #should be made in the relevant section (config type) of this |
| 576 | #dictionary. The key should be the config file section name and the |
Steven M. Gava | a498af2 | 2002-02-01 01:33:36 +0000 | [diff] [blame] | 577 | #value a dictionary, whose key:value pairs are item=value pairs for |
| 578 | #that config file section. |
| 579 | self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}} |
| 580 | |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 581 | def AddChangedItem(self,type,section,item,value): |
Steven M. Gava | 2d7bb3f | 2002-01-29 08:35:29 +0000 | [diff] [blame] | 582 | value=str(value) #make sure we use a string |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 583 | if not self.changedItems[type].has_key(section): |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 584 | self.changedItems[type][section]={} |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 585 | self.changedItems[type][section][item]=value |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 586 | |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 587 | def GetDefaultItems(self): |
| 588 | dItems={'main':{},'highlight':{},'keys':{},'extensions':{}} |
| 589 | for configType in dItems.keys(): |
| 590 | sections=idleConf.GetSectionList('default',configType) |
| 591 | for section in sections: |
| 592 | dItems[configType][section]={} |
| 593 | options=idleConf.defaultCfg[configType].GetOptionList(section) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 594 | for option in options: |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 595 | dItems[configType][section][option]=( |
| 596 | idleConf.defaultCfg[configType].Get(section,option)) |
| 597 | return dItems |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 598 | |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 599 | def SetThemeType(self): |
| 600 | if self.themeIsBuiltin.get(): |
| 601 | self.optMenuThemeBuiltin.config(state=NORMAL) |
| 602 | self.optMenuThemeCustom.config(state=DISABLED) |
| 603 | self.buttonDeleteCustomTheme.config(state=DISABLED) |
| 604 | else: |
| 605 | self.optMenuThemeBuiltin.config(state=DISABLED) |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 606 | self.radioThemeCustom.config(state=NORMAL) |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 607 | self.optMenuThemeCustom.config(state=NORMAL) |
| 608 | self.buttonDeleteCustomTheme.config(state=NORMAL) |
| 609 | |
| 610 | def SetKeysType(self): |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 611 | if self.keysAreBuiltin.get(): |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 612 | self.optMenuKeysBuiltin.config(state=NORMAL) |
| 613 | self.optMenuKeysCustom.config(state=DISABLED) |
| 614 | self.buttonDeleteCustomKeys.config(state=DISABLED) |
| 615 | else: |
| 616 | self.optMenuKeysBuiltin.config(state=DISABLED) |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 617 | self.radioKeysCustom.config(state=NORMAL) |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 618 | self.optMenuKeysCustom.config(state=NORMAL) |
| 619 | self.buttonDeleteCustomKeys.config(state=NORMAL) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 620 | |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 621 | def GetNewKeys(self): |
| 622 | listIndex=self.listBindings.index(ANCHOR) |
| 623 | binding=self.listBindings.get(listIndex) |
| 624 | bindName=binding.split()[0] #first part, up to first space |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 625 | if self.keysAreBuiltin.get(): |
Steven M. Gava | e28ee75 | 2002-02-11 03:45:22 +0000 | [diff] [blame] | 626 | currentKeySetName=self.builtinKeys.get() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 627 | else: |
Steven M. Gava | e28ee75 | 2002-02-11 03:45:22 +0000 | [diff] [blame] | 628 | currentKeySetName=self.customKeys.get() |
| 629 | currentBindings=idleConf.GetCurrentKeySet() |
| 630 | if currentKeySetName in self.changedItems['keys'].keys(): #unsaved changes |
| 631 | keySetChanges=self.changedItems['keys'][currentKeySetName] |
| 632 | for event in keySetChanges.keys(): |
| 633 | currentBindings[event]=keySetChanges[event].split() |
| 634 | currentKeySequences=currentBindings.values() |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 635 | newKeys=GetKeysDialog(self,'Get New Keys',bindName, |
| 636 | currentKeySequences).result |
| 637 | if newKeys: #new keys were specified |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 638 | if self.keysAreBuiltin.get(): #current key set is a built-in |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 639 | message=('Your changes will be saved as a new Custom Key Set. '+ |
| 640 | 'Enter a name for your new Custom Key Set below.') |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 641 | newKeySet=self.GetNewKeysName(message) |
| 642 | if not newKeySet: #user cancelled custom key set creation |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 643 | self.listBindings.select_set(listIndex) |
| 644 | self.listBindings.select_anchor(listIndex) |
| 645 | return |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 646 | else: #create new custom key set based on previously active key set |
| 647 | self.CreateNewKeySet(newKeySet) |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 648 | self.listBindings.delete(listIndex) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 649 | self.listBindings.insert(listIndex,bindName+' - '+newKeys) |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 650 | self.listBindings.select_set(listIndex) |
| 651 | self.listBindings.select_anchor(listIndex) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 652 | self.keyBinding.set(newKeys) |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 653 | else: |
| 654 | self.listBindings.select_set(listIndex) |
| 655 | self.listBindings.select_anchor(listIndex) |
| 656 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 657 | def GetNewKeysName(self,message): |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 658 | usedNames=(idleConf.GetSectionList('user','keys')+ |
| 659 | idleConf.GetSectionList('default','keys')) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 660 | newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set', |
| 661 | message,usedNames).result |
| 662 | return newKeySet |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 663 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 664 | def SaveAsNewKeySet(self): |
| 665 | newKeysName=self.GetNewKeysName('New Key Set Name:') |
| 666 | if newKeysName: |
| 667 | self.CreateNewKeySet(newKeysName) |
| 668 | |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 669 | def KeyBindingSelected(self,event): |
| 670 | self.buttonNewKeys.config(state=NORMAL) |
| 671 | |
| 672 | def CreateNewKeySet(self,newKeySetName): |
| 673 | #creates new custom key set based on the previously active key set, |
| 674 | #and makes the new key set active |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 675 | if self.keysAreBuiltin.get(): |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 676 | prevKeySetName=self.builtinKeys.get() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 677 | else: |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 678 | prevKeySetName=self.customKeys.get() |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 679 | prevKeys=idleConf.GetCoreKeys(prevKeySetName) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 680 | newKeys={} |
| 681 | for event in prevKeys.keys(): #add key set to changed items |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 682 | eventName=event[2:-2] #trim off the angle brackets |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 683 | binding=string.join(prevKeys[event]) |
| 684 | newKeys[eventName]=binding |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 685 | #handle any unsaved changes to prev key set |
| 686 | if prevKeySetName in self.changedItems['keys'].keys(): |
| 687 | keySetChanges=self.changedItems['keys'][prevKeySetName] |
| 688 | for event in keySetChanges.keys(): |
| 689 | newKeys[event]=keySetChanges[event] |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 690 | #save the new theme |
| 691 | self.SaveNewKeySet(newKeySetName,newKeys) |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 692 | #change gui over to the new key set |
| 693 | customKeyList=idleConf.GetSectionList('user','keys') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 694 | customKeyList.sort() |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 695 | self.optMenuKeysCustom.SetMenu(customKeyList,newKeySetName) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 696 | self.keysAreBuiltin.set(0) |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 697 | self.SetKeysType() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 698 | |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 699 | def LoadKeysList(self,keySetName): |
| 700 | reselect=0 |
| 701 | newKeySet=0 |
| 702 | if self.listBindings.curselection(): |
| 703 | reselect=1 |
| 704 | listIndex=self.listBindings.index(ANCHOR) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 705 | keySet=idleConf.GetKeySet(keySetName) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 706 | bindNames=keySet.keys() |
| 707 | bindNames.sort() |
| 708 | self.listBindings.delete(0,END) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 709 | for bindName in bindNames: |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 710 | key=string.join(keySet[bindName]) #make key(s) into a string |
| 711 | bindName=bindName[2:-2] #trim off the angle brackets |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 712 | if keySetName in self.changedItems['keys'].keys(): |
| 713 | #handle any unsaved changes to this key set |
| 714 | if bindName in self.changedItems['keys'][keySetName].keys(): |
| 715 | key=self.changedItems['keys'][keySetName][bindName] |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 716 | self.listBindings.insert(END, bindName+' - '+key) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 717 | if reselect: |
| 718 | self.listBindings.see(listIndex) |
| 719 | self.listBindings.select_set(listIndex) |
| 720 | self.listBindings.select_anchor(listIndex) |
| 721 | |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 722 | def DeleteCustomKeys(self): |
| 723 | keySetName=self.customKeys.get() |
| 724 | if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+ |
Walter Dörwald | 70a6b49 | 2004-02-12 17:35:32 +0000 | [diff] [blame] | 725 | 'to delete the key set %r ?' % (keySetName), |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 726 | parent=self): |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 727 | return |
| 728 | #remove key set from config |
| 729 | idleConf.userCfg['keys'].remove_section(keySetName) |
| 730 | if self.changedItems['keys'].has_key(keySetName): |
| 731 | del(self.changedItems['keys'][keySetName]) |
| 732 | #write changes |
| 733 | idleConf.userCfg['keys'].Save() |
| 734 | #reload user key set list |
| 735 | itemList=idleConf.GetSectionList('user','keys') |
| 736 | itemList.sort() |
| 737 | if not itemList: |
| 738 | self.radioKeysCustom.config(state=DISABLED) |
| 739 | self.optMenuKeysCustom.SetMenu(itemList,'- no custom keys -') |
| 740 | else: |
| 741 | self.optMenuKeysCustom.SetMenu(itemList,itemList[0]) |
| 742 | #revert to default key set |
| 743 | self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys','default')) |
| 744 | self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys','name')) |
| 745 | #user can't back out of these changes, they must be applied now |
| 746 | self.Apply() |
| 747 | self.SetKeysType() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 748 | |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 749 | def DeleteCustomTheme(self): |
| 750 | themeName=self.customTheme.get() |
| 751 | if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+ |
Walter Dörwald | 70a6b49 | 2004-02-12 17:35:32 +0000 | [diff] [blame] | 752 | 'to delete the theme %r ?' % (themeName,), |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 753 | parent=self): |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 754 | return |
| 755 | #remove theme from config |
| 756 | idleConf.userCfg['highlight'].remove_section(themeName) |
| 757 | if self.changedItems['highlight'].has_key(themeName): |
| 758 | del(self.changedItems['highlight'][themeName]) |
| 759 | #write changes |
| 760 | idleConf.userCfg['highlight'].Save() |
| 761 | #reload user theme list |
| 762 | itemList=idleConf.GetSectionList('user','highlight') |
| 763 | itemList.sort() |
| 764 | if not itemList: |
| 765 | self.radioThemeCustom.config(state=DISABLED) |
| 766 | self.optMenuThemeCustom.SetMenu(itemList,'- no custom themes -') |
| 767 | else: |
| 768 | self.optMenuThemeCustom.SetMenu(itemList,itemList[0]) |
| 769 | #revert to default theme |
| 770 | self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme','default')) |
| 771 | self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme','name')) |
| 772 | #user can't back out of these changes, they must be applied now |
| 773 | self.Apply() |
| 774 | self.SetThemeType() |
| 775 | |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 776 | def GetColour(self): |
| 777 | target=self.highlightTarget.get() |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 778 | prevColour=self.frameColourSet.cget('bg') |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 779 | rgbTuplet, colourString = tkColorChooser.askcolor(parent=self, |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 780 | title='Pick new colour for : '+target,initialcolor=prevColour) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 781 | if colourString and (colourString!=prevColour): |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 782 | #user didn't cancel, and they chose a new colour |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 783 | if self.themeIsBuiltin.get(): #current theme is a built-in |
| 784 | message=('Your changes will be saved as a new Custom Theme. '+ |
| 785 | 'Enter a name for your new Custom Theme below.') |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 786 | newTheme=self.GetNewThemeName(message) |
| 787 | if not newTheme: #user cancelled custom theme creation |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 788 | return |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 789 | else: #create new custom theme based on previously active theme |
| 790 | self.CreateNewTheme(newTheme) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 791 | self.colour.set(colourString) |
| 792 | else: #current theme is user defined |
| 793 | self.colour.set(colourString) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 794 | |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 795 | def OnNewColourSet(self): |
| 796 | newColour=self.colour.get() |
| 797 | self.frameColourSet.config(bg=newColour)#set sample |
| 798 | if self.fgHilite.get(): plane='foreground' |
| 799 | else: plane='background' |
| 800 | sampleElement=self.themeElements[self.highlightTarget.get()][0] |
Raymond Hettinger | 931237e | 2003-07-09 18:48:24 +0000 | [diff] [blame] | 801 | self.textHighlightSample.tag_config(sampleElement, **{plane:newColour}) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 802 | theme=self.customTheme.get() |
| 803 | themeElement=sampleElement+'-'+plane |
| 804 | self.AddChangedItem('highlight',theme,themeElement,newColour) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 805 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 806 | def GetNewThemeName(self,message): |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 807 | usedNames=(idleConf.GetSectionList('user','highlight')+ |
| 808 | idleConf.GetSectionList('default','highlight')) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 809 | newTheme=GetCfgSectionNameDialog(self,'New Custom Theme', |
| 810 | message,usedNames).result |
| 811 | return newTheme |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 812 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 813 | def SaveAsNewTheme(self): |
| 814 | newThemeName=self.GetNewThemeName('New Theme Name:') |
| 815 | if newThemeName: |
| 816 | self.CreateNewTheme(newThemeName) |
| 817 | |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 818 | def CreateNewTheme(self,newThemeName): |
| 819 | #creates new custom theme based on the previously active theme, |
| 820 | #and makes the new theme active |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 821 | if self.themeIsBuiltin.get(): |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 822 | themeType='default' |
| 823 | themeName=self.builtinTheme.get() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 824 | else: |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 825 | themeType='user' |
| 826 | themeName=self.customTheme.get() |
| 827 | newTheme=idleConf.GetThemeDict(themeType,themeName) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 828 | #apply any of the old theme's unsaved changes to the new theme |
| 829 | if themeName in self.changedItems['highlight'].keys(): |
| 830 | themeChanges=self.changedItems['highlight'][themeName] |
| 831 | for element in themeChanges.keys(): |
| 832 | newTheme[element]=themeChanges[element] |
| 833 | #save the new theme |
| 834 | self.SaveNewTheme(newThemeName,newTheme) |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 835 | #change gui over to the new theme |
| 836 | customThemeList=idleConf.GetSectionList('user','highlight') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 837 | customThemeList.sort() |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 838 | self.optMenuThemeCustom.SetMenu(customThemeList,newThemeName) |
| 839 | self.themeIsBuiltin.set(0) |
| 840 | self.SetThemeType() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 841 | |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 842 | def OnListFontButtonRelease(self,event): |
Kurt B. Kaiser | 0539169 | 2003-05-26 20:35:53 +0000 | [diff] [blame] | 843 | font = self.listFontName.get(ANCHOR) |
| 844 | self.fontName.set(font.lower()) |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 845 | self.SetFontSample() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 846 | |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 847 | def SetFontSample(self,event=None): |
| 848 | fontName=self.fontName.get() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 849 | if self.fontBold.get(): |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 850 | fontWeight=tkFont.BOLD |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 851 | else: |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 852 | fontWeight=tkFont.NORMAL |
| 853 | self.editFont.config(size=self.fontSize.get(), |
| 854 | weight=fontWeight,family=fontName) |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 855 | |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 856 | def SetHighlightTarget(self): |
| 857 | if self.highlightTarget.get()=='Cursor': #bg not possible |
| 858 | self.radioFg.config(state=DISABLED) |
| 859 | self.radioBg.config(state=DISABLED) |
| 860 | self.fgHilite.set(1) |
| 861 | else: #both fg and bg can be set |
| 862 | self.radioFg.config(state=NORMAL) |
| 863 | self.radioBg.config(state=NORMAL) |
| 864 | self.fgHilite.set(1) |
| 865 | self.SetColourSample() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 866 | |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 867 | def SetColourSampleBinding(self,*args): |
| 868 | self.SetColourSample() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 869 | |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 870 | def SetColourSample(self): |
| 871 | #set the colour smaple area |
| 872 | tag=self.themeElements[self.highlightTarget.get()][0] |
| 873 | if self.fgHilite.get(): plane='foreground' |
| 874 | else: plane='background' |
| 875 | colour=self.textHighlightSample.tag_cget(tag,plane) |
| 876 | self.frameColourSet.config(bg=colour) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 877 | |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 878 | def PaintThemeSample(self): |
Steven M. Gava | d0342cd | 2001-11-04 11:53:10 +0000 | [diff] [blame] | 879 | if self.themeIsBuiltin.get(): #a default theme |
Steven M. Gava | 9930061 | 2001-11-04 07:03:08 +0000 | [diff] [blame] | 880 | theme=self.builtinTheme.get() |
| 881 | else: #a user theme |
| 882 | theme=self.customTheme.get() |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 883 | for elementTitle in self.themeElements.keys(): |
| 884 | element=self.themeElements[elementTitle][0] |
| 885 | colours=idleConf.GetHighlight(theme,element) |
| 886 | if element=='cursor': #cursor sample needs special painting |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 887 | colours['background']=idleConf.GetHighlight(theme, |
Steven M. Gava | 0cae01c | 2002-01-04 07:53:06 +0000 | [diff] [blame] | 888 | 'normal', fgBg='bg') |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 889 | #handle any unsaved changes to this theme |
| 890 | if theme in self.changedItems['highlight'].keys(): |
| 891 | themeDict=self.changedItems['highlight'][theme] |
| 892 | if themeDict.has_key(element+'-foreground'): |
| 893 | colours['foreground']=themeDict[element+'-foreground'] |
| 894 | if themeDict.has_key(element+'-background'): |
| 895 | colours['background']=themeDict[element+'-background'] |
Raymond Hettinger | 931237e | 2003-07-09 18:48:24 +0000 | [diff] [blame] | 896 | self.textHighlightSample.tag_config(element, **colours) |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 897 | self.SetColourSample() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 898 | |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 899 | ## def OnCheckUserHelpBrowser(self): |
| 900 | ## if self.userHelpBrowser.get(): |
| 901 | ## self.entryHelpBrowser.config(state=NORMAL) |
| 902 | ## else: |
| 903 | ## self.entryHelpBrowser.config(state=DISABLED) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 904 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 905 | def HelpSourceSelected(self,event): |
| 906 | self.SetHelpListButtonStates() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 907 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 908 | def SetHelpListButtonStates(self): |
| 909 | if self.listHelp.size()<1: #no entries in list |
| 910 | self.buttonHelpListEdit.config(state=DISABLED) |
| 911 | self.buttonHelpListRemove.config(state=DISABLED) |
| 912 | else: #there are some entries |
| 913 | if self.listHelp.curselection(): #there currently is a selection |
| 914 | self.buttonHelpListEdit.config(state=NORMAL) |
| 915 | self.buttonHelpListRemove.config(state=NORMAL) |
| 916 | else: #there currently is not a selection |
| 917 | self.buttonHelpListEdit.config(state=DISABLED) |
| 918 | self.buttonHelpListRemove.config(state=DISABLED) |
| 919 | |
| 920 | def HelpListItemAdd(self): |
| 921 | helpSource=GetHelpSourceDialog(self,'New Help Source').result |
| 922 | if helpSource: |
| 923 | self.userHelpList.append( (helpSource[0],helpSource[1]) ) |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 924 | self.listHelp.insert(END,helpSource[0]) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 925 | self.UpdateUserHelpChangedItems() |
| 926 | self.SetHelpListButtonStates() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 927 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 928 | def HelpListItemEdit(self): |
| 929 | itemIndex=self.listHelp.index(ANCHOR) |
| 930 | helpSource=self.userHelpList[itemIndex] |
Steven M. Gava | 0c5bc8c | 2002-03-27 02:25:44 +0000 | [diff] [blame] | 931 | newHelpSource=GetHelpSourceDialog(self,'Edit Help Source', |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 932 | menuItem=helpSource[0],filePath=helpSource[1]).result |
| 933 | if (not newHelpSource) or (newHelpSource==helpSource): |
| 934 | return #no changes |
| 935 | self.userHelpList[itemIndex]=newHelpSource |
| 936 | self.listHelp.delete(itemIndex) |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 937 | self.listHelp.insert(itemIndex,newHelpSource[0]) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 938 | self.UpdateUserHelpChangedItems() |
| 939 | self.SetHelpListButtonStates() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 940 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 941 | def HelpListItemRemove(self): |
| 942 | itemIndex=self.listHelp.index(ANCHOR) |
| 943 | del(self.userHelpList[itemIndex]) |
| 944 | self.listHelp.delete(itemIndex) |
| 945 | self.UpdateUserHelpChangedItems() |
| 946 | self.SetHelpListButtonStates() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 947 | |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 948 | def UpdateUserHelpChangedItems(self): |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 949 | "Clear and rebuild the HelpFiles section in self.changedItems" |
| 950 | self.changedItems['main']['HelpFiles'] = {} |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 951 | for num in range(1,len(self.userHelpList)+1): |
| 952 | self.AddChangedItem('main','HelpFiles',str(num), |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 953 | string.join(self.userHelpList[num-1][:2],';')) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 954 | |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 955 | def LoadFontCfg(self): |
| 956 | ##base editor font selection list |
Steven M. Gava | c11ccf3 | 2001-09-24 09:43:17 +0000 | [diff] [blame] | 957 | fonts=list(tkFont.families(self)) |
| 958 | fonts.sort() |
| 959 | for font in fonts: |
| 960 | self.listFontName.insert(END,font) |
Steven M. Gava | 485f7b6 | 2001-10-26 06:47:09 +0000 | [diff] [blame] | 961 | configuredFont=idleConf.GetOption('main','EditorWindow','font', |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 962 | default='courier') |
Kurt B. Kaiser | 0539169 | 2003-05-26 20:35:53 +0000 | [diff] [blame] | 963 | lc_configuredFont = configuredFont.lower() |
| 964 | self.fontName.set(lc_configuredFont) |
| 965 | lc_fonts = [s.lower() for s in fonts] |
| 966 | if lc_configuredFont in lc_fonts: |
| 967 | currentFontIndex = lc_fonts.index(lc_configuredFont) |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 968 | self.listFontName.see(currentFontIndex) |
| 969 | self.listFontName.select_set(currentFontIndex) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 970 | self.listFontName.select_anchor(currentFontIndex) |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 971 | ##font size dropdown |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 972 | fontSize=idleConf.GetOption('main','EditorWindow','font-size', |
Kurt B. Kaiser | 0539169 | 2003-05-26 20:35:53 +0000 | [diff] [blame] | 973 | default='10') |
Chui Tey | a178cff | 2002-11-04 03:17:45 +0000 | [diff] [blame] | 974 | self.optMenuFontSize.SetMenu(('7','8','9','10','11','12','13','14', |
Steven M. Gava | 485f7b6 | 2001-10-26 06:47:09 +0000 | [diff] [blame] | 975 | '16','18','20','22'),fontSize ) |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 976 | ##fontWeight |
| 977 | self.fontBold.set(idleConf.GetOption('main','EditorWindow', |
| 978 | 'font-bold',default=0,type='bool')) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 979 | ##font sample |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 980 | self.SetFontSample() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 981 | |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 982 | def LoadTabCfg(self): |
Steven M. Gava | 63f6714 | 2002-03-12 00:52:42 +0000 | [diff] [blame] | 983 | ##indent type radiobuttons |
Steven M. Gava | 485f7b6 | 2001-10-26 06:47:09 +0000 | [diff] [blame] | 984 | spaceIndent=idleConf.GetOption('main','Indent','use-spaces', |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 985 | default=1,type='bool') |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 986 | self.indentBySpaces.set(spaceIndent) |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 987 | ##indent sizes |
Steven M. Gava | 485f7b6 | 2001-10-26 06:47:09 +0000 | [diff] [blame] | 988 | spaceNum=idleConf.GetOption('main','Indent','num-spaces', |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 989 | default=4,type='int') |
Steven M. Gava | 63f6714 | 2002-03-12 00:52:42 +0000 | [diff] [blame] | 990 | #tabCols=idleConf.GetOption('main','Indent','tab-cols', |
| 991 | # default=4,type='int') |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 992 | self.spaceNum.set(spaceNum) |
Steven M. Gava | 63f6714 | 2002-03-12 00:52:42 +0000 | [diff] [blame] | 993 | #self.tabCols.set(tabCols) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 994 | |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 995 | def LoadThemeCfg(self): |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 996 | ##current theme type radiobutton |
Steven M. Gava | d0342cd | 2001-11-04 11:53:10 +0000 | [diff] [blame] | 997 | self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default', |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 998 | type='bool',default=1)) |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 999 | ##currently set theme |
Steven M. Gava | ad4f532 | 2002-01-03 12:05:17 +0000 | [diff] [blame] | 1000 | currentOption=idleConf.CurrentTheme() |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 1001 | ##load available theme option menus |
Steven M. Gava | d0342cd | 2001-11-04 11:53:10 +0000 | [diff] [blame] | 1002 | if self.themeIsBuiltin.get(): #default theme selected |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1003 | itemList=idleConf.GetSectionList('default','highlight') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 1004 | itemList.sort() |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1005 | self.optMenuThemeBuiltin.SetMenu(itemList,currentOption) |
| 1006 | itemList=idleConf.GetSectionList('user','highlight') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 1007 | itemList.sort() |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1008 | if not itemList: |
| 1009 | self.radioThemeCustom.config(state=DISABLED) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1010 | self.customTheme.set('- no custom themes -') |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1011 | else: |
| 1012 | self.optMenuThemeCustom.SetMenu(itemList,itemList[0]) |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 1013 | else: #user theme selected |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1014 | itemList=idleConf.GetSectionList('user','highlight') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 1015 | itemList.sort() |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1016 | self.optMenuThemeCustom.SetMenu(itemList,currentOption) |
| 1017 | itemList=idleConf.GetSectionList('default','highlight') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 1018 | itemList.sort() |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1019 | self.optMenuThemeBuiltin.SetMenu(itemList,itemList[0]) |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 1020 | self.SetThemeType() |
| 1021 | ##load theme element option menu |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 1022 | themeNames=self.themeElements.keys() |
| 1023 | themeNames.sort(self.__ThemeNameIndexCompare) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1024 | self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0]) |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 1025 | self.PaintThemeSample() |
Steven M. Gava | 0cae01c | 2002-01-04 07:53:06 +0000 | [diff] [blame] | 1026 | self.SetHighlightTarget() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1027 | |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 1028 | def __ThemeNameIndexCompare(self,a,b): |
| 1029 | if self.themeElements[a][1]<self.themeElements[b][1]: return -1 |
| 1030 | elif self.themeElements[a][1]==self.themeElements[b][1]: return 0 |
| 1031 | else: return 1 |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1032 | |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 1033 | def LoadKeyCfg(self): |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1034 | ##current keys type radiobutton |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 1035 | self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default', |
Steven M. Gava | c112cd8 | 2002-01-22 05:56:40 +0000 | [diff] [blame] | 1036 | type='bool',default=1)) |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1037 | ##currently set keys |
Steven M. Gava | ad4f532 | 2002-01-03 12:05:17 +0000 | [diff] [blame] | 1038 | currentOption=idleConf.CurrentKeys() |
Steven M. Gava | 7c01786 | 2001-10-29 11:19:46 +0000 | [diff] [blame] | 1039 | ##load available keyset option menus |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 1040 | if self.keysAreBuiltin.get(): #default theme selected |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1041 | itemList=idleConf.GetSectionList('default','keys') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 1042 | itemList.sort() |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1043 | self.optMenuKeysBuiltin.SetMenu(itemList,currentOption) |
| 1044 | itemList=idleConf.GetSectionList('user','keys') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 1045 | itemList.sort() |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1046 | if not itemList: |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1047 | self.radioKeysCustom.config(state=DISABLED) |
| 1048 | self.customKeys.set('- no custom keys -') |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1049 | else: |
| 1050 | self.optMenuKeysCustom.SetMenu(itemList,itemList[0]) |
Steven M. Gava | a498af2 | 2002-02-01 01:33:36 +0000 | [diff] [blame] | 1051 | else: #user key set selected |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1052 | itemList=idleConf.GetSectionList('user','keys') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 1053 | itemList.sort() |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1054 | self.optMenuKeysCustom.SetMenu(itemList,currentOption) |
| 1055 | itemList=idleConf.GetSectionList('default','keys') |
Steven M. Gava | f9bb90e | 2002-01-24 06:02:50 +0000 | [diff] [blame] | 1056 | itemList.sort() |
Steven M. Gava | 41a8532 | 2001-10-29 08:05:34 +0000 | [diff] [blame] | 1057 | self.optMenuKeysBuiltin.SetMenu(itemList,itemList[0]) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1058 | self.SetKeysType() |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 1059 | ##load keyset element list |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 1060 | keySetName=idleConf.CurrentKeys() |
| 1061 | self.LoadKeysList(keySetName) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1062 | |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 1063 | def LoadGeneralCfg(self): |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 1064 | #startup state |
| 1065 | self.startupEdit.set(idleConf.GetOption('main','General', |
| 1066 | 'editor-on-startup',default=1,type='bool')) |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 1067 | #autosave state |
| 1068 | self.autoSave.set(idleConf.GetOption('main', 'General', 'autosave', |
| 1069 | default=0, type='bool')) |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 1070 | #initial window size |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1071 | self.winWidth.set(idleConf.GetOption('main','EditorWindow','width')) |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 1072 | self.winHeight.set(idleConf.GetOption('main','EditorWindow','height')) |
Kurt B. Kaiser | a053f33 | 2003-05-10 00:49:56 +0000 | [diff] [blame] | 1073 | # default source encoding |
Kurt B. Kaiser | 6c638b6 | 2003-05-26 06:23:10 +0000 | [diff] [blame] | 1074 | self.encoding.set(idleConf.GetOption('main', 'EditorWindow', |
| 1075 | 'encoding', default='none')) |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 1076 | # additional help sources |
| 1077 | self.userHelpList = idleConf.GetAllExtraHelpSourcesList() |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 1078 | for helpItem in self.userHelpList: |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 1079 | self.listHelp.insert(END,helpItem[0]) |
Steven M. Gava | 085eb1b | 2002-02-05 04:52:32 +0000 | [diff] [blame] | 1080 | self.SetHelpListButtonStates() |
Steven M. Gava | 0c5bc8c | 2002-03-27 02:25:44 +0000 | [diff] [blame] | 1081 | #self.userHelpBrowser.set(idleConf.GetOption('main','General', |
| 1082 | # 'user-help-browser',default=0,type='bool')) |
| 1083 | #self.helpBrowser.set(idleConf.GetOption('main','General', |
| 1084 | # 'user-help-browser-command',default='')) |
| 1085 | #self.OnCheckUserHelpBrowser() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1086 | |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 1087 | def LoadConfigs(self): |
| 1088 | """ |
| 1089 | load configuration from default and user config files and populate |
| 1090 | the widgets on the config dialog pages. |
| 1091 | """ |
| 1092 | ### fonts / tabs page |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1093 | self.LoadFontCfg() |
| 1094 | self.LoadTabCfg() |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 1095 | ### highlighting page |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 1096 | self.LoadThemeCfg() |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 1097 | ### keys page |
Steven M. Gava | 9dd16b3 | 2001-11-03 14:54:25 +0000 | [diff] [blame] | 1098 | self.LoadKeyCfg() |
Steven M. Gava | 429a86af | 2001-10-23 10:42:12 +0000 | [diff] [blame] | 1099 | ### general page |
Steven M. Gava | facfc09 | 2002-01-19 00:29:54 +0000 | [diff] [blame] | 1100 | self.LoadGeneralCfg() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1101 | |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 1102 | def SaveNewKeySet(self,keySetName,keySet): |
| 1103 | """ |
| 1104 | save a newly created core key set. |
| 1105 | keySetName - string, the name of the new key set |
| 1106 | keySet - dictionary containing the new key set |
| 1107 | """ |
| 1108 | if not idleConf.userCfg['keys'].has_section(keySetName): |
| 1109 | idleConf.userCfg['keys'].add_section(keySetName) |
| 1110 | for event in keySet.keys(): |
| 1111 | value=keySet[event] |
| 1112 | idleConf.userCfg['keys'].SetOption(keySetName,event,value) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1113 | |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 1114 | def SaveNewTheme(self,themeName,theme): |
| 1115 | """ |
| 1116 | save a newly created theme. |
| 1117 | themeName - string, the name of the new theme |
| 1118 | theme - dictionary containing the new theme |
| 1119 | """ |
| 1120 | if not idleConf.userCfg['highlight'].has_section(themeName): |
| 1121 | idleConf.userCfg['highlight'].add_section(themeName) |
| 1122 | for element in theme.keys(): |
| 1123 | value=theme[element] |
| 1124 | idleConf.userCfg['highlight'].SetOption(themeName,element,value) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1125 | |
Steven M. Gava | 2d7bb3f | 2002-01-29 08:35:29 +0000 | [diff] [blame] | 1126 | def SetUserValue(self,configType,section,item,value): |
Steven M. Gava | 2d7bb3f | 2002-01-29 08:35:29 +0000 | [diff] [blame] | 1127 | if idleConf.defaultCfg[configType].has_option(section,item): |
| 1128 | if idleConf.defaultCfg[configType].Get(section,item)==value: |
| 1129 | #the setting equals a default setting, remove it from user cfg |
| 1130 | return idleConf.userCfg[configType].RemoveOption(section,item) |
| 1131 | #if we got here set the option |
| 1132 | return idleConf.userCfg[configType].SetOption(section,item,value) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1133 | |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 1134 | def SaveAllChangedConfigs(self): |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 1135 | "Save configuration changes to the user config file." |
Steven M. Gava | 0c5bc8c | 2002-03-27 02:25:44 +0000 | [diff] [blame] | 1136 | idleConf.userCfg['main'].Save() |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 1137 | for configType in self.changedItems.keys(): |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 1138 | cfgTypeHasChanges = False |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 1139 | for section in self.changedItems[configType].keys(): |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 1140 | if section == 'HelpFiles': |
| 1141 | #this section gets completely replaced |
| 1142 | idleConf.userCfg['main'].remove_section('HelpFiles') |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 1143 | cfgTypeHasChanges = True |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 1144 | for item in self.changedItems[configType][section].keys(): |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 1145 | value = self.changedItems[configType][section][item] |
Steven M. Gava | 2d7bb3f | 2002-01-29 08:35:29 +0000 | [diff] [blame] | 1146 | if self.SetUserValue(configType,section,item,value): |
Kurt B. Kaiser | e7a161e | 2003-01-10 20:13:57 +0000 | [diff] [blame] | 1147 | cfgTypeHasChanges = True |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1148 | if cfgTypeHasChanges: |
| 1149 | idleConf.userCfg[configType].Save() |
Steven M. Gava | a498af2 | 2002-02-01 01:33:36 +0000 | [diff] [blame] | 1150 | self.ResetChangedItems() #clear the changed items dict |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1151 | |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 1152 | def ActivateConfigChanges(self): |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1153 | #things that need to be done to make |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 1154 | #applied config changes dynamic: |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 1155 | #update editor/shell font and repaint |
| 1156 | #dynamically update indentation setttings |
| 1157 | #update theme and repaint |
| 1158 | #update keybindings and re-bind |
| 1159 | #update user help sources menu |
Steven M. Gava | b77d343 | 2002-03-02 07:16:21 +0000 | [diff] [blame] | 1160 | winInstances=self.parent.instanceDict.keys() |
| 1161 | for instance in winInstances: |
| 1162 | instance.ResetColorizer() |
Steven M. Gava | b158541 | 2002-03-12 00:21:56 +0000 | [diff] [blame] | 1163 | instance.ResetFont() |
Steven M. Gava | dbfe92c | 2002-03-18 02:38:44 +0000 | [diff] [blame] | 1164 | instance.ResetKeybindings() |
Kurt B. Kaiser | 8e92bf7 | 2003-01-14 22:03:31 +0000 | [diff] [blame] | 1165 | instance.reset_help_menu_entries() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 1166 | |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 1167 | def Cancel(self): |
| 1168 | self.destroy() |
| 1169 | |
| 1170 | def Ok(self): |
| 1171 | self.Apply() |
| 1172 | self.destroy() |
| 1173 | |
| 1174 | def Apply(self): |
Steven M. Gava | 052937f | 2002-02-11 02:20:53 +0000 | [diff] [blame] | 1175 | self.SaveAllChangedConfigs() |
Steven M. Gava | 4974575 | 2002-02-18 01:43:11 +0000 | [diff] [blame] | 1176 | self.ActivateConfigChanges() |
Steven M. Gava | 5f28e8f | 2002-01-21 06:38:21 +0000 | [diff] [blame] | 1177 | |
| 1178 | def Help(self): |
Steven M. Gava | c11ccf3 | 2001-09-24 09:43:17 +0000 | [diff] [blame] | 1179 | pass |
| 1180 | |
Steven M. Gava | 44d3d1a | 2001-07-31 06:59:02 +0000 | [diff] [blame] | 1181 | if __name__ == '__main__': |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 1182 | #test the dialog |
| 1183 | root=Tk() |
| 1184 | Button(root,text='Dialog', |
Steven M. Gava | 3b55a89 | 2001-11-21 05:56:26 +0000 | [diff] [blame] | 1185 | command=lambda:ConfigDialog(root,'Settings')).pack() |
Steven M. Gava | f31eec0 | 2002-03-05 00:25:58 +0000 | [diff] [blame] | 1186 | root.instanceDict={} |
Steven M. Gava | d721c48 | 2001-07-31 10:46:53 +0000 | [diff] [blame] | 1187 | root.mainloop() |