[Python-checkins] r65427 - in sandbox/trunk/ttk-gsoc/src/idlelib: ColorDelegator.py configDialog.py configHandler.py

guilherme.polo python-checkins at python.org
Sun Aug 3 04:21:44 CEST 2008


Author: guilherme.polo
Date: Sun Aug  3 04:21:44 2008
New Revision: 65427

Log:
Added an option to load modules and open files in new tabs instead of creating
new windows;
Started adding support for bold in theme highlight, but left commented for now.
Minor touches around configDialog.


Modified:
   sandbox/trunk/ttk-gsoc/src/idlelib/ColorDelegator.py
   sandbox/trunk/ttk-gsoc/src/idlelib/configDialog.py
   sandbox/trunk/ttk-gsoc/src/idlelib/configHandler.py

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/ColorDelegator.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/ColorDelegator.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/ColorDelegator.py	Sun Aug  3 04:21:44 2008
@@ -182,8 +182,7 @@
             ok = False
             while not ok:
                 mark = next
-                next = self.index(mark + "+%d lines linestart" %
-                                         lines_to_get)
+                next = self.index(mark + "+%d lines linestart" % lines_to_get)
                 lines_to_get = min(lines_to_get * 2, 100)
                 ok = "SYNC" in self.tag_names(next + "-1c")
                 line = self.get(mark, next)

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/configDialog.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/configDialog.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/configDialog.py	Sun Aug  3 04:21:44 2008
@@ -10,10 +10,10 @@
 """
 from Tkinter import Toplevel, Frame, Button, Scale, Label, LabelFrame, Text, \
                     Listbox, Scrollbar, Checkbutton, Radiobutton, Entry, \
-                    StringVar, BooleanVar, IntVar
+                    Checkbutton, StringVar, BooleanVar, IntVar
 from Tkconstants import LEFT, RIGHT, BOTTOM, TOP, BOTH, GROOVE, SOLID, NONE, \
                         END, DISABLED, NSEW, Y, X, W, E, HORIZONTAL, NS, EW, \
-                        ANCHOR, NORMAL
+                        N, ANCHOR, NORMAL
 import tkMessageBox, tkColorChooser, tkFont
 
 from stylist import PoorManStyle
@@ -28,7 +28,8 @@
 TTK = idleConf.GetOption('main', 'General', 'use-ttk', type='int')
 if TTK:
     from ttk import Frame, Button, Checkbutton, LabelFrame, LabeledScale, \
-                    Combobox, Entry, Radiobutton, Scrollbar, Label, Style
+                    Combobox, Checkbutton, Entry, Radiobutton, Scrollbar, \
+                    Label, Style
 
 class ConfigDialog(Toplevel):
 
@@ -194,95 +195,107 @@
         return frame
 
     def CreatePageHighlight(self):
-        self.builtinTheme=StringVar(self)
-        self.customTheme=StringVar(self)
-        self.fgHilite=BooleanVar(self)
-        self.colour=StringVar(self)
-        self.fontName=StringVar(self)
-        self.themeIsBuiltin=BooleanVar(self)
-        self.highlightTarget=StringVar(self)
+        self.builtinTheme = StringVar(self)
+        self.customTheme = StringVar(self)
+        self.fgHilite = BooleanVar(self)
+        self.colour = StringVar(self)
+        self.fontName = StringVar(self)
+        self.themeIsBuiltin = BooleanVar(self)
+        self.highlightTarget = StringVar(self)
+        #self.themeFontBold = BooleanVar(self)
         ##widget creation
         #body frame
-        frame=self.tabPages.pages['Highlighting'].frame
+        frame = self.tabPages.pages['Highlighting'].frame
         #body section frames
-        frameCustom=LabelFrame(frame,borderwidth=2,relief=GROOVE,
-                               text=' Custom Highlighting ')
-        frameTheme=LabelFrame(frame,borderwidth=2,relief=GROOVE,
-                              text=' Highlighting Theme ')
+        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=11,
-            takefocus=False,highlightthickness=0,wrap=NONE)
-        text=self.textHighlightSample
-        text.bind('<Double-Button-1>',lambda e: 'break')
-        text.bind('<B1-Motion>',lambda e: 'break')
-        textAndTags=(('#you can click 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'",'hilite'),
-            ('\n  var2 = ','normal'),("'found'",'hit'),
-            ('\n  var3 = ','normal'),('list', 'builtin'), ('(','normal'),
-            ('None', 'builtin'),(')\n\n','normal'),
-            (' error ','error'),(' ','normal'),('cursor |','cursor'),
-            ('\n ','normal'),('shell','console'),(' ','normal'),('stdout','stdout'),
-            (' ','normal'),('stderr','stderr'),('\n','normal'))
+        self.textHighlightSample = Text(frameCustom, relief=SOLID,
+            borderwidth=1, font=('courier', 12, ''), cursor='hand2', width=21,
+            height=11, takefocus=False, highlightthickness=0, wrap=NONE)
+        text = self.textHighlightSample
+        text.bind('<Double-Button-1>', lambda e: 'break')
+        text.bind('<B1-Motion>', lambda e: 'break')
+        textAndTags = (
+            ('#you can click 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'", 'hilite'),
+            ('\n  var2 = ', 'normal'), ("'found'", 'hit'),
+            ('\n  var3 = ', 'normal'), ('list', 'builtin'), ('(', 'normal'),
+            ('None', 'builtin'), (')\n\n', 'normal'),
+            (' error ', 'error'), (' ', 'normal'), ('cursor |', 'cursor'),
+            ('\n ', 'normal'), ('shell', 'console'), (' ', 'normal'),
+            ('stdout', 'stdout'), (' ', 'normal'), ('stderr', 'stderr'),
+            ('\n', 'normal')
+        )
         for txTa in textAndTags:
-            text.insert(END,txTa[0],txTa[1])
+            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.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)
+        self.frameColourSet = Frame(frameCustom, relief=SOLID, borderwidth=1)
         self.style(self.frameColourSet, 'Color.TFrame')
 
-        frameFgBg=Frame(frameCustom)
-        buttonSetColour=Button(self.frameColourSet,text='Choose Colour for :',
-            command=self.GetColour) # XXX
-        self.optMenuHighlightTarget=DynOptionMenu(self.frameColourSet,
-            self.highlightTarget, None) # XXX
-        self.radioFg=Radiobutton(frameFgBg,variable=self.fgHilite,
-            value=1,text='Foreground',command=self.SetColourSampleBinding)
-        self.radioBg=Radiobutton(frameFgBg,variable=self.fgHilite,
-            value=0,text='Background',command=self.SetColourSampleBinding)
+        frameFgBg = Frame(frameCustom)
+        buttonSetColour = Button(self.frameColourSet,
+            text='Choose Colour for :', command=self.GetColour)
+        self.optMenuHighlightTarget = DynOptionMenu(self.frameColourSet,
+            self.highlightTarget, None)
+        #self.optBoldText = Checkbutton(self.frameColourSet, text="Bold",
+        #    variable=self.themeFontBold)
+        self.radioFg = Radiobutton(frameFgBg, variable=self.fgHilite,
+            value=1, text='Foreground', command=self.SetColourSampleBinding)
+        self.radioBg = Radiobutton(frameFgBg, variable=self.fgHilite,
+            value=0, text='Background', command=self.SetColourSampleBinding)
         self.fgHilite.set(1)
-        buttonSaveCustomTheme=Button(frameCustom,
-            text='Save as New Custom Theme',command=self.SaveAsNewTheme)
+        buttonSaveCustomTheme = Button(frameCustom,
+            text='Save as New Custom Theme', command=self.SaveAsNewTheme)
         #frameTheme
-        labelTypeTitle=Label(frameTheme,text='Select : ')
-        self.radioThemeBuiltin=Radiobutton(frameTheme,variable=self.themeIsBuiltin,
-            value=1,command=self.SetThemeType,text='a Built-in Theme')
-        self.radioThemeCustom=Radiobutton(frameTheme,variable=self.themeIsBuiltin,
-            value=0,command=self.SetThemeType,text='a Custom Theme')
-        self.optMenuThemeBuiltin=DynOptionMenu(frameTheme,
-            self.builtinTheme,None,command=None)
-        self.optMenuThemeCustom=DynOptionMenu(frameTheme,
-            self.customTheme,None,command=None)
-        self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme',
-                command=self.DeleteCustomTheme)
+        labelTypeTitle = Label(frameTheme, text='Select : ')
+        self.radioThemeBuiltin = Radiobutton(frameTheme,
+            variable=self.themeIsBuiltin, value=1,
+            command=self.SetThemeType, text='a Built-in Theme')
+        self.radioThemeCustom = Radiobutton(frameTheme,
+            variable=self.themeIsBuiltin, value=0,
+            command=self.SetThemeType, text='a Custom Theme')
+        self.optMenuThemeBuiltin = DynOptionMenu(frameTheme,
+            self.builtinTheme, None, command=None)
+        self.optMenuThemeCustom = DynOptionMenu(frameTheme,
+            self.customTheme, None, command=None)
+        self.buttonDeleteCustomTheme = Button(frameTheme,
+            text='Delete Custom Theme', command=self.DeleteCustomTheme)
         ##widget packing
         #body
-        frameCustom.pack(side=LEFT,padx=5,pady=5,expand=True,fill=BOTH)
-        frameTheme.pack(side=LEFT,padx=5,pady=5,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
-        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,
+        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,
             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)
-        buttonSaveCustomTheme.pack(side=BOTTOM,fill=X,padx=5,pady=5)
+        buttonSetColour.pack(side=TOP, expand=True, fill=X, padx=8, pady=4)
+        self.optMenuHighlightTarget.pack(side=LEFT, anchor=N, expand=True,
+            fill=X, padx=8, pady=3)
+        #self.optBoldText.pack(side=RIGHT, anchor=N, padx=8, pady=3)
+        self.radioFg.pack(side=LEFT, anchor=E)
+        self.radioBg.pack(side=RIGHT, anchor=W)
+        buttonSaveCustomTheme.pack(side=BOTTOM, fill=X, padx=5, pady=5)
         #frameTheme
-        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)
-        self.optMenuThemeBuiltin.pack(side=TOP,fill=X,padx=5,pady=5)
-        self.optMenuThemeCustom.pack(side=TOP,fill=X,anchor=W,padx=5,pady=5)
-        self.buttonDeleteCustomTheme.pack(side=TOP,fill=X,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)
+        self.optMenuThemeBuiltin.pack(side=TOP, fill=X, padx=5, pady=5)
+        self.optMenuThemeCustom.pack(side=TOP, fill=X, anchor=W, padx=5, pady=5)
+        self.buttonDeleteCustomTheme.pack(side=TOP, fill=X, padx=5, pady=5)
         return frame
 
     def CreatePageKeys(self):
@@ -359,15 +372,16 @@
 
     def CreatePageGeneral(self):
         #tkVars
-        self.winWidth=StringVar(self)
-        self.winHeight=StringVar(self)
-        self.paraWidth=StringVar(self)
-        self.startupEdit=IntVar(self)
-        self.autoSave=IntVar(self)
-        self.encoding=StringVar(self)
+        self.winWidth = StringVar(self)
+        self.winHeight = StringVar(self)
+        self.paraWidth = StringVar(self)
+        self.startupEdit = IntVar(self)
+        self.autoSave = IntVar(self)
+        self.encoding = StringVar(self)
         self.themename = StringVar(self)
-        self.userHelpBrowser=BooleanVar(self)
-        self.helpBrowser=StringVar(self)
+        self.fileintab = BooleanVar(self)
+        self.userHelpBrowser = BooleanVar(self)
+        self.helpBrowser = StringVar(self)
         #widget creation
         #body
         frame=self.tabPages.pages['General'].frame
@@ -379,6 +393,7 @@
         frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
         frameParaSize=Frame(frame,borderwidth=2,relief=GROOVE)
         frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE)
+        frameModTab = Frame(frame, borderwidth=2, relief=GROOVE)
         if TTK:
             frameTheme = Frame(frame, borderwidth=2, relief=GROOVE)
         frameHelp=LabelFrame(frame,borderwidth=2,relief=GROOVE,
@@ -417,6 +432,10 @@
             value="utf-8",text="UTF-8")
         radioEncNone=Radiobutton(frameEncoding,variable=self.encoding,
             value="none",text="None")
+        # frameModTab
+        labelMTab = Label(frameModTab, text="Open files and modules in tabs")
+        checkMTab = Checkbutton(frameModTab, variable=self.fileintab,
+            text="Yes")
         #frameTheme
         if TTK:
             labelTheme = Label(frameTheme, text="Display Theme")
@@ -426,7 +445,7 @@
         frameHelpList=Frame(frameHelp)
         frameHelpListButtons=Frame(frameHelpList)
         scrollHelpList=Scrollbar(frameHelpList)
-        self.listHelp=Listbox(frameHelpList,height=5,takefocus=False,
+        self.listHelp=Listbox(frameHelpList, height=4, takefocus=False,
                 exportselection=False)
         scrollHelpList.config(command=self.listHelp.yview)
         self.listHelp.config(yscrollcommand=scrollHelpList.set)
@@ -444,6 +463,7 @@
         frameWinSize.pack(side=TOP,padx=5,pady=5,fill=X)
         frameParaSize.pack(side=TOP,padx=5,pady=5,fill=X)
         frameEncoding.pack(side=TOP,padx=5,pady=5,fill=X)
+        frameModTab.pack(side=TOP, padx=5, pady=5, fill=X)
         if TTK:
             frameTheme.pack(side=TOP, padx=5, pady=5, fill=X)
         frameHelp.pack(side=TOP,padx=5,pady=5,expand=True,fill=BOTH)
@@ -469,7 +489,10 @@
         radioEncNone.pack(side=RIGHT,anchor=E,pady=5)
         radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5)
         radioEncLocale.pack(side=RIGHT,anchor=E,pady=5)
-        #franeTheme
+        #frameModTab
+        labelMTab.pack(side=LEFT, anchor=W, padx=5, pady=5)
+        checkMTab.pack(side=RIGHT, anchor=E, padx=5, pady=5)
+        #frameTheme
         if TTK:
             labelTheme.pack(side=LEFT, anchor=W, padx=5, pady=5)
             comboTheme.pack(side=RIGHT, anchor=E, padx=5, pady=5)
@@ -481,6 +504,7 @@
         self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5)
         self.buttonHelpListAdd.pack(side=TOP,anchor=W)
         self.buttonHelpListRemove.pack(side=TOP,anchor=W,pady=5)
+
         return frame
 
     def AttachVarCallbacks(self):
@@ -489,6 +513,7 @@
         self.fontBold.trace_variable('w',self.VarChanged_fontBold)
         self.spaceNum.trace_variable('w',self.VarChanged_spaceNum)
         self.colour.trace_variable('w',self.VarChanged_colour)
+        #self.themeFontBold.trace_variable('w', self.VarChanged_themeFontBold)
         self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme)
         self.customTheme.trace_variable('w',self.VarChanged_customTheme)
         self.themeIsBuiltin.trace_variable('w',self.VarChanged_themeIsBuiltin)
@@ -504,6 +529,7 @@
         self.autoSave.trace_variable('w',self.VarChanged_autoSave)
         self.encoding.trace_variable('w',self.VarChanged_encoding)
         self.themename.trace_variable('w', self.VarChanged_themename)
+        self.fileintab.trace_variable('w', self.VarChanged_fileintab)
 
     def VarChanged_fontSize(self,*params):
         value=self.fontSize.get()
@@ -524,6 +550,9 @@
     def VarChanged_colour(self,*params):
         self.OnNewColourSet()
 
+    #def VarChanged_themeFontBold(self, *params):
+    #    self.OnBoldChanged()
+
     def VarChanged_builtinTheme(self,*params):
         value=self.builtinTheme.get()
         self.AddChangedItem('main','Theme','name',value)
@@ -605,6 +634,10 @@
         value = self.themename.get()
         self.AddChangedItem('main', 'Theme', 'displaytheme', value)
 
+    def VarChanged_fileintab(self, *params):
+        value = self.fileintab.get()
+        self.AddChangedItem('main', 'EditorWindow', 'file-in-tab', value)
+
     def ResetChangedItems(self):
         #When any config item is changed in this dialog, an entry
         #should be made in the relevant section (config type) of this
@@ -614,10 +647,10 @@
         self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
 
     def AddChangedItem(self,type,section,item,value):
-        value=str(value) #make sure we use a string
+        value = str(value) #make sure we use a string
         if not self.changedItems[type].has_key(section):
-            self.changedItems[type][section]={}
-        self.changedItems[type][section][item]=value
+            self.changedItems[type][section] = {}
+        self.changedItems[type][section][item] = value
 
     def GetDefaultItems(self):
         dItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
@@ -756,9 +789,9 @@
 
     def DeleteCustomKeys(self):
         keySetName=self.customKeys.get()
-        if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+
-                                     'to delete the key set %r ?' % (keySetName),
-                                     parent=self):
+        if not tkMessageBox.askyesno("Delete Key Set",
+            "Are you sure you wish to delete the key set %r ?" % keySetName,
+            parent=self):
             return
         #remove key set from config
         idleConf.userCfg['keys'].remove_section(keySetName)
@@ -767,25 +800,26 @@
         #write changes
         idleConf.userCfg['keys'].Save()
         #reload user key set list
-        itemList=idleConf.GetSectionList('user','keys')
+        itemList = idleConf.GetSectionList('user', 'keys')
         itemList.sort()
         if not itemList:
             self.radioKeysCustom.config(state=DISABLED)
-            self.optMenuKeysCustom.SetMenu(itemList,'- no custom keys -')
+            self.optMenuKeysCustom.SetMenu(itemList, "- no custom keys -")
         else:
             self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
         #revert to default key set
-        self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys','default'))
-        self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys','name'))
+        self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys',
+            'default'))
+        self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys', 'name'))
         #user can't back out of these changes, they must be applied now
         self.Apply()
         self.SetKeysType()
 
     def DeleteCustomTheme(self):
-        themeName=self.customTheme.get()
-        if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
-                                     'to delete the theme %r ?' % (themeName,),
-                                     parent=self):
+        themeName = self.customTheme.get()
+        if not tkMessageBox.askyesno("Delete Theme",
+            "Are you sure you wish to delete the theme %r ?" % themeName,
+            parent=self):
             return
         #remove theme from config
         idleConf.userCfg['highlight'].remove_section(themeName)
@@ -794,16 +828,17 @@
         #write changes
         idleConf.userCfg['highlight'].Save()
         #reload user theme list
-        itemList=idleConf.GetSectionList('user','highlight')
+        itemList = idleConf.GetSectionList('user', 'highlight')
         itemList.sort()
         if not itemList:
             self.radioThemeCustom.config(state=DISABLED)
-            self.optMenuThemeCustom.SetMenu(itemList,'- no custom themes -')
+            self.optMenuThemeCustom.SetMenu(itemList, "- no custom themes -")
         else:
-            self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
+            self.optMenuThemeCustom.SetMenu(itemList, itemList[0])
         #revert to default theme
-        self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme','default'))
-        self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme','name'))
+        self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme',
+            'default'))
+        self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme', 'name'))
         #user can't back out of these changes, they must be applied now
         self.Apply()
         self.SetThemeType()
@@ -833,11 +868,27 @@
         if self.fgHilite.get(): plane='foreground'
         else: plane='background'
         sampleElement=self.themeElements[self.highlightTarget.get()][0]
-        self.textHighlightSample.tag_config(sampleElement, **{plane:newColour})
+        self.textHighlightSample.tag_config(sampleElement, **{plane: newColour})
         theme=self.customTheme.get()
         themeElement=sampleElement+'-'+plane
         self.AddChangedItem('highlight',theme,themeElement,newColour)
 
+    #def OnBoldChanged(self):
+    #    bold = self.themeFontBold.get() and tkFont.BOLD or tkFont.NORMAL
+    #    sampleElement = self.themeElements[self.highlightTarget.get()][0]
+
+    #    #fontName = self.fontName.get()
+    #    #self.textHighlightSample.tag_config(sampleElement,
+    #    #    font=(fontName, self.fontSize.get(), bold))
+
+    #    self.textHighlightSample.tag_config(sampleElement,
+    #        font=('courier', 12, bold))
+
+    #    theme = self.customTheme.get()
+    #    themeElement = "%s-%s" % (sampleElement, 'bold')
+    #    self.AddChangedItem('highlight', theme, themeElement,
+    #        (bold == tkFont.BOLD) and 1 or 0)
+
     def GetNewThemeName(self,message):
         # XXX idle bug here
         usedNames=(idleConf.GetSectionList('user','highlight')+
@@ -898,37 +949,45 @@
             self.radioFg.config(state=NORMAL)
             self.radioBg.config(state=NORMAL)
             self.fgHilite.set(1)
+        #tag = self.themeElements[self.highlightTarget.get()][0]
+        #font = self.textHighlightSample.tag_cget(tag, 'font')
+        #if font:
+        #    self.themeFontBold.set(font.split()[2] == tkFont.BOLD)
+        #else:
+        #    self.themeFontBold.set(0)
         self.SetColourSample()
 
     def SetColourSampleBinding(self,*args):
         self.SetColourSample()
 
     def SetColourSample(self):
-        #set the colour smaple area
-        tag=self.themeElements[self.highlightTarget.get()][0]
-        if self.fgHilite.get(): plane='foreground'
-        else: plane='background'
-        colour=self.textHighlightSample.tag_cget(tag,plane)
+        # set the colour sample area
+        tag = self.themeElements[self.highlightTarget.get()][0]
+        if self.fgHilite.get():
+            plane = 'foreground'
+        else:
+            plane = 'background'
+        colour = self.textHighlightSample.tag_cget(tag, plane)
         self.ttkstyle.configure('Color.TFrame', background=colour)
 
     def PaintThemeSample(self):
         if self.themeIsBuiltin.get(): #a default theme
-            theme=self.builtinTheme.get()
+            theme = self.builtinTheme.get()
         else: #a user theme
-            theme=self.customTheme.get()
+            theme = self.customTheme.get()
         for elementTitle in self.themeElements.keys():
-            element=self.themeElements[elementTitle][0]
-            colours=idleConf.GetHighlight(theme,element)
-            if element=='cursor': #cursor sample needs special painting
-                colours['background']=idleConf.GetHighlight(theme,
-                        'normal', fgBg='bg')
+            element = self.themeElements[elementTitle][0]
+            colours = idleConf.GetHighlight(theme, element)
+            if element == 'cursor': #cursor sample needs special painting
+                colours['background'] = idleConf.GetHighlight(theme,
+                    'normal', fgBg='bg')
             #handle any unsaved changes to this theme
             if theme in self.changedItems['highlight'].keys():
-                themeDict=self.changedItems['highlight'][theme]
-                if themeDict.has_key(element+'-foreground'):
-                    colours['foreground']=themeDict[element+'-foreground']
-                if themeDict.has_key(element+'-background'):
-                    colours['background']=themeDict[element+'-background']
+                themeDict = self.changedItems['highlight'][theme]
+                if themeDict.has_key(element + '-foreground'):
+                    colours['foreground'] = themeDict[element + '-foreground']
+                if themeDict.has_key(element + '-background'):
+                    colours['background'] = themeDict[element + '-background']
             self.textHighlightSample.tag_config(element, **colours)
         self.SetColourSample()
 
@@ -1017,34 +1076,34 @@
 
     def LoadThemeCfg(self):
         ##current theme type radiobutton
-        self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default',
-            type='bool',default=1))
+        self.themeIsBuiltin.set(idleConf.GetOption('main', 'Theme', 'default',
+            type='bool', default=1))
         ##currently set theme
-        currentOption=idleConf.CurrentTheme()
+        currentOption = idleConf.CurrentTheme()
         ##load available theme option menus
         if self.themeIsBuiltin.get(): #default theme selected
-            itemList=idleConf.GetSectionList('default','highlight')
+            itemList = idleConf.GetSectionList('default', 'highlight')
             itemList.sort()
-            self.optMenuThemeBuiltin.SetMenu(itemList,currentOption)
-            itemList=idleConf.GetSectionList('user','highlight')
+            self.optMenuThemeBuiltin.SetMenu(itemList, currentOption)
+            itemList = idleConf.GetSectionList('user', 'highlight')
             itemList.sort()
             if not itemList:
                 self.radioThemeCustom.config(state=DISABLED)
-                self.customTheme.set('- no custom themes -')
+                self.customTheme.set("- no custom themes -")
             else:
                 self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
         else: #user theme selected
-            itemList=idleConf.GetSectionList('user','highlight')
+            itemList = idleConf.GetSectionList('user', 'highlight')
             itemList.sort()
-            self.optMenuThemeCustom.SetMenu(itemList,currentOption)
-            itemList=idleConf.GetSectionList('default','highlight')
+            self.optMenuThemeCustom.SetMenu(itemList, currentOption)
+            itemList = idleConf.GetSectionList('default', 'highlight')
             itemList.sort()
-            self.optMenuThemeBuiltin.SetMenu(itemList,itemList[0])
+            self.optMenuThemeBuiltin.SetMenu(itemList, itemList[0])
         self.SetThemeType()
         ##load theme element option menu
-        themeNames=self.themeElements.keys()
+        themeNames = self.themeElements.keys()
         themeNames.sort(self.__ThemeNameIndexCompare)
-        self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
+        self.optMenuHighlightTarget.SetMenu(themeNames, themeNames[0])
         self.PaintThemeSample()
         self.SetHighlightTarget()
 
@@ -1103,6 +1162,9 @@
         # default source encoding
         self.encoding.set(idleConf.GetOption('main', 'EditorPage',
             'encoding', default='none'))
+        # open files/modules in tabs
+        self.fileintab.set(idleConf.GetOption('main', 'EditorWindow',
+            'file-in-tab', default=1, type='bool'))
         # additional help sources
         self.userHelpList = idleConf.GetAllExtraHelpSourcesList()
         for helpItem in self.userHelpList:

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/configHandler.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/configHandler.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/configHandler.py	Sun Aug  3 04:21:44 2008
@@ -295,7 +295,10 @@
             back=themeDict['normal-background']
         else:
             back=themeDict[element+'-background']
-        highlight={"foreground": fore,"background": back}
+        #bold = 0
+        #if  element + '-bold' in themeDict:
+        #    bold = themeDict[element + '-bold']
+        highlight={"foreground": fore, "background": back}#, "font": bold}
         if not fgBg: #return dict of both colours
             return highlight
         else: #return specified colour only


More information about the Python-checkins mailing list