1 | n/a | """IDLE Configuration Dialog: support user customization of IDLE by GUI |
---|
2 | n/a | |
---|
3 | n/a | Customize font faces, sizes, and colorization attributes. Set indentation |
---|
4 | n/a | defaults. Customize keybindings. Colorization and keybindings can be |
---|
5 | n/a | saved as user defined sets. Select startup options including shell/editor |
---|
6 | n/a | and default window size. Define additional help sources. |
---|
7 | n/a | |
---|
8 | n/a | Note that tab width in IDLE is currently fixed at eight due to Tk issues. |
---|
9 | n/a | Refer to comments in EditorWindow autoindent code for details. |
---|
10 | n/a | |
---|
11 | n/a | """ |
---|
12 | n/a | from tkinter import * |
---|
13 | n/a | from tkinter.ttk import Scrollbar |
---|
14 | n/a | import tkinter.colorchooser as tkColorChooser |
---|
15 | n/a | import tkinter.font as tkFont |
---|
16 | n/a | import tkinter.messagebox as tkMessageBox |
---|
17 | n/a | |
---|
18 | n/a | from idlelib.config import idleConf |
---|
19 | n/a | from idlelib.config_key import GetKeysDialog |
---|
20 | n/a | from idlelib.dynoption import DynOptionMenu |
---|
21 | n/a | from idlelib import macosx |
---|
22 | n/a | from idlelib.query import SectionName, HelpSource |
---|
23 | n/a | from idlelib.tabbedpages import TabbedPageSet |
---|
24 | n/a | from idlelib.textview import view_text |
---|
25 | n/a | |
---|
26 | n/a | class ConfigDialog(Toplevel): |
---|
27 | n/a | |
---|
28 | n/a | def __init__(self, parent, title='', _htest=False, _utest=False): |
---|
29 | n/a | """ |
---|
30 | n/a | _htest - bool, change box location when running htest |
---|
31 | n/a | _utest - bool, don't wait_window when running unittest |
---|
32 | n/a | """ |
---|
33 | n/a | Toplevel.__init__(self, parent) |
---|
34 | n/a | self.parent = parent |
---|
35 | n/a | if _htest: |
---|
36 | n/a | parent.instance_dict = {} |
---|
37 | n/a | self.wm_withdraw() |
---|
38 | n/a | |
---|
39 | n/a | self.configure(borderwidth=5) |
---|
40 | n/a | self.title(title or 'IDLE Preferences') |
---|
41 | n/a | self.geometry( |
---|
42 | n/a | "+%d+%d" % (parent.winfo_rootx() + 20, |
---|
43 | n/a | parent.winfo_rooty() + (30 if not _htest else 150))) |
---|
44 | n/a | #Theme Elements. Each theme element key is its display name. |
---|
45 | n/a | #The first value of the tuple is the sample area tag name. |
---|
46 | n/a | #The second value is the display name list sort index. |
---|
47 | n/a | self.themeElements={ |
---|
48 | n/a | 'Normal Text': ('normal', '00'), |
---|
49 | n/a | 'Python Keywords': ('keyword', '01'), |
---|
50 | n/a | 'Python Definitions': ('definition', '02'), |
---|
51 | n/a | 'Python Builtins': ('builtin', '03'), |
---|
52 | n/a | 'Python Comments': ('comment', '04'), |
---|
53 | n/a | 'Python Strings': ('string', '05'), |
---|
54 | n/a | 'Selected Text': ('hilite', '06'), |
---|
55 | n/a | 'Found Text': ('hit', '07'), |
---|
56 | n/a | 'Cursor': ('cursor', '08'), |
---|
57 | n/a | 'Editor Breakpoint': ('break', '09'), |
---|
58 | n/a | 'Shell Normal Text': ('console', '10'), |
---|
59 | n/a | 'Shell Error Text': ('error', '11'), |
---|
60 | n/a | 'Shell Stdout Text': ('stdout', '12'), |
---|
61 | n/a | 'Shell Stderr Text': ('stderr', '13'), |
---|
62 | n/a | } |
---|
63 | n/a | self.ResetChangedItems() #load initial values in changed items dict |
---|
64 | n/a | self.CreateWidgets() |
---|
65 | n/a | self.resizable(height=FALSE, width=FALSE) |
---|
66 | n/a | self.transient(parent) |
---|
67 | n/a | self.grab_set() |
---|
68 | n/a | self.protocol("WM_DELETE_WINDOW", self.Cancel) |
---|
69 | n/a | self.tabPages.focus_set() |
---|
70 | n/a | #key bindings for this dialog |
---|
71 | n/a | #self.bind('<Escape>', self.Cancel) #dismiss dialog, no save |
---|
72 | n/a | #self.bind('<Alt-a>', self.Apply) #apply changes, save |
---|
73 | n/a | #self.bind('<F1>', self.Help) #context help |
---|
74 | n/a | self.LoadConfigs() |
---|
75 | n/a | self.AttachVarCallbacks() #avoid callbacks during LoadConfigs |
---|
76 | n/a | |
---|
77 | n/a | if not _utest: |
---|
78 | n/a | self.wm_deiconify() |
---|
79 | n/a | self.wait_window() |
---|
80 | n/a | |
---|
81 | n/a | def CreateWidgets(self): |
---|
82 | n/a | self.tabPages = TabbedPageSet(self, |
---|
83 | n/a | page_names=['Fonts/Tabs', 'Highlighting', 'Keys', 'General', |
---|
84 | n/a | 'Extensions']) |
---|
85 | n/a | self.tabPages.pack(side=TOP, expand=TRUE, fill=BOTH) |
---|
86 | n/a | self.CreatePageFontTab() |
---|
87 | n/a | self.CreatePageHighlight() |
---|
88 | n/a | self.CreatePageKeys() |
---|
89 | n/a | self.CreatePageGeneral() |
---|
90 | n/a | self.CreatePageExtensions() |
---|
91 | n/a | self.create_action_buttons().pack(side=BOTTOM) |
---|
92 | n/a | |
---|
93 | n/a | def create_action_buttons(self): |
---|
94 | n/a | if macosx.isAquaTk(): |
---|
95 | n/a | # Changing the default padding on OSX results in unreadable |
---|
96 | n/a | # text in the buttons |
---|
97 | n/a | paddingArgs = {} |
---|
98 | n/a | else: |
---|
99 | n/a | paddingArgs = {'padx':6, 'pady':3} |
---|
100 | n/a | outer = Frame(self, pady=2) |
---|
101 | n/a | buttons = Frame(outer, pady=2) |
---|
102 | n/a | for txt, cmd in ( |
---|
103 | n/a | ('Ok', self.Ok), |
---|
104 | n/a | ('Apply', self.Apply), |
---|
105 | n/a | ('Cancel', self.Cancel), |
---|
106 | n/a | ('Help', self.Help)): |
---|
107 | n/a | Button(buttons, text=txt, command=cmd, takefocus=FALSE, |
---|
108 | n/a | **paddingArgs).pack(side=LEFT, padx=5) |
---|
109 | n/a | # add space above buttons |
---|
110 | n/a | Frame(outer, height=2, borderwidth=0).pack(side=TOP) |
---|
111 | n/a | buttons.pack(side=BOTTOM) |
---|
112 | n/a | return outer |
---|
113 | n/a | |
---|
114 | n/a | def CreatePageFontTab(self): |
---|
115 | n/a | parent = self.parent |
---|
116 | n/a | self.fontSize = StringVar(parent) |
---|
117 | n/a | self.fontBold = BooleanVar(parent) |
---|
118 | n/a | self.fontName = StringVar(parent) |
---|
119 | n/a | self.spaceNum = IntVar(parent) |
---|
120 | n/a | self.editFont = tkFont.Font(parent, ('courier', 10, 'normal')) |
---|
121 | n/a | |
---|
122 | n/a | ##widget creation |
---|
123 | n/a | #body frame |
---|
124 | n/a | frame = self.tabPages.pages['Fonts/Tabs'].frame |
---|
125 | n/a | #body section frames |
---|
126 | n/a | frameFont = LabelFrame( |
---|
127 | n/a | frame, borderwidth=2, relief=GROOVE, text=' Base Editor Font ') |
---|
128 | n/a | frameIndent = LabelFrame( |
---|
129 | n/a | frame, borderwidth=2, relief=GROOVE, text=' Indentation Width ') |
---|
130 | n/a | #frameFont |
---|
131 | n/a | frameFontName = Frame(frameFont) |
---|
132 | n/a | frameFontParam = Frame(frameFont) |
---|
133 | n/a | labelFontNameTitle = Label( |
---|
134 | n/a | frameFontName, justify=LEFT, text='Font Face :') |
---|
135 | n/a | self.listFontName = Listbox( |
---|
136 | n/a | frameFontName, height=5, takefocus=FALSE, exportselection=FALSE) |
---|
137 | n/a | self.listFontName.bind( |
---|
138 | n/a | '<ButtonRelease-1>', self.OnListFontButtonRelease) |
---|
139 | n/a | scrollFont = Scrollbar(frameFontName) |
---|
140 | n/a | scrollFont.config(command=self.listFontName.yview) |
---|
141 | n/a | self.listFontName.config(yscrollcommand=scrollFont.set) |
---|
142 | n/a | labelFontSizeTitle = Label(frameFontParam, text='Size :') |
---|
143 | n/a | self.optMenuFontSize = DynOptionMenu( |
---|
144 | n/a | frameFontParam, self.fontSize, None, command=self.SetFontSample) |
---|
145 | n/a | checkFontBold = Checkbutton( |
---|
146 | n/a | frameFontParam, variable=self.fontBold, onvalue=1, |
---|
147 | n/a | offvalue=0, text='Bold', command=self.SetFontSample) |
---|
148 | n/a | frameFontSample = Frame(frameFont, relief=SOLID, borderwidth=1) |
---|
149 | n/a | self.labelFontSample = Label( |
---|
150 | n/a | frameFontSample, justify=LEFT, font=self.editFont, |
---|
151 | n/a | text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]') |
---|
152 | n/a | #frameIndent |
---|
153 | n/a | frameIndentSize = Frame(frameIndent) |
---|
154 | n/a | labelSpaceNumTitle = Label( |
---|
155 | n/a | frameIndentSize, justify=LEFT, |
---|
156 | n/a | text='Python Standard: 4 Spaces!') |
---|
157 | n/a | self.scaleSpaceNum = Scale( |
---|
158 | n/a | frameIndentSize, variable=self.spaceNum, |
---|
159 | n/a | orient='horizontal', tickinterval=2, from_=2, to=16) |
---|
160 | n/a | |
---|
161 | n/a | #widget packing |
---|
162 | n/a | #body |
---|
163 | n/a | frameFont.pack(side=LEFT, padx=5, pady=5, expand=TRUE, fill=BOTH) |
---|
164 | n/a | frameIndent.pack(side=LEFT, padx=5, pady=5, fill=Y) |
---|
165 | n/a | #frameFont |
---|
166 | n/a | frameFontName.pack(side=TOP, padx=5, pady=5, fill=X) |
---|
167 | n/a | frameFontParam.pack(side=TOP, padx=5, pady=5, fill=X) |
---|
168 | n/a | labelFontNameTitle.pack(side=TOP, anchor=W) |
---|
169 | n/a | self.listFontName.pack(side=LEFT, expand=TRUE, fill=X) |
---|
170 | n/a | scrollFont.pack(side=LEFT, fill=Y) |
---|
171 | n/a | labelFontSizeTitle.pack(side=LEFT, anchor=W) |
---|
172 | n/a | self.optMenuFontSize.pack(side=LEFT, anchor=W) |
---|
173 | n/a | checkFontBold.pack(side=LEFT, anchor=W, padx=20) |
---|
174 | n/a | frameFontSample.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH) |
---|
175 | n/a | self.labelFontSample.pack(expand=TRUE, fill=BOTH) |
---|
176 | n/a | #frameIndent |
---|
177 | n/a | frameIndentSize.pack(side=TOP, fill=X) |
---|
178 | n/a | labelSpaceNumTitle.pack(side=TOP, anchor=W, padx=5) |
---|
179 | n/a | self.scaleSpaceNum.pack(side=TOP, padx=5, fill=X) |
---|
180 | n/a | return frame |
---|
181 | n/a | |
---|
182 | n/a | def CreatePageHighlight(self): |
---|
183 | n/a | parent = self.parent |
---|
184 | n/a | self.builtinTheme = StringVar(parent) |
---|
185 | n/a | self.customTheme = StringVar(parent) |
---|
186 | n/a | self.fgHilite = BooleanVar(parent) |
---|
187 | n/a | self.colour = StringVar(parent) |
---|
188 | n/a | self.fontName = StringVar(parent) |
---|
189 | n/a | self.themeIsBuiltin = BooleanVar(parent) |
---|
190 | n/a | self.highlightTarget = StringVar(parent) |
---|
191 | n/a | |
---|
192 | n/a | ##widget creation |
---|
193 | n/a | #body frame |
---|
194 | n/a | frame = self.tabPages.pages['Highlighting'].frame |
---|
195 | n/a | #body section frames |
---|
196 | n/a | frameCustom = LabelFrame(frame, borderwidth=2, relief=GROOVE, |
---|
197 | n/a | text=' Custom Highlighting ') |
---|
198 | n/a | frameTheme = LabelFrame(frame, borderwidth=2, relief=GROOVE, |
---|
199 | n/a | text=' Highlighting Theme ') |
---|
200 | n/a | #frameCustom |
---|
201 | n/a | self.textHighlightSample=Text( |
---|
202 | n/a | frameCustom, relief=SOLID, borderwidth=1, |
---|
203 | n/a | font=('courier', 12, ''), cursor='hand2', width=21, height=11, |
---|
204 | n/a | takefocus=FALSE, highlightthickness=0, wrap=NONE) |
---|
205 | n/a | text=self.textHighlightSample |
---|
206 | n/a | text.bind('<Double-Button-1>', lambda e: 'break') |
---|
207 | n/a | text.bind('<B1-Motion>', lambda e: 'break') |
---|
208 | n/a | textAndTags=( |
---|
209 | n/a | ('#you can click here', 'comment'), ('\n', 'normal'), |
---|
210 | n/a | ('#to choose items', 'comment'), ('\n', 'normal'), |
---|
211 | n/a | ('def', 'keyword'), (' ', 'normal'), |
---|
212 | n/a | ('func', 'definition'), ('(param):\n ', 'normal'), |
---|
213 | n/a | ('"""string"""', 'string'), ('\n var0 = ', 'normal'), |
---|
214 | n/a | ("'string'", 'string'), ('\n var1 = ', 'normal'), |
---|
215 | n/a | ("'selected'", 'hilite'), ('\n var2 = ', 'normal'), |
---|
216 | n/a | ("'found'", 'hit'), ('\n var3 = ', 'normal'), |
---|
217 | n/a | ('list', 'builtin'), ('(', 'normal'), |
---|
218 | n/a | ('None', 'keyword'), (')\n', 'normal'), |
---|
219 | n/a | (' breakpoint("line")', 'break'), ('\n\n', 'normal'), |
---|
220 | n/a | (' error ', 'error'), (' ', 'normal'), |
---|
221 | n/a | ('cursor |', 'cursor'), ('\n ', 'normal'), |
---|
222 | n/a | ('shell', 'console'), (' ', 'normal'), |
---|
223 | n/a | ('stdout', 'stdout'), (' ', 'normal'), |
---|
224 | n/a | ('stderr', 'stderr'), ('\n', 'normal')) |
---|
225 | n/a | for txTa in textAndTags: |
---|
226 | n/a | text.insert(END, txTa[0], txTa[1]) |
---|
227 | n/a | for element in self.themeElements: |
---|
228 | n/a | def tem(event, elem=element): |
---|
229 | n/a | event.widget.winfo_toplevel().highlightTarget.set(elem) |
---|
230 | n/a | text.tag_bind( |
---|
231 | n/a | self.themeElements[element][0], '<ButtonPress-1>', tem) |
---|
232 | n/a | text.config(state=DISABLED) |
---|
233 | n/a | self.frameColourSet = Frame(frameCustom, relief=SOLID, borderwidth=1) |
---|
234 | n/a | frameFgBg = Frame(frameCustom) |
---|
235 | n/a | buttonSetColour = Button( |
---|
236 | n/a | self.frameColourSet, text='Choose Colour for :', |
---|
237 | n/a | command=self.GetColour, highlightthickness=0) |
---|
238 | n/a | self.optMenuHighlightTarget = DynOptionMenu( |
---|
239 | n/a | self.frameColourSet, self.highlightTarget, None, |
---|
240 | n/a | highlightthickness=0) #, command=self.SetHighlightTargetBinding |
---|
241 | n/a | self.radioFg = Radiobutton( |
---|
242 | n/a | frameFgBg, variable=self.fgHilite, value=1, |
---|
243 | n/a | text='Foreground', command=self.SetColourSampleBinding) |
---|
244 | n/a | self.radioBg=Radiobutton( |
---|
245 | n/a | frameFgBg, variable=self.fgHilite, value=0, |
---|
246 | n/a | text='Background', command=self.SetColourSampleBinding) |
---|
247 | n/a | self.fgHilite.set(1) |
---|
248 | n/a | buttonSaveCustomTheme = Button( |
---|
249 | n/a | frameCustom, text='Save as New Custom Theme', |
---|
250 | n/a | command=self.SaveAsNewTheme) |
---|
251 | n/a | #frameTheme |
---|
252 | n/a | labelTypeTitle = Label(frameTheme, text='Select : ') |
---|
253 | n/a | self.radioThemeBuiltin = Radiobutton( |
---|
254 | n/a | frameTheme, variable=self.themeIsBuiltin, value=1, |
---|
255 | n/a | command=self.SetThemeType, text='a Built-in Theme') |
---|
256 | n/a | self.radioThemeCustom = Radiobutton( |
---|
257 | n/a | frameTheme, variable=self.themeIsBuiltin, value=0, |
---|
258 | n/a | command=self.SetThemeType, text='a Custom Theme') |
---|
259 | n/a | self.optMenuThemeBuiltin = DynOptionMenu( |
---|
260 | n/a | frameTheme, self.builtinTheme, None, command=None) |
---|
261 | n/a | self.optMenuThemeCustom=DynOptionMenu( |
---|
262 | n/a | frameTheme, self.customTheme, None, command=None) |
---|
263 | n/a | self.buttonDeleteCustomTheme=Button( |
---|
264 | n/a | frameTheme, text='Delete Custom Theme', |
---|
265 | n/a | command=self.DeleteCustomTheme) |
---|
266 | n/a | self.new_custom_theme = Label(frameTheme, bd=2) |
---|
267 | n/a | |
---|
268 | n/a | ##widget packing |
---|
269 | n/a | #body |
---|
270 | n/a | frameCustom.pack(side=LEFT, padx=5, pady=5, expand=TRUE, fill=BOTH) |
---|
271 | n/a | frameTheme.pack(side=LEFT, padx=5, pady=5, fill=Y) |
---|
272 | n/a | #frameCustom |
---|
273 | n/a | self.frameColourSet.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=X) |
---|
274 | n/a | frameFgBg.pack(side=TOP, padx=5, pady=0) |
---|
275 | n/a | self.textHighlightSample.pack( |
---|
276 | n/a | side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH) |
---|
277 | n/a | buttonSetColour.pack(side=TOP, expand=TRUE, fill=X, padx=8, pady=4) |
---|
278 | n/a | self.optMenuHighlightTarget.pack( |
---|
279 | n/a | side=TOP, expand=TRUE, fill=X, padx=8, pady=3) |
---|
280 | n/a | self.radioFg.pack(side=LEFT, anchor=E) |
---|
281 | n/a | self.radioBg.pack(side=RIGHT, anchor=W) |
---|
282 | n/a | buttonSaveCustomTheme.pack(side=BOTTOM, fill=X, padx=5, pady=5) |
---|
283 | n/a | #frameTheme |
---|
284 | n/a | labelTypeTitle.pack(side=TOP, anchor=W, padx=5, pady=5) |
---|
285 | n/a | self.radioThemeBuiltin.pack(side=TOP, anchor=W, padx=5) |
---|
286 | n/a | self.radioThemeCustom.pack(side=TOP, anchor=W, padx=5, pady=2) |
---|
287 | n/a | self.optMenuThemeBuiltin.pack(side=TOP, fill=X, padx=5, pady=5) |
---|
288 | n/a | self.optMenuThemeCustom.pack(side=TOP, fill=X, anchor=W, padx=5, pady=5) |
---|
289 | n/a | self.buttonDeleteCustomTheme.pack(side=TOP, fill=X, padx=5, pady=5) |
---|
290 | n/a | self.new_custom_theme.pack(side=TOP, fill=X, pady=5) |
---|
291 | n/a | return frame |
---|
292 | n/a | |
---|
293 | n/a | def CreatePageKeys(self): |
---|
294 | n/a | parent = self.parent |
---|
295 | n/a | self.bindingTarget = StringVar(parent) |
---|
296 | n/a | self.builtinKeys = StringVar(parent) |
---|
297 | n/a | self.customKeys = StringVar(parent) |
---|
298 | n/a | self.keysAreBuiltin = BooleanVar(parent) |
---|
299 | n/a | self.keyBinding = StringVar(parent) |
---|
300 | n/a | |
---|
301 | n/a | ##widget creation |
---|
302 | n/a | #body frame |
---|
303 | n/a | frame = self.tabPages.pages['Keys'].frame |
---|
304 | n/a | #body section frames |
---|
305 | n/a | frameCustom = LabelFrame( |
---|
306 | n/a | frame, borderwidth=2, relief=GROOVE, |
---|
307 | n/a | text=' Custom Key Bindings ') |
---|
308 | n/a | frameKeySets = LabelFrame( |
---|
309 | n/a | frame, borderwidth=2, relief=GROOVE, text=' Key Set ') |
---|
310 | n/a | #frameCustom |
---|
311 | n/a | frameTarget = Frame(frameCustom) |
---|
312 | n/a | labelTargetTitle = Label(frameTarget, text='Action - Key(s)') |
---|
313 | n/a | scrollTargetY = Scrollbar(frameTarget) |
---|
314 | n/a | scrollTargetX = Scrollbar(frameTarget, orient=HORIZONTAL) |
---|
315 | n/a | self.listBindings = Listbox( |
---|
316 | n/a | frameTarget, takefocus=FALSE, exportselection=FALSE) |
---|
317 | n/a | self.listBindings.bind('<ButtonRelease-1>', self.KeyBindingSelected) |
---|
318 | n/a | scrollTargetY.config(command=self.listBindings.yview) |
---|
319 | n/a | scrollTargetX.config(command=self.listBindings.xview) |
---|
320 | n/a | self.listBindings.config(yscrollcommand=scrollTargetY.set) |
---|
321 | n/a | self.listBindings.config(xscrollcommand=scrollTargetX.set) |
---|
322 | n/a | self.buttonNewKeys = Button( |
---|
323 | n/a | frameCustom, text='Get New Keys for Selection', |
---|
324 | n/a | command=self.GetNewKeys, state=DISABLED) |
---|
325 | n/a | #frameKeySets |
---|
326 | n/a | frames = [Frame(frameKeySets, padx=2, pady=2, borderwidth=0) |
---|
327 | n/a | for i in range(2)] |
---|
328 | n/a | self.radioKeysBuiltin = Radiobutton( |
---|
329 | n/a | frames[0], variable=self.keysAreBuiltin, value=1, |
---|
330 | n/a | command=self.SetKeysType, text='Use a Built-in Key Set') |
---|
331 | n/a | self.radioKeysCustom = Radiobutton( |
---|
332 | n/a | frames[0], variable=self.keysAreBuiltin, value=0, |
---|
333 | n/a | command=self.SetKeysType, text='Use a Custom Key Set') |
---|
334 | n/a | self.optMenuKeysBuiltin = DynOptionMenu( |
---|
335 | n/a | frames[0], self.builtinKeys, None, command=None) |
---|
336 | n/a | self.optMenuKeysCustom = DynOptionMenu( |
---|
337 | n/a | frames[0], self.customKeys, None, command=None) |
---|
338 | n/a | self.buttonDeleteCustomKeys = Button( |
---|
339 | n/a | frames[1], text='Delete Custom Key Set', |
---|
340 | n/a | command=self.DeleteCustomKeys) |
---|
341 | n/a | buttonSaveCustomKeys = Button( |
---|
342 | n/a | frames[1], text='Save as New Custom Key Set', |
---|
343 | n/a | command=self.SaveAsNewKeySet) |
---|
344 | n/a | self.new_custom_keys = Label(frames[0], bd=2) |
---|
345 | n/a | |
---|
346 | n/a | ##widget packing |
---|
347 | n/a | #body |
---|
348 | n/a | frameCustom.pack(side=BOTTOM, padx=5, pady=5, expand=TRUE, fill=BOTH) |
---|
349 | n/a | frameKeySets.pack(side=BOTTOM, padx=5, pady=5, fill=BOTH) |
---|
350 | n/a | #frameCustom |
---|
351 | n/a | self.buttonNewKeys.pack(side=BOTTOM, fill=X, padx=5, pady=5) |
---|
352 | n/a | frameTarget.pack(side=LEFT, padx=5, pady=5, expand=TRUE, fill=BOTH) |
---|
353 | n/a | #frame target |
---|
354 | n/a | frameTarget.columnconfigure(0, weight=1) |
---|
355 | n/a | frameTarget.rowconfigure(1, weight=1) |
---|
356 | n/a | labelTargetTitle.grid(row=0, column=0, columnspan=2, sticky=W) |
---|
357 | n/a | self.listBindings.grid(row=1, column=0, sticky=NSEW) |
---|
358 | n/a | scrollTargetY.grid(row=1, column=1, sticky=NS) |
---|
359 | n/a | scrollTargetX.grid(row=2, column=0, sticky=EW) |
---|
360 | n/a | #frameKeySets |
---|
361 | n/a | self.radioKeysBuiltin.grid(row=0, column=0, sticky=W+NS) |
---|
362 | n/a | self.radioKeysCustom.grid(row=1, column=0, sticky=W+NS) |
---|
363 | n/a | self.optMenuKeysBuiltin.grid(row=0, column=1, sticky=NSEW) |
---|
364 | n/a | self.optMenuKeysCustom.grid(row=1, column=1, sticky=NSEW) |
---|
365 | n/a | self.new_custom_keys.grid(row=0, column=2, sticky=NSEW, padx=5, pady=5) |
---|
366 | n/a | self.buttonDeleteCustomKeys.pack(side=LEFT, fill=X, expand=True, padx=2) |
---|
367 | n/a | buttonSaveCustomKeys.pack(side=LEFT, fill=X, expand=True, padx=2) |
---|
368 | n/a | frames[0].pack(side=TOP, fill=BOTH, expand=True) |
---|
369 | n/a | frames[1].pack(side=TOP, fill=X, expand=True, pady=2) |
---|
370 | n/a | return frame |
---|
371 | n/a | |
---|
372 | n/a | def CreatePageGeneral(self): |
---|
373 | n/a | parent = self.parent |
---|
374 | n/a | self.winWidth = StringVar(parent) |
---|
375 | n/a | self.winHeight = StringVar(parent) |
---|
376 | n/a | self.startupEdit = IntVar(parent) |
---|
377 | n/a | self.autoSave = IntVar(parent) |
---|
378 | n/a | self.encoding = StringVar(parent) |
---|
379 | n/a | self.userHelpBrowser = BooleanVar(parent) |
---|
380 | n/a | self.helpBrowser = StringVar(parent) |
---|
381 | n/a | |
---|
382 | n/a | #widget creation |
---|
383 | n/a | #body |
---|
384 | n/a | frame = self.tabPages.pages['General'].frame |
---|
385 | n/a | #body section frames |
---|
386 | n/a | frameRun = LabelFrame(frame, borderwidth=2, relief=GROOVE, |
---|
387 | n/a | text=' Startup Preferences ') |
---|
388 | n/a | frameSave = LabelFrame(frame, borderwidth=2, relief=GROOVE, |
---|
389 | n/a | text=' Autosave Preferences ') |
---|
390 | n/a | frameWinSize = Frame(frame, borderwidth=2, relief=GROOVE) |
---|
391 | n/a | frameHelp = LabelFrame(frame, borderwidth=2, relief=GROOVE, |
---|
392 | n/a | text=' Additional Help Sources ') |
---|
393 | n/a | #frameRun |
---|
394 | n/a | labelRunChoiceTitle = Label(frameRun, text='At Startup') |
---|
395 | n/a | self.radioStartupEdit = Radiobutton( |
---|
396 | n/a | frameRun, variable=self.startupEdit, value=1, |
---|
397 | n/a | text="Open Edit Window") |
---|
398 | n/a | self.radioStartupShell = Radiobutton( |
---|
399 | n/a | frameRun, variable=self.startupEdit, value=0, |
---|
400 | n/a | text='Open Shell Window') |
---|
401 | n/a | #frameSave |
---|
402 | n/a | labelRunSaveTitle = Label(frameSave, text='At Start of Run (F5) ') |
---|
403 | n/a | self.radioSaveAsk = Radiobutton( |
---|
404 | n/a | frameSave, variable=self.autoSave, value=0, |
---|
405 | n/a | text="Prompt to Save") |
---|
406 | n/a | self.radioSaveAuto = Radiobutton( |
---|
407 | n/a | frameSave, variable=self.autoSave, value=1, |
---|
408 | n/a | text='No Prompt') |
---|
409 | n/a | #frameWinSize |
---|
410 | n/a | labelWinSizeTitle = Label( |
---|
411 | n/a | frameWinSize, text='Initial Window Size (in characters)') |
---|
412 | n/a | labelWinWidthTitle = Label(frameWinSize, text='Width') |
---|
413 | n/a | self.entryWinWidth = Entry( |
---|
414 | n/a | frameWinSize, textvariable=self.winWidth, width=3) |
---|
415 | n/a | labelWinHeightTitle = Label(frameWinSize, text='Height') |
---|
416 | n/a | self.entryWinHeight = Entry( |
---|
417 | n/a | frameWinSize, textvariable=self.winHeight, width=3) |
---|
418 | n/a | #frameHelp |
---|
419 | n/a | frameHelpList = Frame(frameHelp) |
---|
420 | n/a | frameHelpListButtons = Frame(frameHelpList) |
---|
421 | n/a | scrollHelpList = Scrollbar(frameHelpList) |
---|
422 | n/a | self.listHelp = Listbox( |
---|
423 | n/a | frameHelpList, height=5, takefocus=FALSE, |
---|
424 | n/a | exportselection=FALSE) |
---|
425 | n/a | scrollHelpList.config(command=self.listHelp.yview) |
---|
426 | n/a | self.listHelp.config(yscrollcommand=scrollHelpList.set) |
---|
427 | n/a | self.listHelp.bind('<ButtonRelease-1>', self.HelpSourceSelected) |
---|
428 | n/a | self.buttonHelpListEdit = Button( |
---|
429 | n/a | frameHelpListButtons, text='Edit', state=DISABLED, |
---|
430 | n/a | width=8, command=self.HelpListItemEdit) |
---|
431 | n/a | self.buttonHelpListAdd = Button( |
---|
432 | n/a | frameHelpListButtons, text='Add', |
---|
433 | n/a | width=8, command=self.HelpListItemAdd) |
---|
434 | n/a | self.buttonHelpListRemove = Button( |
---|
435 | n/a | frameHelpListButtons, text='Remove', state=DISABLED, |
---|
436 | n/a | width=8, command=self.HelpListItemRemove) |
---|
437 | n/a | |
---|
438 | n/a | #widget packing |
---|
439 | n/a | #body |
---|
440 | n/a | frameRun.pack(side=TOP, padx=5, pady=5, fill=X) |
---|
441 | n/a | frameSave.pack(side=TOP, padx=5, pady=5, fill=X) |
---|
442 | n/a | frameWinSize.pack(side=TOP, padx=5, pady=5, fill=X) |
---|
443 | n/a | frameHelp.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH) |
---|
444 | n/a | #frameRun |
---|
445 | n/a | labelRunChoiceTitle.pack(side=LEFT, anchor=W, padx=5, pady=5) |
---|
446 | n/a | self.radioStartupShell.pack(side=RIGHT, anchor=W, padx=5, pady=5) |
---|
447 | n/a | self.radioStartupEdit.pack(side=RIGHT, anchor=W, padx=5, pady=5) |
---|
448 | n/a | #frameSave |
---|
449 | n/a | labelRunSaveTitle.pack(side=LEFT, anchor=W, padx=5, pady=5) |
---|
450 | n/a | self.radioSaveAuto.pack(side=RIGHT, anchor=W, padx=5, pady=5) |
---|
451 | n/a | self.radioSaveAsk.pack(side=RIGHT, anchor=W, padx=5, pady=5) |
---|
452 | n/a | #frameWinSize |
---|
453 | n/a | labelWinSizeTitle.pack(side=LEFT, anchor=W, padx=5, pady=5) |
---|
454 | n/a | self.entryWinHeight.pack(side=RIGHT, anchor=E, padx=10, pady=5) |
---|
455 | n/a | labelWinHeightTitle.pack(side=RIGHT, anchor=E, pady=5) |
---|
456 | n/a | self.entryWinWidth.pack(side=RIGHT, anchor=E, padx=10, pady=5) |
---|
457 | n/a | labelWinWidthTitle.pack(side=RIGHT, anchor=E, pady=5) |
---|
458 | n/a | #frameHelp |
---|
459 | n/a | frameHelpListButtons.pack(side=RIGHT, padx=5, pady=5, fill=Y) |
---|
460 | n/a | frameHelpList.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH) |
---|
461 | n/a | scrollHelpList.pack(side=RIGHT, anchor=W, fill=Y) |
---|
462 | n/a | self.listHelp.pack(side=LEFT, anchor=E, expand=TRUE, fill=BOTH) |
---|
463 | n/a | self.buttonHelpListEdit.pack(side=TOP, anchor=W, pady=5) |
---|
464 | n/a | self.buttonHelpListAdd.pack(side=TOP, anchor=W) |
---|
465 | n/a | self.buttonHelpListRemove.pack(side=TOP, anchor=W, pady=5) |
---|
466 | n/a | return frame |
---|
467 | n/a | |
---|
468 | n/a | def AttachVarCallbacks(self): |
---|
469 | n/a | self.fontSize.trace_add('write', self.VarChanged_font) |
---|
470 | n/a | self.fontName.trace_add('write', self.VarChanged_font) |
---|
471 | n/a | self.fontBold.trace_add('write', self.VarChanged_font) |
---|
472 | n/a | self.spaceNum.trace_add('write', self.VarChanged_spaceNum) |
---|
473 | n/a | self.colour.trace_add('write', self.VarChanged_colour) |
---|
474 | n/a | self.builtinTheme.trace_add('write', self.VarChanged_builtinTheme) |
---|
475 | n/a | self.customTheme.trace_add('write', self.VarChanged_customTheme) |
---|
476 | n/a | self.themeIsBuiltin.trace_add('write', self.VarChanged_themeIsBuiltin) |
---|
477 | n/a | self.highlightTarget.trace_add('write', self.VarChanged_highlightTarget) |
---|
478 | n/a | self.keyBinding.trace_add('write', self.VarChanged_keyBinding) |
---|
479 | n/a | self.builtinKeys.trace_add('write', self.VarChanged_builtinKeys) |
---|
480 | n/a | self.customKeys.trace_add('write', self.VarChanged_customKeys) |
---|
481 | n/a | self.keysAreBuiltin.trace_add('write', self.VarChanged_keysAreBuiltin) |
---|
482 | n/a | self.winWidth.trace_add('write', self.VarChanged_winWidth) |
---|
483 | n/a | self.winHeight.trace_add('write', self.VarChanged_winHeight) |
---|
484 | n/a | self.startupEdit.trace_add('write', self.VarChanged_startupEdit) |
---|
485 | n/a | self.autoSave.trace_add('write', self.VarChanged_autoSave) |
---|
486 | n/a | self.encoding.trace_add('write', self.VarChanged_encoding) |
---|
487 | n/a | |
---|
488 | n/a | def remove_var_callbacks(self): |
---|
489 | n/a | "Remove callbacks to prevent memory leaks." |
---|
490 | n/a | for var in ( |
---|
491 | n/a | self.fontSize, self.fontName, self.fontBold, |
---|
492 | n/a | self.spaceNum, self.colour, self.builtinTheme, |
---|
493 | n/a | self.customTheme, self.themeIsBuiltin, self.highlightTarget, |
---|
494 | n/a | self.keyBinding, self.builtinKeys, self.customKeys, |
---|
495 | n/a | self.keysAreBuiltin, self.winWidth, self.winHeight, |
---|
496 | n/a | self.startupEdit, self.autoSave, self.encoding,): |
---|
497 | n/a | var.trace_remove('write', var.trace_info()[0][1]) |
---|
498 | n/a | |
---|
499 | n/a | def VarChanged_font(self, *params): |
---|
500 | n/a | '''When one font attribute changes, save them all, as they are |
---|
501 | n/a | not independent from each other. In particular, when we are |
---|
502 | n/a | overriding the default font, we need to write out everything. |
---|
503 | n/a | ''' |
---|
504 | n/a | value = self.fontName.get() |
---|
505 | n/a | self.AddChangedItem('main', 'EditorWindow', 'font', value) |
---|
506 | n/a | value = self.fontSize.get() |
---|
507 | n/a | self.AddChangedItem('main', 'EditorWindow', 'font-size', value) |
---|
508 | n/a | value = self.fontBold.get() |
---|
509 | n/a | self.AddChangedItem('main', 'EditorWindow', 'font-bold', value) |
---|
510 | n/a | |
---|
511 | n/a | def VarChanged_spaceNum(self, *params): |
---|
512 | n/a | value = self.spaceNum.get() |
---|
513 | n/a | self.AddChangedItem('main', 'Indent', 'num-spaces', value) |
---|
514 | n/a | |
---|
515 | n/a | def VarChanged_colour(self, *params): |
---|
516 | n/a | self.OnNewColourSet() |
---|
517 | n/a | |
---|
518 | n/a | def VarChanged_builtinTheme(self, *params): |
---|
519 | n/a | oldthemes = ('IDLE Classic', 'IDLE New') |
---|
520 | n/a | value = self.builtinTheme.get() |
---|
521 | n/a | if value not in oldthemes: |
---|
522 | n/a | if idleConf.GetOption('main', 'Theme', 'name') not in oldthemes: |
---|
523 | n/a | self.AddChangedItem('main', 'Theme', 'name', oldthemes[0]) |
---|
524 | n/a | self.AddChangedItem('main', 'Theme', 'name2', value) |
---|
525 | n/a | self.new_custom_theme.config(text='New theme, see Help', |
---|
526 | n/a | fg='#500000') |
---|
527 | n/a | else: |
---|
528 | n/a | self.AddChangedItem('main', 'Theme', 'name', value) |
---|
529 | n/a | self.AddChangedItem('main', 'Theme', 'name2', '') |
---|
530 | n/a | self.new_custom_theme.config(text='', fg='black') |
---|
531 | n/a | self.PaintThemeSample() |
---|
532 | n/a | |
---|
533 | n/a | def VarChanged_customTheme(self, *params): |
---|
534 | n/a | value = self.customTheme.get() |
---|
535 | n/a | if value != '- no custom themes -': |
---|
536 | n/a | self.AddChangedItem('main', 'Theme', 'name', value) |
---|
537 | n/a | self.PaintThemeSample() |
---|
538 | n/a | |
---|
539 | n/a | def VarChanged_themeIsBuiltin(self, *params): |
---|
540 | n/a | value = self.themeIsBuiltin.get() |
---|
541 | n/a | self.AddChangedItem('main', 'Theme', 'default', value) |
---|
542 | n/a | if value: |
---|
543 | n/a | self.VarChanged_builtinTheme() |
---|
544 | n/a | else: |
---|
545 | n/a | self.VarChanged_customTheme() |
---|
546 | n/a | |
---|
547 | n/a | def VarChanged_highlightTarget(self, *params): |
---|
548 | n/a | self.SetHighlightTarget() |
---|
549 | n/a | |
---|
550 | n/a | def VarChanged_keyBinding(self, *params): |
---|
551 | n/a | value = self.keyBinding.get() |
---|
552 | n/a | keySet = self.customKeys.get() |
---|
553 | n/a | event = self.listBindings.get(ANCHOR).split()[0] |
---|
554 | n/a | if idleConf.IsCoreBinding(event): |
---|
555 | n/a | #this is a core keybinding |
---|
556 | n/a | self.AddChangedItem('keys', keySet, event, value) |
---|
557 | n/a | else: #this is an extension key binding |
---|
558 | n/a | extName = idleConf.GetExtnNameForEvent(event) |
---|
559 | n/a | extKeybindSection = extName + '_cfgBindings' |
---|
560 | n/a | self.AddChangedItem('extensions', extKeybindSection, event, value) |
---|
561 | n/a | |
---|
562 | n/a | def VarChanged_builtinKeys(self, *params): |
---|
563 | n/a | oldkeys = ( |
---|
564 | n/a | 'IDLE Classic Windows', |
---|
565 | n/a | 'IDLE Classic Unix', |
---|
566 | n/a | 'IDLE Classic Mac', |
---|
567 | n/a | 'IDLE Classic OSX', |
---|
568 | n/a | ) |
---|
569 | n/a | value = self.builtinKeys.get() |
---|
570 | n/a | if value not in oldkeys: |
---|
571 | n/a | if idleConf.GetOption('main', 'Keys', 'name') not in oldkeys: |
---|
572 | n/a | self.AddChangedItem('main', 'Keys', 'name', oldkeys[0]) |
---|
573 | n/a | self.AddChangedItem('main', 'Keys', 'name2', value) |
---|
574 | n/a | self.new_custom_keys.config(text='New key set, see Help', |
---|
575 | n/a | fg='#500000') |
---|
576 | n/a | else: |
---|
577 | n/a | self.AddChangedItem('main', 'Keys', 'name', value) |
---|
578 | n/a | self.AddChangedItem('main', 'Keys', 'name2', '') |
---|
579 | n/a | self.new_custom_keys.config(text='', fg='black') |
---|
580 | n/a | self.LoadKeysList(value) |
---|
581 | n/a | |
---|
582 | n/a | def VarChanged_customKeys(self, *params): |
---|
583 | n/a | value = self.customKeys.get() |
---|
584 | n/a | if value != '- no custom keys -': |
---|
585 | n/a | self.AddChangedItem('main', 'Keys', 'name', value) |
---|
586 | n/a | self.LoadKeysList(value) |
---|
587 | n/a | |
---|
588 | n/a | def VarChanged_keysAreBuiltin(self, *params): |
---|
589 | n/a | value = self.keysAreBuiltin.get() |
---|
590 | n/a | self.AddChangedItem('main', 'Keys', 'default', value) |
---|
591 | n/a | if value: |
---|
592 | n/a | self.VarChanged_builtinKeys() |
---|
593 | n/a | else: |
---|
594 | n/a | self.VarChanged_customKeys() |
---|
595 | n/a | |
---|
596 | n/a | def VarChanged_winWidth(self, *params): |
---|
597 | n/a | value = self.winWidth.get() |
---|
598 | n/a | self.AddChangedItem('main', 'EditorWindow', 'width', value) |
---|
599 | n/a | |
---|
600 | n/a | def VarChanged_winHeight(self, *params): |
---|
601 | n/a | value = self.winHeight.get() |
---|
602 | n/a | self.AddChangedItem('main', 'EditorWindow', 'height', value) |
---|
603 | n/a | |
---|
604 | n/a | def VarChanged_startupEdit(self, *params): |
---|
605 | n/a | value = self.startupEdit.get() |
---|
606 | n/a | self.AddChangedItem('main', 'General', 'editor-on-startup', value) |
---|
607 | n/a | |
---|
608 | n/a | def VarChanged_autoSave(self, *params): |
---|
609 | n/a | value = self.autoSave.get() |
---|
610 | n/a | self.AddChangedItem('main', 'General', 'autosave', value) |
---|
611 | n/a | |
---|
612 | n/a | def VarChanged_encoding(self, *params): |
---|
613 | n/a | value = self.encoding.get() |
---|
614 | n/a | self.AddChangedItem('main', 'EditorWindow', 'encoding', value) |
---|
615 | n/a | |
---|
616 | n/a | def ResetChangedItems(self): |
---|
617 | n/a | #When any config item is changed in this dialog, an entry |
---|
618 | n/a | #should be made in the relevant section (config type) of this |
---|
619 | n/a | #dictionary. The key should be the config file section name and the |
---|
620 | n/a | #value a dictionary, whose key:value pairs are item=value pairs for |
---|
621 | n/a | #that config file section. |
---|
622 | n/a | self.changedItems = {'main':{}, 'highlight':{}, 'keys':{}, |
---|
623 | n/a | 'extensions':{}} |
---|
624 | n/a | |
---|
625 | n/a | def AddChangedItem(self, typ, section, item, value): |
---|
626 | n/a | value = str(value) #make sure we use a string |
---|
627 | n/a | if section not in self.changedItems[typ]: |
---|
628 | n/a | self.changedItems[typ][section] = {} |
---|
629 | n/a | self.changedItems[typ][section][item] = value |
---|
630 | n/a | |
---|
631 | n/a | def GetDefaultItems(self): |
---|
632 | n/a | dItems={'main':{}, 'highlight':{}, 'keys':{}, 'extensions':{}} |
---|
633 | n/a | for configType in dItems: |
---|
634 | n/a | sections = idleConf.GetSectionList('default', configType) |
---|
635 | n/a | for section in sections: |
---|
636 | n/a | dItems[configType][section] = {} |
---|
637 | n/a | options = idleConf.defaultCfg[configType].GetOptionList(section) |
---|
638 | n/a | for option in options: |
---|
639 | n/a | dItems[configType][section][option] = ( |
---|
640 | n/a | idleConf.defaultCfg[configType].Get(section, option)) |
---|
641 | n/a | return dItems |
---|
642 | n/a | |
---|
643 | n/a | def SetThemeType(self): |
---|
644 | n/a | if self.themeIsBuiltin.get(): |
---|
645 | n/a | self.optMenuThemeBuiltin.config(state=NORMAL) |
---|
646 | n/a | self.optMenuThemeCustom.config(state=DISABLED) |
---|
647 | n/a | self.buttonDeleteCustomTheme.config(state=DISABLED) |
---|
648 | n/a | else: |
---|
649 | n/a | self.optMenuThemeBuiltin.config(state=DISABLED) |
---|
650 | n/a | self.radioThemeCustom.config(state=NORMAL) |
---|
651 | n/a | self.optMenuThemeCustom.config(state=NORMAL) |
---|
652 | n/a | self.buttonDeleteCustomTheme.config(state=NORMAL) |
---|
653 | n/a | |
---|
654 | n/a | def SetKeysType(self): |
---|
655 | n/a | if self.keysAreBuiltin.get(): |
---|
656 | n/a | self.optMenuKeysBuiltin.config(state=NORMAL) |
---|
657 | n/a | self.optMenuKeysCustom.config(state=DISABLED) |
---|
658 | n/a | self.buttonDeleteCustomKeys.config(state=DISABLED) |
---|
659 | n/a | else: |
---|
660 | n/a | self.optMenuKeysBuiltin.config(state=DISABLED) |
---|
661 | n/a | self.radioKeysCustom.config(state=NORMAL) |
---|
662 | n/a | self.optMenuKeysCustom.config(state=NORMAL) |
---|
663 | n/a | self.buttonDeleteCustomKeys.config(state=NORMAL) |
---|
664 | n/a | |
---|
665 | n/a | def GetNewKeys(self): |
---|
666 | n/a | listIndex = self.listBindings.index(ANCHOR) |
---|
667 | n/a | binding = self.listBindings.get(listIndex) |
---|
668 | n/a | bindName = binding.split()[0] #first part, up to first space |
---|
669 | n/a | if self.keysAreBuiltin.get(): |
---|
670 | n/a | currentKeySetName = self.builtinKeys.get() |
---|
671 | n/a | else: |
---|
672 | n/a | currentKeySetName = self.customKeys.get() |
---|
673 | n/a | currentBindings = idleConf.GetCurrentKeySet() |
---|
674 | n/a | if currentKeySetName in self.changedItems['keys']: #unsaved changes |
---|
675 | n/a | keySetChanges = self.changedItems['keys'][currentKeySetName] |
---|
676 | n/a | for event in keySetChanges: |
---|
677 | n/a | currentBindings[event] = keySetChanges[event].split() |
---|
678 | n/a | currentKeySequences = list(currentBindings.values()) |
---|
679 | n/a | newKeys = GetKeysDialog(self, 'Get New Keys', bindName, |
---|
680 | n/a | currentKeySequences).result |
---|
681 | n/a | if newKeys: #new keys were specified |
---|
682 | n/a | if self.keysAreBuiltin.get(): #current key set is a built-in |
---|
683 | n/a | message = ('Your changes will be saved as a new Custom Key Set.' |
---|
684 | n/a | ' Enter a name for your new Custom Key Set below.') |
---|
685 | n/a | newKeySet = self.GetNewKeysName(message) |
---|
686 | n/a | if not newKeySet: #user cancelled custom key set creation |
---|
687 | n/a | self.listBindings.select_set(listIndex) |
---|
688 | n/a | self.listBindings.select_anchor(listIndex) |
---|
689 | n/a | return |
---|
690 | n/a | else: #create new custom key set based on previously active key set |
---|
691 | n/a | self.CreateNewKeySet(newKeySet) |
---|
692 | n/a | self.listBindings.delete(listIndex) |
---|
693 | n/a | self.listBindings.insert(listIndex, bindName+' - '+newKeys) |
---|
694 | n/a | self.listBindings.select_set(listIndex) |
---|
695 | n/a | self.listBindings.select_anchor(listIndex) |
---|
696 | n/a | self.keyBinding.set(newKeys) |
---|
697 | n/a | else: |
---|
698 | n/a | self.listBindings.select_set(listIndex) |
---|
699 | n/a | self.listBindings.select_anchor(listIndex) |
---|
700 | n/a | |
---|
701 | n/a | def GetNewKeysName(self, message): |
---|
702 | n/a | usedNames = (idleConf.GetSectionList('user', 'keys') + |
---|
703 | n/a | idleConf.GetSectionList('default', 'keys')) |
---|
704 | n/a | newKeySet = SectionName( |
---|
705 | n/a | self, 'New Custom Key Set', message, usedNames).result |
---|
706 | n/a | return newKeySet |
---|
707 | n/a | |
---|
708 | n/a | def SaveAsNewKeySet(self): |
---|
709 | n/a | newKeysName = self.GetNewKeysName('New Key Set Name:') |
---|
710 | n/a | if newKeysName: |
---|
711 | n/a | self.CreateNewKeySet(newKeysName) |
---|
712 | n/a | |
---|
713 | n/a | def KeyBindingSelected(self, event): |
---|
714 | n/a | self.buttonNewKeys.config(state=NORMAL) |
---|
715 | n/a | |
---|
716 | n/a | def CreateNewKeySet(self, newKeySetName): |
---|
717 | n/a | #creates new custom key set based on the previously active key set, |
---|
718 | n/a | #and makes the new key set active |
---|
719 | n/a | if self.keysAreBuiltin.get(): |
---|
720 | n/a | prevKeySetName = self.builtinKeys.get() |
---|
721 | n/a | else: |
---|
722 | n/a | prevKeySetName = self.customKeys.get() |
---|
723 | n/a | prevKeys = idleConf.GetCoreKeys(prevKeySetName) |
---|
724 | n/a | newKeys = {} |
---|
725 | n/a | for event in prevKeys: #add key set to changed items |
---|
726 | n/a | eventName = event[2:-2] #trim off the angle brackets |
---|
727 | n/a | binding = ' '.join(prevKeys[event]) |
---|
728 | n/a | newKeys[eventName] = binding |
---|
729 | n/a | #handle any unsaved changes to prev key set |
---|
730 | n/a | if prevKeySetName in self.changedItems['keys']: |
---|
731 | n/a | keySetChanges = self.changedItems['keys'][prevKeySetName] |
---|
732 | n/a | for event in keySetChanges: |
---|
733 | n/a | newKeys[event] = keySetChanges[event] |
---|
734 | n/a | #save the new theme |
---|
735 | n/a | self.SaveNewKeySet(newKeySetName, newKeys) |
---|
736 | n/a | #change gui over to the new key set |
---|
737 | n/a | customKeyList = idleConf.GetSectionList('user', 'keys') |
---|
738 | n/a | customKeyList.sort() |
---|
739 | n/a | self.optMenuKeysCustom.SetMenu(customKeyList, newKeySetName) |
---|
740 | n/a | self.keysAreBuiltin.set(0) |
---|
741 | n/a | self.SetKeysType() |
---|
742 | n/a | |
---|
743 | n/a | def LoadKeysList(self, keySetName): |
---|
744 | n/a | reselect = 0 |
---|
745 | n/a | newKeySet = 0 |
---|
746 | n/a | if self.listBindings.curselection(): |
---|
747 | n/a | reselect = 1 |
---|
748 | n/a | listIndex = self.listBindings.index(ANCHOR) |
---|
749 | n/a | keySet = idleConf.GetKeySet(keySetName) |
---|
750 | n/a | bindNames = list(keySet.keys()) |
---|
751 | n/a | bindNames.sort() |
---|
752 | n/a | self.listBindings.delete(0, END) |
---|
753 | n/a | for bindName in bindNames: |
---|
754 | n/a | key = ' '.join(keySet[bindName]) #make key(s) into a string |
---|
755 | n/a | bindName = bindName[2:-2] #trim off the angle brackets |
---|
756 | n/a | if keySetName in self.changedItems['keys']: |
---|
757 | n/a | #handle any unsaved changes to this key set |
---|
758 | n/a | if bindName in self.changedItems['keys'][keySetName]: |
---|
759 | n/a | key = self.changedItems['keys'][keySetName][bindName] |
---|
760 | n/a | self.listBindings.insert(END, bindName+' - '+key) |
---|
761 | n/a | if reselect: |
---|
762 | n/a | self.listBindings.see(listIndex) |
---|
763 | n/a | self.listBindings.select_set(listIndex) |
---|
764 | n/a | self.listBindings.select_anchor(listIndex) |
---|
765 | n/a | |
---|
766 | n/a | def DeleteCustomKeys(self): |
---|
767 | n/a | keySetName=self.customKeys.get() |
---|
768 | n/a | delmsg = 'Are you sure you wish to delete the key set %r ?' |
---|
769 | n/a | if not tkMessageBox.askyesno( |
---|
770 | n/a | 'Delete Key Set', delmsg % keySetName, parent=self): |
---|
771 | n/a | return |
---|
772 | n/a | self.DeactivateCurrentConfig() |
---|
773 | n/a | #remove key set from config |
---|
774 | n/a | idleConf.userCfg['keys'].remove_section(keySetName) |
---|
775 | n/a | if keySetName in self.changedItems['keys']: |
---|
776 | n/a | del(self.changedItems['keys'][keySetName]) |
---|
777 | n/a | #write changes |
---|
778 | n/a | idleConf.userCfg['keys'].Save() |
---|
779 | n/a | #reload user key set list |
---|
780 | n/a | itemList = idleConf.GetSectionList('user', 'keys') |
---|
781 | n/a | itemList.sort() |
---|
782 | n/a | if not itemList: |
---|
783 | n/a | self.radioKeysCustom.config(state=DISABLED) |
---|
784 | n/a | self.optMenuKeysCustom.SetMenu(itemList, '- no custom keys -') |
---|
785 | n/a | else: |
---|
786 | n/a | self.optMenuKeysCustom.SetMenu(itemList, itemList[0]) |
---|
787 | n/a | #revert to default key set |
---|
788 | n/a | self.keysAreBuiltin.set(idleConf.defaultCfg['main'] |
---|
789 | n/a | .Get('Keys', 'default')) |
---|
790 | n/a | self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys', 'name') |
---|
791 | n/a | or idleConf.default_keys()) |
---|
792 | n/a | #user can't back out of these changes, they must be applied now |
---|
793 | n/a | self.SaveAllChangedConfigs() |
---|
794 | n/a | self.ActivateConfigChanges() |
---|
795 | n/a | self.SetKeysType() |
---|
796 | n/a | |
---|
797 | n/a | def DeleteCustomTheme(self): |
---|
798 | n/a | themeName = self.customTheme.get() |
---|
799 | n/a | delmsg = 'Are you sure you wish to delete the theme %r ?' |
---|
800 | n/a | if not tkMessageBox.askyesno( |
---|
801 | n/a | 'Delete Theme', delmsg % themeName, parent=self): |
---|
802 | n/a | return |
---|
803 | n/a | self.DeactivateCurrentConfig() |
---|
804 | n/a | #remove theme from config |
---|
805 | n/a | idleConf.userCfg['highlight'].remove_section(themeName) |
---|
806 | n/a | if themeName in self.changedItems['highlight']: |
---|
807 | n/a | del(self.changedItems['highlight'][themeName]) |
---|
808 | n/a | #write changes |
---|
809 | n/a | idleConf.userCfg['highlight'].Save() |
---|
810 | n/a | #reload user theme list |
---|
811 | n/a | itemList = idleConf.GetSectionList('user', 'highlight') |
---|
812 | n/a | itemList.sort() |
---|
813 | n/a | if not itemList: |
---|
814 | n/a | self.radioThemeCustom.config(state=DISABLED) |
---|
815 | n/a | self.optMenuThemeCustom.SetMenu(itemList, '- no custom themes -') |
---|
816 | n/a | else: |
---|
817 | n/a | self.optMenuThemeCustom.SetMenu(itemList, itemList[0]) |
---|
818 | n/a | #revert to default theme |
---|
819 | n/a | self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme', 'default')) |
---|
820 | n/a | self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme', 'name')) |
---|
821 | n/a | #user can't back out of these changes, they must be applied now |
---|
822 | n/a | self.SaveAllChangedConfigs() |
---|
823 | n/a | self.ActivateConfigChanges() |
---|
824 | n/a | self.SetThemeType() |
---|
825 | n/a | |
---|
826 | n/a | def GetColour(self): |
---|
827 | n/a | target = self.highlightTarget.get() |
---|
828 | n/a | prevColour = self.frameColourSet.cget('bg') |
---|
829 | n/a | rgbTuplet, colourString = tkColorChooser.askcolor( |
---|
830 | n/a | parent=self, title='Pick new colour for : '+target, |
---|
831 | n/a | initialcolor=prevColour) |
---|
832 | n/a | if colourString and (colourString != prevColour): |
---|
833 | n/a | #user didn't cancel, and they chose a new colour |
---|
834 | n/a | if self.themeIsBuiltin.get(): #current theme is a built-in |
---|
835 | n/a | message = ('Your changes will be saved as a new Custom Theme. ' |
---|
836 | n/a | 'Enter a name for your new Custom Theme below.') |
---|
837 | n/a | newTheme = self.GetNewThemeName(message) |
---|
838 | n/a | if not newTheme: #user cancelled custom theme creation |
---|
839 | n/a | return |
---|
840 | n/a | else: #create new custom theme based on previously active theme |
---|
841 | n/a | self.CreateNewTheme(newTheme) |
---|
842 | n/a | self.colour.set(colourString) |
---|
843 | n/a | else: #current theme is user defined |
---|
844 | n/a | self.colour.set(colourString) |
---|
845 | n/a | |
---|
846 | n/a | def OnNewColourSet(self): |
---|
847 | n/a | newColour=self.colour.get() |
---|
848 | n/a | self.frameColourSet.config(bg=newColour) #set sample |
---|
849 | n/a | plane ='foreground' if self.fgHilite.get() else 'background' |
---|
850 | n/a | sampleElement = self.themeElements[self.highlightTarget.get()][0] |
---|
851 | n/a | self.textHighlightSample.tag_config(sampleElement, **{plane:newColour}) |
---|
852 | n/a | theme = self.customTheme.get() |
---|
853 | n/a | themeElement = sampleElement + '-' + plane |
---|
854 | n/a | self.AddChangedItem('highlight', theme, themeElement, newColour) |
---|
855 | n/a | |
---|
856 | n/a | def GetNewThemeName(self, message): |
---|
857 | n/a | usedNames = (idleConf.GetSectionList('user', 'highlight') + |
---|
858 | n/a | idleConf.GetSectionList('default', 'highlight')) |
---|
859 | n/a | newTheme = SectionName( |
---|
860 | n/a | self, 'New Custom Theme', message, usedNames).result |
---|
861 | n/a | return newTheme |
---|
862 | n/a | |
---|
863 | n/a | def SaveAsNewTheme(self): |
---|
864 | n/a | newThemeName = self.GetNewThemeName('New Theme Name:') |
---|
865 | n/a | if newThemeName: |
---|
866 | n/a | self.CreateNewTheme(newThemeName) |
---|
867 | n/a | |
---|
868 | n/a | def CreateNewTheme(self, newThemeName): |
---|
869 | n/a | #creates new custom theme based on the previously active theme, |
---|
870 | n/a | #and makes the new theme active |
---|
871 | n/a | if self.themeIsBuiltin.get(): |
---|
872 | n/a | themeType = 'default' |
---|
873 | n/a | themeName = self.builtinTheme.get() |
---|
874 | n/a | else: |
---|
875 | n/a | themeType = 'user' |
---|
876 | n/a | themeName = self.customTheme.get() |
---|
877 | n/a | newTheme = idleConf.GetThemeDict(themeType, themeName) |
---|
878 | n/a | #apply any of the old theme's unsaved changes to the new theme |
---|
879 | n/a | if themeName in self.changedItems['highlight']: |
---|
880 | n/a | themeChanges = self.changedItems['highlight'][themeName] |
---|
881 | n/a | for element in themeChanges: |
---|
882 | n/a | newTheme[element] = themeChanges[element] |
---|
883 | n/a | #save the new theme |
---|
884 | n/a | self.SaveNewTheme(newThemeName, newTheme) |
---|
885 | n/a | #change gui over to the new theme |
---|
886 | n/a | customThemeList = idleConf.GetSectionList('user', 'highlight') |
---|
887 | n/a | customThemeList.sort() |
---|
888 | n/a | self.optMenuThemeCustom.SetMenu(customThemeList, newThemeName) |
---|
889 | n/a | self.themeIsBuiltin.set(0) |
---|
890 | n/a | self.SetThemeType() |
---|
891 | n/a | |
---|
892 | n/a | def OnListFontButtonRelease(self, event): |
---|
893 | n/a | font = self.listFontName.get(ANCHOR) |
---|
894 | n/a | self.fontName.set(font.lower()) |
---|
895 | n/a | self.SetFontSample() |
---|
896 | n/a | |
---|
897 | n/a | def SetFontSample(self, event=None): |
---|
898 | n/a | fontName = self.fontName.get() |
---|
899 | n/a | fontWeight = tkFont.BOLD if self.fontBold.get() else tkFont.NORMAL |
---|
900 | n/a | newFont = (fontName, self.fontSize.get(), fontWeight) |
---|
901 | n/a | self.labelFontSample.config(font=newFont) |
---|
902 | n/a | self.textHighlightSample.configure(font=newFont) |
---|
903 | n/a | |
---|
904 | n/a | def SetHighlightTarget(self): |
---|
905 | n/a | if self.highlightTarget.get() == 'Cursor': #bg not possible |
---|
906 | n/a | self.radioFg.config(state=DISABLED) |
---|
907 | n/a | self.radioBg.config(state=DISABLED) |
---|
908 | n/a | self.fgHilite.set(1) |
---|
909 | n/a | else: #both fg and bg can be set |
---|
910 | n/a | self.radioFg.config(state=NORMAL) |
---|
911 | n/a | self.radioBg.config(state=NORMAL) |
---|
912 | n/a | self.fgHilite.set(1) |
---|
913 | n/a | self.SetColourSample() |
---|
914 | n/a | |
---|
915 | n/a | def SetColourSampleBinding(self, *args): |
---|
916 | n/a | self.SetColourSample() |
---|
917 | n/a | |
---|
918 | n/a | def SetColourSample(self): |
---|
919 | n/a | #set the colour smaple area |
---|
920 | n/a | tag = self.themeElements[self.highlightTarget.get()][0] |
---|
921 | n/a | plane = 'foreground' if self.fgHilite.get() else 'background' |
---|
922 | n/a | colour = self.textHighlightSample.tag_cget(tag, plane) |
---|
923 | n/a | self.frameColourSet.config(bg=colour) |
---|
924 | n/a | |
---|
925 | n/a | def PaintThemeSample(self): |
---|
926 | n/a | if self.themeIsBuiltin.get(): #a default theme |
---|
927 | n/a | theme = self.builtinTheme.get() |
---|
928 | n/a | else: #a user theme |
---|
929 | n/a | theme = self.customTheme.get() |
---|
930 | n/a | for elementTitle in self.themeElements: |
---|
931 | n/a | element = self.themeElements[elementTitle][0] |
---|
932 | n/a | colours = idleConf.GetHighlight(theme, element) |
---|
933 | n/a | if element == 'cursor': #cursor sample needs special painting |
---|
934 | n/a | colours['background'] = idleConf.GetHighlight( |
---|
935 | n/a | theme, 'normal', fgBg='bg') |
---|
936 | n/a | #handle any unsaved changes to this theme |
---|
937 | n/a | if theme in self.changedItems['highlight']: |
---|
938 | n/a | themeDict = self.changedItems['highlight'][theme] |
---|
939 | n/a | if element + '-foreground' in themeDict: |
---|
940 | n/a | colours['foreground'] = themeDict[element + '-foreground'] |
---|
941 | n/a | if element + '-background' in themeDict: |
---|
942 | n/a | colours['background'] = themeDict[element + '-background'] |
---|
943 | n/a | self.textHighlightSample.tag_config(element, **colours) |
---|
944 | n/a | self.SetColourSample() |
---|
945 | n/a | |
---|
946 | n/a | def HelpSourceSelected(self, event): |
---|
947 | n/a | self.SetHelpListButtonStates() |
---|
948 | n/a | |
---|
949 | n/a | def SetHelpListButtonStates(self): |
---|
950 | n/a | if self.listHelp.size() < 1: #no entries in list |
---|
951 | n/a | self.buttonHelpListEdit.config(state=DISABLED) |
---|
952 | n/a | self.buttonHelpListRemove.config(state=DISABLED) |
---|
953 | n/a | else: #there are some entries |
---|
954 | n/a | if self.listHelp.curselection(): #there currently is a selection |
---|
955 | n/a | self.buttonHelpListEdit.config(state=NORMAL) |
---|
956 | n/a | self.buttonHelpListRemove.config(state=NORMAL) |
---|
957 | n/a | else: #there currently is not a selection |
---|
958 | n/a | self.buttonHelpListEdit.config(state=DISABLED) |
---|
959 | n/a | self.buttonHelpListRemove.config(state=DISABLED) |
---|
960 | n/a | |
---|
961 | n/a | def HelpListItemAdd(self): |
---|
962 | n/a | helpSource = HelpSource(self, 'New Help Source', |
---|
963 | n/a | ).result |
---|
964 | n/a | if helpSource: |
---|
965 | n/a | self.userHelpList.append((helpSource[0], helpSource[1])) |
---|
966 | n/a | self.listHelp.insert(END, helpSource[0]) |
---|
967 | n/a | self.UpdateUserHelpChangedItems() |
---|
968 | n/a | self.SetHelpListButtonStates() |
---|
969 | n/a | |
---|
970 | n/a | def HelpListItemEdit(self): |
---|
971 | n/a | itemIndex = self.listHelp.index(ANCHOR) |
---|
972 | n/a | helpSource = self.userHelpList[itemIndex] |
---|
973 | n/a | newHelpSource = HelpSource( |
---|
974 | n/a | self, 'Edit Help Source', |
---|
975 | n/a | menuitem=helpSource[0], |
---|
976 | n/a | filepath=helpSource[1], |
---|
977 | n/a | ).result |
---|
978 | n/a | if newHelpSource and newHelpSource != helpSource: |
---|
979 | n/a | self.userHelpList[itemIndex] = newHelpSource |
---|
980 | n/a | self.listHelp.delete(itemIndex) |
---|
981 | n/a | self.listHelp.insert(itemIndex, newHelpSource[0]) |
---|
982 | n/a | self.UpdateUserHelpChangedItems() |
---|
983 | n/a | self.SetHelpListButtonStates() |
---|
984 | n/a | |
---|
985 | n/a | def HelpListItemRemove(self): |
---|
986 | n/a | itemIndex = self.listHelp.index(ANCHOR) |
---|
987 | n/a | del(self.userHelpList[itemIndex]) |
---|
988 | n/a | self.listHelp.delete(itemIndex) |
---|
989 | n/a | self.UpdateUserHelpChangedItems() |
---|
990 | n/a | self.SetHelpListButtonStates() |
---|
991 | n/a | |
---|
992 | n/a | def UpdateUserHelpChangedItems(self): |
---|
993 | n/a | "Clear and rebuild the HelpFiles section in self.changedItems" |
---|
994 | n/a | self.changedItems['main']['HelpFiles'] = {} |
---|
995 | n/a | for num in range(1, len(self.userHelpList) + 1): |
---|
996 | n/a | self.AddChangedItem( |
---|
997 | n/a | 'main', 'HelpFiles', str(num), |
---|
998 | n/a | ';'.join(self.userHelpList[num-1][:2])) |
---|
999 | n/a | |
---|
1000 | n/a | def LoadFontCfg(self): |
---|
1001 | n/a | ##base editor font selection list |
---|
1002 | n/a | fonts = list(tkFont.families(self)) |
---|
1003 | n/a | fonts.sort() |
---|
1004 | n/a | for font in fonts: |
---|
1005 | n/a | self.listFontName.insert(END, font) |
---|
1006 | n/a | configuredFont = idleConf.GetFont(self, 'main', 'EditorWindow') |
---|
1007 | n/a | fontName = configuredFont[0].lower() |
---|
1008 | n/a | fontSize = configuredFont[1] |
---|
1009 | n/a | fontBold = configuredFont[2]=='bold' |
---|
1010 | n/a | self.fontName.set(fontName) |
---|
1011 | n/a | lc_fonts = [s.lower() for s in fonts] |
---|
1012 | n/a | try: |
---|
1013 | n/a | currentFontIndex = lc_fonts.index(fontName) |
---|
1014 | n/a | self.listFontName.see(currentFontIndex) |
---|
1015 | n/a | self.listFontName.select_set(currentFontIndex) |
---|
1016 | n/a | self.listFontName.select_anchor(currentFontIndex) |
---|
1017 | n/a | except ValueError: |
---|
1018 | n/a | pass |
---|
1019 | n/a | ##font size dropdown |
---|
1020 | n/a | self.optMenuFontSize.SetMenu(('7', '8', '9', '10', '11', '12', '13', |
---|
1021 | n/a | '14', '16', '18', '20', '22', |
---|
1022 | n/a | '25', '29', '34', '40'), fontSize ) |
---|
1023 | n/a | ##fontWeight |
---|
1024 | n/a | self.fontBold.set(fontBold) |
---|
1025 | n/a | ##font sample |
---|
1026 | n/a | self.SetFontSample() |
---|
1027 | n/a | |
---|
1028 | n/a | def LoadTabCfg(self): |
---|
1029 | n/a | ##indent sizes |
---|
1030 | n/a | spaceNum = idleConf.GetOption( |
---|
1031 | n/a | 'main', 'Indent', 'num-spaces', default=4, type='int') |
---|
1032 | n/a | self.spaceNum.set(spaceNum) |
---|
1033 | n/a | |
---|
1034 | n/a | def LoadThemeCfg(self): |
---|
1035 | n/a | ##current theme type radiobutton |
---|
1036 | n/a | self.themeIsBuiltin.set(idleConf.GetOption( |
---|
1037 | n/a | 'main', 'Theme', 'default', type='bool', default=1)) |
---|
1038 | n/a | ##currently set theme |
---|
1039 | n/a | currentOption = idleConf.CurrentTheme() |
---|
1040 | n/a | ##load available theme option menus |
---|
1041 | n/a | if self.themeIsBuiltin.get(): #default theme selected |
---|
1042 | n/a | itemList = idleConf.GetSectionList('default', 'highlight') |
---|
1043 | n/a | itemList.sort() |
---|
1044 | n/a | self.optMenuThemeBuiltin.SetMenu(itemList, currentOption) |
---|
1045 | n/a | itemList = idleConf.GetSectionList('user', 'highlight') |
---|
1046 | n/a | itemList.sort() |
---|
1047 | n/a | if not itemList: |
---|
1048 | n/a | self.radioThemeCustom.config(state=DISABLED) |
---|
1049 | n/a | self.customTheme.set('- no custom themes -') |
---|
1050 | n/a | else: |
---|
1051 | n/a | self.optMenuThemeCustom.SetMenu(itemList, itemList[0]) |
---|
1052 | n/a | else: #user theme selected |
---|
1053 | n/a | itemList = idleConf.GetSectionList('user', 'highlight') |
---|
1054 | n/a | itemList.sort() |
---|
1055 | n/a | self.optMenuThemeCustom.SetMenu(itemList, currentOption) |
---|
1056 | n/a | itemList = idleConf.GetSectionList('default', 'highlight') |
---|
1057 | n/a | itemList.sort() |
---|
1058 | n/a | self.optMenuThemeBuiltin.SetMenu(itemList, itemList[0]) |
---|
1059 | n/a | self.SetThemeType() |
---|
1060 | n/a | ##load theme element option menu |
---|
1061 | n/a | themeNames = list(self.themeElements.keys()) |
---|
1062 | n/a | themeNames.sort(key=lambda x: self.themeElements[x][1]) |
---|
1063 | n/a | self.optMenuHighlightTarget.SetMenu(themeNames, themeNames[0]) |
---|
1064 | n/a | self.PaintThemeSample() |
---|
1065 | n/a | self.SetHighlightTarget() |
---|
1066 | n/a | |
---|
1067 | n/a | def LoadKeyCfg(self): |
---|
1068 | n/a | ##current keys type radiobutton |
---|
1069 | n/a | self.keysAreBuiltin.set(idleConf.GetOption( |
---|
1070 | n/a | 'main', 'Keys', 'default', type='bool', default=1)) |
---|
1071 | n/a | ##currently set keys |
---|
1072 | n/a | currentOption = idleConf.CurrentKeys() |
---|
1073 | n/a | ##load available keyset option menus |
---|
1074 | n/a | if self.keysAreBuiltin.get(): #default theme selected |
---|
1075 | n/a | itemList = idleConf.GetSectionList('default', 'keys') |
---|
1076 | n/a | itemList.sort() |
---|
1077 | n/a | self.optMenuKeysBuiltin.SetMenu(itemList, currentOption) |
---|
1078 | n/a | itemList = idleConf.GetSectionList('user', 'keys') |
---|
1079 | n/a | itemList.sort() |
---|
1080 | n/a | if not itemList: |
---|
1081 | n/a | self.radioKeysCustom.config(state=DISABLED) |
---|
1082 | n/a | self.customKeys.set('- no custom keys -') |
---|
1083 | n/a | else: |
---|
1084 | n/a | self.optMenuKeysCustom.SetMenu(itemList, itemList[0]) |
---|
1085 | n/a | else: #user key set selected |
---|
1086 | n/a | itemList = idleConf.GetSectionList('user', 'keys') |
---|
1087 | n/a | itemList.sort() |
---|
1088 | n/a | self.optMenuKeysCustom.SetMenu(itemList, currentOption) |
---|
1089 | n/a | itemList = idleConf.GetSectionList('default', 'keys') |
---|
1090 | n/a | itemList.sort() |
---|
1091 | n/a | self.optMenuKeysBuiltin.SetMenu(itemList, idleConf.default_keys()) |
---|
1092 | n/a | self.SetKeysType() |
---|
1093 | n/a | ##load keyset element list |
---|
1094 | n/a | keySetName = idleConf.CurrentKeys() |
---|
1095 | n/a | self.LoadKeysList(keySetName) |
---|
1096 | n/a | |
---|
1097 | n/a | def LoadGeneralCfg(self): |
---|
1098 | n/a | #startup state |
---|
1099 | n/a | self.startupEdit.set(idleConf.GetOption( |
---|
1100 | n/a | 'main', 'General', 'editor-on-startup', default=1, type='bool')) |
---|
1101 | n/a | #autosave state |
---|
1102 | n/a | self.autoSave.set(idleConf.GetOption( |
---|
1103 | n/a | 'main', 'General', 'autosave', default=0, type='bool')) |
---|
1104 | n/a | #initial window size |
---|
1105 | n/a | self.winWidth.set(idleConf.GetOption( |
---|
1106 | n/a | 'main', 'EditorWindow', 'width', type='int')) |
---|
1107 | n/a | self.winHeight.set(idleConf.GetOption( |
---|
1108 | n/a | 'main', 'EditorWindow', 'height', type='int')) |
---|
1109 | n/a | # default source encoding |
---|
1110 | n/a | self.encoding.set(idleConf.GetOption( |
---|
1111 | n/a | 'main', 'EditorWindow', 'encoding', default='none')) |
---|
1112 | n/a | # additional help sources |
---|
1113 | n/a | self.userHelpList = idleConf.GetAllExtraHelpSourcesList() |
---|
1114 | n/a | for helpItem in self.userHelpList: |
---|
1115 | n/a | self.listHelp.insert(END, helpItem[0]) |
---|
1116 | n/a | self.SetHelpListButtonStates() |
---|
1117 | n/a | |
---|
1118 | n/a | def LoadConfigs(self): |
---|
1119 | n/a | """ |
---|
1120 | n/a | load configuration from default and user config files and populate |
---|
1121 | n/a | the widgets on the config dialog pages. |
---|
1122 | n/a | """ |
---|
1123 | n/a | ### fonts / tabs page |
---|
1124 | n/a | self.LoadFontCfg() |
---|
1125 | n/a | self.LoadTabCfg() |
---|
1126 | n/a | ### highlighting page |
---|
1127 | n/a | self.LoadThemeCfg() |
---|
1128 | n/a | ### keys page |
---|
1129 | n/a | self.LoadKeyCfg() |
---|
1130 | n/a | ### general page |
---|
1131 | n/a | self.LoadGeneralCfg() |
---|
1132 | n/a | # note: extension page handled separately |
---|
1133 | n/a | |
---|
1134 | n/a | def SaveNewKeySet(self, keySetName, keySet): |
---|
1135 | n/a | """ |
---|
1136 | n/a | save a newly created core key set. |
---|
1137 | n/a | keySetName - string, the name of the new key set |
---|
1138 | n/a | keySet - dictionary containing the new key set |
---|
1139 | n/a | """ |
---|
1140 | n/a | if not idleConf.userCfg['keys'].has_section(keySetName): |
---|
1141 | n/a | idleConf.userCfg['keys'].add_section(keySetName) |
---|
1142 | n/a | for event in keySet: |
---|
1143 | n/a | value = keySet[event] |
---|
1144 | n/a | idleConf.userCfg['keys'].SetOption(keySetName, event, value) |
---|
1145 | n/a | |
---|
1146 | n/a | def SaveNewTheme(self, themeName, theme): |
---|
1147 | n/a | """ |
---|
1148 | n/a | save a newly created theme. |
---|
1149 | n/a | themeName - string, the name of the new theme |
---|
1150 | n/a | theme - dictionary containing the new theme |
---|
1151 | n/a | """ |
---|
1152 | n/a | if not idleConf.userCfg['highlight'].has_section(themeName): |
---|
1153 | n/a | idleConf.userCfg['highlight'].add_section(themeName) |
---|
1154 | n/a | for element in theme: |
---|
1155 | n/a | value = theme[element] |
---|
1156 | n/a | idleConf.userCfg['highlight'].SetOption(themeName, element, value) |
---|
1157 | n/a | |
---|
1158 | n/a | def SetUserValue(self, configType, section, item, value): |
---|
1159 | n/a | if idleConf.defaultCfg[configType].has_option(section, item): |
---|
1160 | n/a | if idleConf.defaultCfg[configType].Get(section, item) == value: |
---|
1161 | n/a | #the setting equals a default setting, remove it from user cfg |
---|
1162 | n/a | return idleConf.userCfg[configType].RemoveOption(section, item) |
---|
1163 | n/a | #if we got here set the option |
---|
1164 | n/a | return idleConf.userCfg[configType].SetOption(section, item, value) |
---|
1165 | n/a | |
---|
1166 | n/a | def SaveAllChangedConfigs(self): |
---|
1167 | n/a | "Save configuration changes to the user config file." |
---|
1168 | n/a | idleConf.userCfg['main'].Save() |
---|
1169 | n/a | for configType in self.changedItems: |
---|
1170 | n/a | cfgTypeHasChanges = False |
---|
1171 | n/a | for section in self.changedItems[configType]: |
---|
1172 | n/a | if section == 'HelpFiles': |
---|
1173 | n/a | #this section gets completely replaced |
---|
1174 | n/a | idleConf.userCfg['main'].remove_section('HelpFiles') |
---|
1175 | n/a | cfgTypeHasChanges = True |
---|
1176 | n/a | for item in self.changedItems[configType][section]: |
---|
1177 | n/a | value = self.changedItems[configType][section][item] |
---|
1178 | n/a | if self.SetUserValue(configType, section, item, value): |
---|
1179 | n/a | cfgTypeHasChanges = True |
---|
1180 | n/a | if cfgTypeHasChanges: |
---|
1181 | n/a | idleConf.userCfg[configType].Save() |
---|
1182 | n/a | for configType in ['keys', 'highlight']: |
---|
1183 | n/a | # save these even if unchanged! |
---|
1184 | n/a | idleConf.userCfg[configType].Save() |
---|
1185 | n/a | self.ResetChangedItems() #clear the changed items dict |
---|
1186 | n/a | self.save_all_changed_extensions() # uses a different mechanism |
---|
1187 | n/a | |
---|
1188 | n/a | def DeactivateCurrentConfig(self): |
---|
1189 | n/a | #Before a config is saved, some cleanup of current |
---|
1190 | n/a | #config must be done - remove the previous keybindings |
---|
1191 | n/a | winInstances = self.parent.instance_dict.keys() |
---|
1192 | n/a | for instance in winInstances: |
---|
1193 | n/a | instance.RemoveKeybindings() |
---|
1194 | n/a | |
---|
1195 | n/a | def ActivateConfigChanges(self): |
---|
1196 | n/a | "Dynamically apply configuration changes" |
---|
1197 | n/a | winInstances = self.parent.instance_dict.keys() |
---|
1198 | n/a | for instance in winInstances: |
---|
1199 | n/a | instance.ResetColorizer() |
---|
1200 | n/a | instance.ResetFont() |
---|
1201 | n/a | instance.set_notabs_indentwidth() |
---|
1202 | n/a | instance.ApplyKeybindings() |
---|
1203 | n/a | instance.reset_help_menu_entries() |
---|
1204 | n/a | |
---|
1205 | n/a | def Cancel(self): |
---|
1206 | n/a | self.destroy() |
---|
1207 | n/a | |
---|
1208 | n/a | def Ok(self): |
---|
1209 | n/a | self.Apply() |
---|
1210 | n/a | self.destroy() |
---|
1211 | n/a | |
---|
1212 | n/a | def Apply(self): |
---|
1213 | n/a | self.DeactivateCurrentConfig() |
---|
1214 | n/a | self.SaveAllChangedConfigs() |
---|
1215 | n/a | self.ActivateConfigChanges() |
---|
1216 | n/a | |
---|
1217 | n/a | def Help(self): |
---|
1218 | n/a | page = self.tabPages._current_page |
---|
1219 | n/a | view_text(self, title='Help for IDLE preferences', |
---|
1220 | n/a | text=help_common+help_pages.get(page, '')) |
---|
1221 | n/a | |
---|
1222 | n/a | def CreatePageExtensions(self): |
---|
1223 | n/a | """Part of the config dialog used for configuring IDLE extensions. |
---|
1224 | n/a | |
---|
1225 | n/a | This code is generic - it works for any and all IDLE extensions. |
---|
1226 | n/a | |
---|
1227 | n/a | IDLE extensions save their configuration options using idleConf. |
---|
1228 | n/a | This code reads the current configuration using idleConf, supplies a |
---|
1229 | n/a | GUI interface to change the configuration values, and saves the |
---|
1230 | n/a | changes using idleConf. |
---|
1231 | n/a | |
---|
1232 | n/a | Not all changes take effect immediately - some may require restarting IDLE. |
---|
1233 | n/a | This depends on each extension's implementation. |
---|
1234 | n/a | |
---|
1235 | n/a | All values are treated as text, and it is up to the user to supply |
---|
1236 | n/a | reasonable values. The only exception to this are the 'enable*' options, |
---|
1237 | n/a | which are boolean, and can be toggled with a True/False button. |
---|
1238 | n/a | """ |
---|
1239 | n/a | parent = self.parent |
---|
1240 | n/a | frame = self.tabPages.pages['Extensions'].frame |
---|
1241 | n/a | self.ext_defaultCfg = idleConf.defaultCfg['extensions'] |
---|
1242 | n/a | self.ext_userCfg = idleConf.userCfg['extensions'] |
---|
1243 | n/a | self.is_int = self.register(is_int) |
---|
1244 | n/a | self.load_extensions() |
---|
1245 | n/a | # create widgets - a listbox shows all available extensions, with the |
---|
1246 | n/a | # controls for the extension selected in the listbox to the right |
---|
1247 | n/a | self.extension_names = StringVar(self) |
---|
1248 | n/a | frame.rowconfigure(0, weight=1) |
---|
1249 | n/a | frame.columnconfigure(2, weight=1) |
---|
1250 | n/a | self.extension_list = Listbox(frame, listvariable=self.extension_names, |
---|
1251 | n/a | selectmode='browse') |
---|
1252 | n/a | self.extension_list.bind('<<ListboxSelect>>', self.extension_selected) |
---|
1253 | n/a | scroll = Scrollbar(frame, command=self.extension_list.yview) |
---|
1254 | n/a | self.extension_list.yscrollcommand=scroll.set |
---|
1255 | n/a | self.details_frame = LabelFrame(frame, width=250, height=250) |
---|
1256 | n/a | self.extension_list.grid(column=0, row=0, sticky='nws') |
---|
1257 | n/a | scroll.grid(column=1, row=0, sticky='ns') |
---|
1258 | n/a | self.details_frame.grid(column=2, row=0, sticky='nsew', padx=[10, 0]) |
---|
1259 | n/a | frame.configure(padx=10, pady=10) |
---|
1260 | n/a | self.config_frame = {} |
---|
1261 | n/a | self.current_extension = None |
---|
1262 | n/a | |
---|
1263 | n/a | self.outerframe = self # TEMPORARY |
---|
1264 | n/a | self.tabbed_page_set = self.extension_list # TEMPORARY |
---|
1265 | n/a | |
---|
1266 | n/a | # create the frame holding controls for each extension |
---|
1267 | n/a | ext_names = '' |
---|
1268 | n/a | for ext_name in sorted(self.extensions): |
---|
1269 | n/a | self.create_extension_frame(ext_name) |
---|
1270 | n/a | ext_names = ext_names + '{' + ext_name + '} ' |
---|
1271 | n/a | self.extension_names.set(ext_names) |
---|
1272 | n/a | self.extension_list.selection_set(0) |
---|
1273 | n/a | self.extension_selected(None) |
---|
1274 | n/a | |
---|
1275 | n/a | def load_extensions(self): |
---|
1276 | n/a | "Fill self.extensions with data from the default and user configs." |
---|
1277 | n/a | self.extensions = {} |
---|
1278 | n/a | for ext_name in idleConf.GetExtensions(active_only=False): |
---|
1279 | n/a | self.extensions[ext_name] = [] |
---|
1280 | n/a | |
---|
1281 | n/a | for ext_name in self.extensions: |
---|
1282 | n/a | opt_list = sorted(self.ext_defaultCfg.GetOptionList(ext_name)) |
---|
1283 | n/a | |
---|
1284 | n/a | # bring 'enable' options to the beginning of the list |
---|
1285 | n/a | enables = [opt_name for opt_name in opt_list |
---|
1286 | n/a | if opt_name.startswith('enable')] |
---|
1287 | n/a | for opt_name in enables: |
---|
1288 | n/a | opt_list.remove(opt_name) |
---|
1289 | n/a | opt_list = enables + opt_list |
---|
1290 | n/a | |
---|
1291 | n/a | for opt_name in opt_list: |
---|
1292 | n/a | def_str = self.ext_defaultCfg.Get( |
---|
1293 | n/a | ext_name, opt_name, raw=True) |
---|
1294 | n/a | try: |
---|
1295 | n/a | def_obj = {'True':True, 'False':False}[def_str] |
---|
1296 | n/a | opt_type = 'bool' |
---|
1297 | n/a | except KeyError: |
---|
1298 | n/a | try: |
---|
1299 | n/a | def_obj = int(def_str) |
---|
1300 | n/a | opt_type = 'int' |
---|
1301 | n/a | except ValueError: |
---|
1302 | n/a | def_obj = def_str |
---|
1303 | n/a | opt_type = None |
---|
1304 | n/a | try: |
---|
1305 | n/a | value = self.ext_userCfg.Get( |
---|
1306 | n/a | ext_name, opt_name, type=opt_type, raw=True, |
---|
1307 | n/a | default=def_obj) |
---|
1308 | n/a | except ValueError: # Need this until .Get fixed |
---|
1309 | n/a | value = def_obj # bad values overwritten by entry |
---|
1310 | n/a | var = StringVar(self) |
---|
1311 | n/a | var.set(str(value)) |
---|
1312 | n/a | |
---|
1313 | n/a | self.extensions[ext_name].append({'name': opt_name, |
---|
1314 | n/a | 'type': opt_type, |
---|
1315 | n/a | 'default': def_str, |
---|
1316 | n/a | 'value': value, |
---|
1317 | n/a | 'var': var, |
---|
1318 | n/a | }) |
---|
1319 | n/a | |
---|
1320 | n/a | def extension_selected(self, event): |
---|
1321 | n/a | newsel = self.extension_list.curselection() |
---|
1322 | n/a | if newsel: |
---|
1323 | n/a | newsel = self.extension_list.get(newsel) |
---|
1324 | n/a | if newsel is None or newsel != self.current_extension: |
---|
1325 | n/a | if self.current_extension: |
---|
1326 | n/a | self.details_frame.config(text='') |
---|
1327 | n/a | self.config_frame[self.current_extension].grid_forget() |
---|
1328 | n/a | self.current_extension = None |
---|
1329 | n/a | if newsel: |
---|
1330 | n/a | self.details_frame.config(text=newsel) |
---|
1331 | n/a | self.config_frame[newsel].grid(column=0, row=0, sticky='nsew') |
---|
1332 | n/a | self.current_extension = newsel |
---|
1333 | n/a | |
---|
1334 | n/a | def create_extension_frame(self, ext_name): |
---|
1335 | n/a | """Create a frame holding the widgets to configure one extension""" |
---|
1336 | n/a | f = VerticalScrolledFrame(self.details_frame, height=250, width=250) |
---|
1337 | n/a | self.config_frame[ext_name] = f |
---|
1338 | n/a | entry_area = f.interior |
---|
1339 | n/a | # create an entry for each configuration option |
---|
1340 | n/a | for row, opt in enumerate(self.extensions[ext_name]): |
---|
1341 | n/a | # create a row with a label and entry/checkbutton |
---|
1342 | n/a | label = Label(entry_area, text=opt['name']) |
---|
1343 | n/a | label.grid(row=row, column=0, sticky=NW) |
---|
1344 | n/a | var = opt['var'] |
---|
1345 | n/a | if opt['type'] == 'bool': |
---|
1346 | n/a | Checkbutton(entry_area, textvariable=var, variable=var, |
---|
1347 | n/a | onvalue='True', offvalue='False', |
---|
1348 | n/a | indicatoron=FALSE, selectcolor='', width=8 |
---|
1349 | n/a | ).grid(row=row, column=1, sticky=W, padx=7) |
---|
1350 | n/a | elif opt['type'] == 'int': |
---|
1351 | n/a | Entry(entry_area, textvariable=var, validate='key', |
---|
1352 | n/a | validatecommand=(self.is_int, '%P') |
---|
1353 | n/a | ).grid(row=row, column=1, sticky=NSEW, padx=7) |
---|
1354 | n/a | |
---|
1355 | n/a | else: |
---|
1356 | n/a | Entry(entry_area, textvariable=var |
---|
1357 | n/a | ).grid(row=row, column=1, sticky=NSEW, padx=7) |
---|
1358 | n/a | return |
---|
1359 | n/a | |
---|
1360 | n/a | def set_extension_value(self, section, opt): |
---|
1361 | n/a | name = opt['name'] |
---|
1362 | n/a | default = opt['default'] |
---|
1363 | n/a | value = opt['var'].get().strip() or default |
---|
1364 | n/a | opt['var'].set(value) |
---|
1365 | n/a | # if self.defaultCfg.has_section(section): |
---|
1366 | n/a | # Currently, always true; if not, indent to return |
---|
1367 | n/a | if (value == default): |
---|
1368 | n/a | return self.ext_userCfg.RemoveOption(section, name) |
---|
1369 | n/a | # set the option |
---|
1370 | n/a | return self.ext_userCfg.SetOption(section, name, value) |
---|
1371 | n/a | |
---|
1372 | n/a | def save_all_changed_extensions(self): |
---|
1373 | n/a | """Save configuration changes to the user config file.""" |
---|
1374 | n/a | has_changes = False |
---|
1375 | n/a | for ext_name in self.extensions: |
---|
1376 | n/a | options = self.extensions[ext_name] |
---|
1377 | n/a | for opt in options: |
---|
1378 | n/a | if self.set_extension_value(ext_name, opt): |
---|
1379 | n/a | has_changes = True |
---|
1380 | n/a | if has_changes: |
---|
1381 | n/a | self.ext_userCfg.Save() |
---|
1382 | n/a | |
---|
1383 | n/a | |
---|
1384 | n/a | help_common = '''\ |
---|
1385 | n/a | When you click either the Apply or Ok buttons, settings in this |
---|
1386 | n/a | dialog that are different from IDLE's default are saved in |
---|
1387 | n/a | a .idlerc directory in your home directory. Except as noted, |
---|
1388 | n/a | these changes apply to all versions of IDLE installed on this |
---|
1389 | n/a | machine. Some do not take affect until IDLE is restarted. |
---|
1390 | n/a | [Cancel] only cancels changes made since the last save. |
---|
1391 | n/a | ''' |
---|
1392 | n/a | help_pages = { |
---|
1393 | n/a | 'Highlighting': ''' |
---|
1394 | n/a | Highlighting: |
---|
1395 | n/a | The IDLE Dark color theme is new in October 2015. It can only |
---|
1396 | n/a | be used with older IDLE releases if it is saved as a custom |
---|
1397 | n/a | theme, with a different name. |
---|
1398 | n/a | ''', |
---|
1399 | n/a | 'Keys': ''' |
---|
1400 | n/a | Keys: |
---|
1401 | n/a | The IDLE Modern Unix key set is new in June 2016. It can only |
---|
1402 | n/a | be used with older IDLE releases if it is saved as a custom |
---|
1403 | n/a | key set, with a different name. |
---|
1404 | n/a | ''', |
---|
1405 | n/a | } |
---|
1406 | n/a | |
---|
1407 | n/a | |
---|
1408 | n/a | def is_int(s): |
---|
1409 | n/a | "Return 's is blank or represents an int'" |
---|
1410 | n/a | if not s: |
---|
1411 | n/a | return True |
---|
1412 | n/a | try: |
---|
1413 | n/a | int(s) |
---|
1414 | n/a | return True |
---|
1415 | n/a | except ValueError: |
---|
1416 | n/a | return False |
---|
1417 | n/a | |
---|
1418 | n/a | |
---|
1419 | n/a | class VerticalScrolledFrame(Frame): |
---|
1420 | n/a | """A pure Tkinter vertically scrollable frame. |
---|
1421 | n/a | |
---|
1422 | n/a | * Use the 'interior' attribute to place widgets inside the scrollable frame |
---|
1423 | n/a | * Construct and pack/place/grid normally |
---|
1424 | n/a | * This frame only allows vertical scrolling |
---|
1425 | n/a | """ |
---|
1426 | n/a | def __init__(self, parent, *args, **kw): |
---|
1427 | n/a | Frame.__init__(self, parent, *args, **kw) |
---|
1428 | n/a | |
---|
1429 | n/a | # create a canvas object and a vertical scrollbar for scrolling it |
---|
1430 | n/a | vscrollbar = Scrollbar(self, orient=VERTICAL) |
---|
1431 | n/a | vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE) |
---|
1432 | n/a | canvas = Canvas(self, bd=0, highlightthickness=0, |
---|
1433 | n/a | yscrollcommand=vscrollbar.set, width=240) |
---|
1434 | n/a | canvas.pack(side=LEFT, fill=BOTH, expand=TRUE) |
---|
1435 | n/a | vscrollbar.config(command=canvas.yview) |
---|
1436 | n/a | |
---|
1437 | n/a | # reset the view |
---|
1438 | n/a | canvas.xview_moveto(0) |
---|
1439 | n/a | canvas.yview_moveto(0) |
---|
1440 | n/a | |
---|
1441 | n/a | # create a frame inside the canvas which will be scrolled with it |
---|
1442 | n/a | self.interior = interior = Frame(canvas) |
---|
1443 | n/a | interior_id = canvas.create_window(0, 0, window=interior, anchor=NW) |
---|
1444 | n/a | |
---|
1445 | n/a | # track changes to the canvas and frame width and sync them, |
---|
1446 | n/a | # also updating the scrollbar |
---|
1447 | n/a | def _configure_interior(event): |
---|
1448 | n/a | # update the scrollbars to match the size of the inner frame |
---|
1449 | n/a | size = (interior.winfo_reqwidth(), interior.winfo_reqheight()) |
---|
1450 | n/a | canvas.config(scrollregion="0 0 %s %s" % size) |
---|
1451 | n/a | interior.bind('<Configure>', _configure_interior) |
---|
1452 | n/a | |
---|
1453 | n/a | def _configure_canvas(event): |
---|
1454 | n/a | if interior.winfo_reqwidth() != canvas.winfo_width(): |
---|
1455 | n/a | # update the inner frame's width to fill the canvas |
---|
1456 | n/a | canvas.itemconfigure(interior_id, width=canvas.winfo_width()) |
---|
1457 | n/a | canvas.bind('<Configure>', _configure_canvas) |
---|
1458 | n/a | |
---|
1459 | n/a | return |
---|
1460 | n/a | |
---|
1461 | n/a | |
---|
1462 | n/a | if __name__ == '__main__': |
---|
1463 | n/a | import unittest |
---|
1464 | n/a | unittest.main('idlelib.idle_test.test_configdialog', |
---|
1465 | n/a | verbosity=2, exit=False) |
---|
1466 | n/a | from idlelib.idle_test.htest import run |
---|
1467 | n/a | run(ConfigDialog) |
---|