[Idle-dev] CVS: idle configDialog.py,1.15,1.16
Stephen M. Gava
elguavas@users.sourceforge.net
Sat, 03 Nov 2001 06:54:27 -0800
Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv28607
Modified Files:
configDialog.py
Log Message:
further config system work
Index: configDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configDialog.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** configDialog.py 2001/11/03 05:07:28 1.15
--- configDialog.py 2001/11/03 14:54:25 1.16
***************
*** 26,31 ****
self.geometry("+%d+%d" % (parent.winfo_rootx()+20,
parent.winfo_rooty()+30))
! #self.LoadConfig()
!
self.CreateWidgets()
self.resizable(height=FALSE,width=FALSE)
--- 26,46 ----
self.geometry("+%d+%d" % (parent.winfo_rootx()+20,
parent.winfo_rooty()+30))
! #Theme Elements. Each theme element key is it's display name.
! #The first value of the tuple is the sample area tag name.
! #The second value is the display name list sort index.
! #The third value indicates whether the element can have a foreground
! #or background colour or both.
! self.themeElements={'Normal Text':('normal','00','both'),
! 'Python Keywords':('keyword','01','both'),
! 'Python Definitions':('definition','02','both'),
! 'Python Comments':('comment','03','both'),
! 'Python Strings':('string','04','both'),
! 'Selected Text':('selected','05','both'),
! 'Found Text':('found','06','both'),
! 'Cursor':('cursor','07','fg'),
! 'Error Background':('error','08','bg'),
! 'Shell Foreground':('shfg','09','fg'),
! 'Shell Stdout Foreground':('shstdout','10','fg'),
! 'Shell Stderr Foreground':('shstderr','11','fg')}
self.CreateWidgets()
self.resizable(height=FALSE,width=FALSE)
***************
*** 44,51 ****
self.bind('<Alt-k>',self.ChangePageBinding)
self.bind('<Alt-g>',self.ChangePageBinding)
- #self.LoadOptMenuHighlightTarget()
-
self.LoadConfigs()
-
self.wait_window()
--- 59,63 ----
***************
*** 94,102 ****
def SetThemeType(self):
! if self.themeType.get()==0:
self.optMenuThemeBuiltin.config(state=NORMAL)
self.optMenuThemeCustom.config(state=DISABLED)
self.buttonDeleteCustomTheme.config(state=DISABLED)
! elif self.themeType.get()==1:
self.optMenuThemeBuiltin.config(state=DISABLED)
self.optMenuThemeCustom.config(state=NORMAL)
--- 106,114 ----
def SetThemeType(self):
! if self.themeBuiltin.get():
self.optMenuThemeBuiltin.config(state=NORMAL)
self.optMenuThemeCustom.config(state=DISABLED)
self.buttonDeleteCustomTheme.config(state=DISABLED)
! else:
self.optMenuThemeBuiltin.config(state=DISABLED)
self.optMenuThemeCustom.config(state=NORMAL)
***************
*** 114,129 ****
def GetColour(self):
rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
! title='Pick new colour for : '+self.highlightTarget.get(),
! initialcolor=self.workingTestColours['Foo-Bg'])#._root()
if colourString: #user didn't cancel
! self.workingTestColours['Foo-Bg']=colourString
! self.frameColourSet.config(bg=self.workingTestColours['Foo-Bg'])
! self.labelTestSample.config(bg=self.workingTestColours['Foo-Bg'])
! self.frameHighlightSample.config(bg=self.workingTestColours['Foo-Bg'])
! self.frameColourSet.update() #redraw after dialog
! self.frameHighlightSample.update() #redraw after dialog
! self.labelTestSample.update()
!
def SetFontSampleBinding(self,event):
self.SetFontSample()
--- 126,140 ----
def GetColour(self):
+ target=self.highlightTarget.get()
rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
! title='Pick new colour for : '+target,
! initialcolor=self.frameColourSet.cget('bg'))
if colourString: #user didn't cancel
! self.frameColourSet.config(bg=colourString)#set sample
! if self.fgHilite.get(): plane='foreground'
! else: plane='background'
! apply(self.textHighlightSample.tag_config,
! (self.themeElements[target][0],),{plane:colourString})
!
def SetFontSampleBinding(self,event):
self.SetFontSample()
***************
*** 137,155 ****
def SetHighlightTarget(self):
! if self.highlightTarget.get() in ('Cursor','Error Background'):
! #only bg colour selection is possible
self.radioFg.config(state=DISABLED)
self.radioBg.config(state=DISABLED)
self.fgHilite.set(0)
! elif self.highlightTarget.get() in ('Shell Foreground',
! 'Shell Stdout Foreground','Shell Stderr Foreground'):
! #fg and font style selection possible
self.radioFg.config(state=DISABLED)
self.radioBg.config(state=DISABLED)
self.fgHilite.set(1)
! else: #full fg/bg and font style selection possible
self.radioFg.config(state=NORMAL)
self.radioBg.config(state=NORMAL)
! self.fgHilite.set(1) #default to setting foreground properties
def CreateWidgets(self):
--- 148,164 ----
def SetHighlightTarget(self):
! colourPlane=self.themeElements[self.highlightTarget.get()][2]
! if colourPlane == 'bg':
self.radioFg.config(state=DISABLED)
self.radioBg.config(state=DISABLED)
self.fgHilite.set(0)
! elif colourPlane == 'fg':
self.radioFg.config(state=DISABLED)
self.radioBg.config(state=DISABLED)
self.fgHilite.set(1)
! elif colourPlane == 'both':
self.radioFg.config(state=NORMAL)
self.radioBg.config(state=NORMAL)
! self.fgHilite.set(1) #default to setting foreground attribute
def CreateWidgets(self):
***************
*** 292,296 ****
self.colour=StringVar()
self.fontName=StringVar()
! self.themeType=IntVar()
self.highlightTarget=StringVar()
self.highlightTarget.trace_variable('w',self.SetHighlightTargetBinding)
--- 301,305 ----
self.colour=StringVar()
self.fontName=StringVar()
! self.themeBuiltin=IntVar()
self.highlightTarget=StringVar()
self.highlightTarget.trace_variable('w',self.SetHighlightTargetBinding)
***************
*** 308,374 ****
text.bind('<Double-Button-1>',lambda e: 'break')
text.bind('<B1-Motion>',lambda e: 'break')
! text.insert(END,'#you can click in here','comment')
! text.insert(END,'\n')
! text.insert(END,'#to choose items','comment')
! text.insert(END,'\n')
! text.insert(END,'def','keyword')
! text.insert(END,' ')
! text.insert(END,'func','definition')
! text.insert(END,'(param):')
! text.insert(END,'\n ')
! text.insert(END,'"""string"""','string')
! text.insert(END,'\n var0 = ')
! text.insert(END,"'string'",'string')
! text.insert(END,'\n var1 = ')
! text.insert(END,"'selected'",'selected')
! text.insert(END,'\n var2 = ')
! text.insert(END,"'found'",'found')
! text.insert(END,'\n\n')
! text.insert(END,' error ','error')
! text.insert(END,'cursor |','cursor')
! text.insert(END,'\n ')
! text.insert(END,'shell','shell')
! text.insert(END,' ')
! text.insert(END,'stdout','shellstdout')
! text.insert(END,' ')
! text.insert(END,'stderr','shellstderr')
! text.tag_add('normal',1.0,END)
! text.tag_lower('normal')
! text.tag_bind('normal','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Normal Text'))
! text.tag_bind('comment','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Python Comments'))
! text.tag_bind('keyword','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Python Keywords'))
! text.tag_bind('definition','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Python Definitions'))
! text.tag_bind('string','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Python Strings'))
! text.tag_bind('selected','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Selected Text'))
! text.tag_bind('found','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Found Text'))
! text.tag_bind('error','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Error Background'))
! text.tag_bind('cursor','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Cursor'))
! text.tag_bind('shell','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Shell Foreground'))
! text.tag_bind('shellstdout','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Shell Stdout Foreground'))
! text.tag_bind('shellstderr','<ButtonPress-1>',
! lambda e: e.widget.winfo_toplevel().highlightTarget.set(
! 'Shell Stderr Foreground'))
text.config(state=DISABLED)
self.frameColourSet=Frame(frameCustom,relief=SOLID,borderwidth=1)
--- 317,334 ----
text.bind('<Double-Button-1>',lambda e: 'break')
text.bind('<B1-Motion>',lambda e: 'break')
! textAndTags=(('#you can click in here','comment'),('\n','normal'),
! ('#to choose items','comment'),('\n','normal'),('def','keyword'),
! (' ','normal'),('func','definition'),('(param):','normal'),
! ('\n ','normal'),('"""string"""','string'),('\n var0 = ','normal'),
! ("'string'",'string'),('\n var1 = ','normal'),("'selected'",'selected'),('\n var2 = ','normal'),
! ("'found'",'found'),('\n\n','normal'),(' error ','error'),
! ('cursor |','cursor'),('\n ','normal'),('shell','shfg'),(' ','normal'),('stdout','shstdout'),(' ','normal'),
! ('stderr','shstderr'))
! for txTa in textAndTags:
! text.insert(END,txTa[0],txTa[1])
! for element in self.themeElements.keys():
! text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>',
! lambda event,elem=element: event.widget.winfo_toplevel()
! .highlightTarget.set(elem))
text.config(state=DISABLED)
self.frameColourSet=Frame(frameCustom,relief=SOLID,borderwidth=1)
***************
*** 376,382 ****
labelCustomTitle=Label(frameCustom,text='Set Custom Highlighting')
buttonSetColour=Button(self.frameColourSet,text='Choose Colour for :',
! command=self.GetColour)
self.optMenuHighlightTarget=DynOptionMenu(self.frameColourSet,
! self.highlightTarget,None)#,command=self.SetHighlightTargetBinding
self.radioFg=Radiobutton(frameFgBg,variable=self.fgHilite,
value=1,text='Foreground')#,command=self.SetFgBg
--- 336,342 ----
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,
! self.highlightTarget,None,highlightthickness=0)#,command=self.SetHighlightTargetBinding
self.radioFg=Radiobutton(frameFgBg,variable=self.fgHilite,
value=1,text='Foreground')#,command=self.SetFgBg
***************
*** 384,392 ****
value=0,text='Background')#,command=self.SetFgBg
self.fgHilite.set(1)
- #self.labelFontTypeTitle=Label(frameFontSet,text='Font Style :')
- #self.checkFontBold=Checkbutton(frameFontSet,variable=self.fontBold,
- # onvalue='Bold',offvalue='',text='Bold')
- #self.checkFontItalic=Checkbutton(frameFontSet,variable=self.fontItalic,
- # onvalue='Italic',offvalue='',text='Italic')
buttonSaveCustomTheme=Button(frameCustom,
text='Save as a Custom Theme')
--- 344,347 ----
***************
*** 394,400 ****
labelThemeTitle=Label(frameTheme,text='Select a Highlighting Theme')
labelTypeTitle=Label(frameTheme,text='Select : ')
! self.radioThemeBuiltin=Radiobutton(frameTheme,variable=self.themeType,
value=0,command=self.SetThemeType,text='a Built-in Theme')
! self.radioThemeCustom=Radiobutton(frameTheme,variable=self.themeType,
value=1,command=self.SetThemeType,text='a Custom Theme')
self.optMenuThemeBuiltin=DynOptionMenu(frameTheme,
--- 349,355 ----
labelThemeTitle=Label(frameTheme,text='Select a Highlighting Theme')
labelTypeTitle=Label(frameTheme,text='Select : ')
! self.radioThemeBuiltin=Radiobutton(frameTheme,variable=self.themeBuiltin,
value=0,command=self.SetThemeType,text='a Built-in Theme')
! self.radioThemeCustom=Radiobutton(frameTheme,variable=self.themeBuiltin,
value=1,command=self.SetThemeType,text='a Custom Theme')
self.optMenuThemeBuiltin=DynOptionMenu(frameTheme,
***************
*** 413,418 ****
self.textHighlightSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,
fill=BOTH)
! buttonSetColour.pack(side=TOP,expand=TRUE,fill=X,padx=5,pady=3)
! self.optMenuHighlightTarget.pack(side=TOP,expand=TRUE,fill=X,padx=5,pady=3)
self.radioFg.pack(side=LEFT,anchor=E)
self.radioBg.pack(side=RIGHT,anchor=W)
--- 368,373 ----
self.textHighlightSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,
fill=BOTH)
! buttonSetColour.pack(side=TOP,expand=TRUE,fill=X,padx=8,pady=4)
! self.optMenuHighlightTarget.pack(side=TOP,expand=TRUE,fill=X,padx=8,pady=3)
self.radioFg.pack(side=LEFT,anchor=E)
self.radioBg.pack(side=RIGHT,anchor=W)
***************
*** 580,583 ****
--- 535,541 ----
return frame
+ def PaintThemeSample(self):
+ pass
+
def LoadFontCfg(self):
##base editor font selection list
***************
*** 612,622 ****
self.tabCols.set(tabCols)
! def LoadThemeLists(self):
##current theme type radiobutton
! self.themeType.set(idleConf.GetOption('main','Theme','user',type='int'))
##currently set theme
currentOption=idleConf.GetOption('main','Theme','name')
##load available theme option menus
! if self.themeType.get() == 0: #default theme selected
itemList=idleConf.GetSectionList('default','highlight')
self.optMenuThemeBuiltin.SetMenu(itemList,currentOption)
--- 570,580 ----
self.tabCols.set(tabCols)
! def LoadThemeCfg(self):
##current theme type radiobutton
! self.themeBuiltin.set(idleConf.GetOption('main','Theme','user',type='int'))
##currently set theme
currentOption=idleConf.GetOption('main','Theme','name')
##load available theme option menus
! if self.themeBuiltin.get(): #default theme selected
itemList=idleConf.GetSectionList('default','highlight')
self.optMenuThemeBuiltin.SetMenu(itemList,currentOption)
***************
*** 627,631 ****
else:
self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
! elif self.themeType.get() == 1: #user theme selected
itemList=idleConf.GetSectionList('user','highlight')
self.optMenuThemeCustom.SetMenu(itemList,currentOption)
--- 585,589 ----
else:
self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
! else: #user theme selected
itemList=idleConf.GetSectionList('user','highlight')
self.optMenuThemeCustom.SetMenu(itemList,currentOption)
***************
*** 634,644 ****
self.SetThemeType()
##load theme element option menu
! elements=('Normal Text','Python Keywords','Python Definitions',
! 'Python Comments','Python Strings','Selected Text',
! 'Found Text','Cursor','Error Background','Shell Foreground',
! 'Shell Stdout Foreground','Shell Stderr Foreground')
! self.optMenuHighlightTarget.SetMenu(elements,elements[0])
! def LoadKeyLists(self):
##current keys type radiobutton
self.keysType.set(idleConf.GetOption('main','Keys','user',type='int'))
--- 592,606 ----
self.SetThemeType()
##load theme element option menu
! themeNames=self.themeElements.keys()
! themeNames.sort(self.__ThemeNameIndexCompare)
! self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
! self.PaintThemeSample()
!
! def __ThemeNameIndexCompare(self,a,b):
! if self.themeElements[a][1]<self.themeElements[b][1]: return -1
! elif self.themeElements[a][1]==self.themeElements[b][1]: return 0
! else: return 1
! def LoadKeyCfg(self):
##current keys type radiobutton
self.keysType.set(idleConf.GetOption('main','Keys','user',type='int'))
***************
*** 672,678 ****
self.LoadTabCfg()
### highlighting page
! self.LoadThemeLists()
### keys page
! self.LoadKeyLists()
### help page
### general page
--- 634,640 ----
self.LoadTabCfg()
### highlighting page
! self.LoadThemeCfg()
### keys page
! self.LoadKeyCfg()
### help page
### general page