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