configDialog cleanup. Patch 1730217 Tal Einat.

This commit is contained in:
Kurt B. Kaiser 2007-10-04 03:11:12 +00:00
parent d5f4910afd
commit e3fde8f8cd
2 changed files with 44 additions and 40 deletions

View File

@ -3,6 +3,8 @@ What's New in IDLE 2.6a1?
*Release date: XX-XXX-200X*
- configDialog cleanup. Patch 1730217 Tal Einat.
- textView cleanup. Patch 1718043 Tal Einat.
- Clean up EditorWindow close.

View File

@ -24,6 +24,8 @@ class ConfigDialog(Toplevel):
def __init__(self,parent,title):
Toplevel.__init__(self, parent)
self.wm_withdraw()
self.configure(borderwidth=5)
self.geometry("+%d+%d" % (parent.winfo_rootx()+20,
parent.winfo_rooty()+30))
@ -58,6 +60,8 @@ class ConfigDialog(Toplevel):
#self.bind('<F1>',self.Help) #context help
self.LoadConfigs()
self.AttachVarCallbacks() #avoid callbacks during LoadConfigs
self.wm_deiconify()
self.wait_window()
def CreateWidgets(self):
@ -67,22 +71,27 @@ class ConfigDialog(Toplevel):
frameActionButtons = Frame(self)
#action buttons
self.buttonHelp = Button(frameActionButtons,text='Help',
command=self.Help,takefocus=FALSE)
command=self.Help,takefocus=FALSE,
padx=6,pady=3)
self.buttonOk = Button(frameActionButtons,text='Ok',
command=self.Ok,takefocus=FALSE)
command=self.Ok,takefocus=FALSE,
padx=6,pady=3)
self.buttonApply = Button(frameActionButtons,text='Apply',
command=self.Apply,takefocus=FALSE)
command=self.Apply,takefocus=FALSE,
padx=6,pady=3)
self.buttonCancel = Button(frameActionButtons,text='Cancel',
command=self.Cancel,takefocus=FALSE)
command=self.Cancel,takefocus=FALSE,
padx=6,pady=3)
self.CreatePageFontTab()
self.CreatePageHighlight()
self.CreatePageKeys()
self.CreatePageGeneral()
self.buttonHelp.pack(side=RIGHT,padx=5,pady=5)
self.buttonOk.pack(side=LEFT,padx=5,pady=5)
self.buttonApply.pack(side=LEFT,padx=5,pady=5)
self.buttonCancel.pack(side=LEFT,padx=5,pady=5)
self.buttonHelp.pack(side=RIGHT,padx=5)
self.buttonOk.pack(side=LEFT,padx=5)
self.buttonApply.pack(side=LEFT,padx=5)
self.buttonCancel.pack(side=LEFT,padx=5)
frameActionButtons.pack(side=BOTTOM)
Frame(self, border=0).pack(side=BOTTOM,pady=2)
self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH)
def CreatePageFontTab(self):
@ -96,14 +105,15 @@ class ConfigDialog(Toplevel):
#body frame
frame=self.tabPages.pages['Fonts/Tabs']['page']
#body section frames
frameFont=Frame(frame,borderwidth=2,relief=GROOVE)
frameIndent=Frame(frame,borderwidth=2,relief=GROOVE)
frameFont=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Base Editor Font ')
frameIndent=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Indentation Width ')
#frameFont
labelFontTitle=Label(frameFont,text='Set Base Editor Font')
frameFontName=Frame(frameFont)
frameFontParam=Frame(frameFont)
labelFontNameTitle=Label(frameFontName,justify=LEFT,
text='Font :')
text='Font Face :')
self.listFontName=Listbox(frameFontName,height=5,takefocus=FALSE,
exportselection=FALSE)
self.listFontName.bind('<ButtonRelease-1>',self.OnListFontButtonRelease)
@ -124,14 +134,13 @@ class ConfigDialog(Toplevel):
labelSpaceNumTitle=Label(frameIndentSize, justify=LEFT,
text='Python Standard: 4 Spaces!')
self.scaleSpaceNum=Scale(frameIndentSize, variable=self.spaceNum,
label='Indentation Width', orient='horizontal',
orient='horizontal',
tickinterval=2, from_=2, to=16)
#widget packing
#body
frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH)
frameIndent.pack(side=LEFT,padx=5,pady=10,fill=Y)
frameFont.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
frameIndent.pack(side=LEFT,padx=5,pady=5,fill=Y)
#frameFont
labelFontTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
frameFontName.pack(side=TOP,padx=5,pady=5,fill=X)
frameFontParam.pack(side=TOP,padx=5,pady=5,fill=X)
labelFontNameTitle.pack(side=TOP,anchor=W)
@ -143,7 +152,7 @@ class ConfigDialog(Toplevel):
frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
self.labelFontSample.pack(expand=TRUE,fill=BOTH)
#frameIndent
frameIndentSize.pack(side=TOP,padx=5,pady=5,fill=BOTH)
frameIndentSize.pack(side=TOP,fill=X)
labelSpaceNumTitle.pack(side=TOP,anchor=W,padx=5)
self.scaleSpaceNum.pack(side=TOP,padx=5,fill=X)
return frame
@ -160,8 +169,10 @@ class ConfigDialog(Toplevel):
#body frame
frame=self.tabPages.pages['Highlighting']['page']
#body section frames
frameCustom=Frame(frame,borderwidth=2,relief=GROOVE)
frameTheme=Frame(frame,borderwidth=2,relief=GROOVE)
frameCustom=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Custom Highlighting ')
frameTheme=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Highlighting Theme ')
#frameCustom
self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1,
font=('courier',12,''),cursor='hand2',width=21,height=10,
@ -189,7 +200,6 @@ class ConfigDialog(Toplevel):
text.config(state=DISABLED)
self.frameColourSet=Frame(frameCustom,relief=SOLID,borderwidth=1)
frameFgBg=Frame(frameCustom)
labelCustomTitle=Label(frameCustom,text='Set Custom Highlighting')
buttonSetColour=Button(self.frameColourSet,text='Choose Colour for :',
command=self.GetColour,highlightthickness=0)
self.optMenuHighlightTarget=DynOptionMenu(self.frameColourSet,
@ -202,7 +212,6 @@ class ConfigDialog(Toplevel):
buttonSaveCustomTheme=Button(frameCustom,
text='Save as New Custom Theme',command=self.SaveAsNewTheme)
#frameTheme
labelThemeTitle=Label(frameTheme,text='Select a Highlighting Theme')
labelTypeTitle=Label(frameTheme,text='Select : ')
self.radioThemeBuiltin=Radiobutton(frameTheme,variable=self.themeIsBuiltin,
value=1,command=self.SetThemeType,text='a Built-in Theme')
@ -216,10 +225,9 @@ class ConfigDialog(Toplevel):
command=self.DeleteCustomTheme)
##widget packing
#body
frameCustom.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH)
frameTheme.pack(side=LEFT,padx=5,pady=10,fill=Y)
frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
frameTheme.pack(side=LEFT,padx=5,pady=5,fill=Y)
#frameCustom
labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
self.frameColourSet.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=X)
frameFgBg.pack(side=TOP,padx=5,pady=0)
self.textHighlightSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,
@ -230,7 +238,6 @@ class ConfigDialog(Toplevel):
self.radioBg.pack(side=RIGHT,anchor=W)
buttonSaveCustomTheme.pack(side=BOTTOM,fill=X,padx=5,pady=5)
#frameTheme
labelThemeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
self.radioThemeBuiltin.pack(side=TOP,anchor=W,padx=5)
self.radioThemeCustom.pack(side=TOP,anchor=W,padx=5,pady=2)
@ -250,11 +257,12 @@ class ConfigDialog(Toplevel):
#body frame
frame=self.tabPages.pages['Keys']['page']
#body section frames
frameCustom=Frame(frame,borderwidth=2,relief=GROOVE)
frameKeySets=Frame(frame,borderwidth=2,relief=GROOVE)
frameCustom=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Custom Key Bindings ')
frameKeySets=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Key Set ')
#frameCustom
frameTarget=Frame(frameCustom)
labelCustomTitle=Label(frameCustom,text='Set Custom Key Bindings')
labelTargetTitle=Label(frameTarget,text='Action - Key(s)')
scrollTargetY=Scrollbar(frameTarget)
scrollTargetX=Scrollbar(frameTarget,orient=HORIZONTAL)
@ -270,7 +278,6 @@ class ConfigDialog(Toplevel):
buttonSaveCustomKeys=Button(frameCustom,
text='Save as New Custom Key Set',command=self.SaveAsNewKeySet)
#frameKeySets
labelKeysTitle=Label(frameKeySets,text='Select a Key Set')
labelTypeTitle=Label(frameKeySets,text='Select : ')
self.radioKeysBuiltin=Radiobutton(frameKeySets,variable=self.keysAreBuiltin,
value=1,command=self.SetKeysType,text='a Built-in Key Set')
@ -287,7 +294,6 @@ class ConfigDialog(Toplevel):
frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
frameKeySets.pack(side=LEFT,padx=5,pady=5,fill=Y)
#frameCustom
labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
self.buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
@ -299,7 +305,6 @@ class ConfigDialog(Toplevel):
scrollTargetY.grid(row=1,column=1,sticky=NS)
scrollTargetX.grid(row=2,column=0,sticky=EW)
#frameKeySets
labelKeysTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
self.radioKeysBuiltin.pack(side=TOP,anchor=W,padx=5)
self.radioKeysCustom.pack(side=TOP,anchor=W,padx=5,pady=2)
@ -322,21 +327,22 @@ class ConfigDialog(Toplevel):
#body
frame=self.tabPages.pages['General']['page']
#body section frames
frameRun=Frame(frame,borderwidth=2,relief=GROOVE)
frameSave=Frame(frame,borderwidth=2,relief=GROOVE)
frameRun=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Startup Preferences ')
frameSave=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Autosave Preferences ')
frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
frameParaSize=Frame(frame,borderwidth=2,relief=GROOVE)
frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE)
frameHelp=Frame(frame,borderwidth=2,relief=GROOVE)
frameHelp=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Additional Help Sources ')
#frameRun
labelRunTitle=Label(frameRun,text='Startup Preferences')
labelRunChoiceTitle=Label(frameRun,text='At Startup')
radioStartupEdit=Radiobutton(frameRun,variable=self.startupEdit,
value=1,command=self.SetKeysType,text="Open Edit Window")
radioStartupShell=Radiobutton(frameRun,variable=self.startupEdit,
value=0,command=self.SetKeysType,text='Open Shell Window')
#frameSave
labelSaveTitle=Label(frameSave,text='Autosave Preference')
labelRunSaveTitle=Label(frameSave,text='At Start of Run (F5) ')
radioSaveAsk=Radiobutton(frameSave,variable=self.autoSave,
value=0,command=self.SetKeysType,text="Prompt to Save")
@ -367,7 +373,6 @@ class ConfigDialog(Toplevel):
#frameHelp
frameHelpList=Frame(frameHelp)
frameHelpListButtons=Frame(frameHelpList)
labelHelpListTitle=Label(frameHelpList,text='Additional Help Sources:')
scrollHelpList=Scrollbar(frameHelpList)
self.listHelp=Listbox(frameHelpList,height=5,takefocus=FALSE,
exportselection=FALSE)
@ -389,12 +394,10 @@ class ConfigDialog(Toplevel):
frameEncoding.pack(side=TOP,padx=5,pady=5,fill=X)
frameHelp.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
#frameRun
labelRunTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
radioStartupShell.pack(side=RIGHT,anchor=W,padx=5,pady=5)
radioStartupEdit.pack(side=RIGHT,anchor=W,padx=5,pady=5)
#frameSave
labelSaveTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
labelRunSaveTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
radioSaveAuto.pack(side=RIGHT,anchor=W,padx=5,pady=5)
radioSaveAsk.pack(side=RIGHT,anchor=W,padx=5,pady=5)
@ -415,7 +418,6 @@ class ConfigDialog(Toplevel):
#frameHelp
frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y)
frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
labelHelpListTitle.pack(side=TOP,anchor=W)
scrollHelpList.pack(side=RIGHT,anchor=W,fill=Y)
self.listHelp.pack(side=LEFT,anchor=E,expand=TRUE,fill=BOTH)
self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5)