[Python-checkins] r64004 - in sandbox/trunk/ttk-gsoc/src/idlelib: PyShell.py config-main.def configDialog.py

guilherme.polo python-checkins at python.org
Sat Jun 7 01:06:21 CEST 2008


Author: guilherme.polo
Date: Sat Jun 7 01:06:20 2008
New Revision: 64004
Log:
Added the possibility to change the display theme when running with Ttk.
Modified:
 sandbox/trunk/ttk-gsoc/src/idlelib/PyShell.py
 sandbox/trunk/ttk-gsoc/src/idlelib/config-main.def
 sandbox/trunk/ttk-gsoc/src/idlelib/configDialog.py
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/PyShell.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/PyShell.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/PyShell.py	Sat Jun 7 01:06:20 2008
@@ -862,6 +862,9 @@
 #
 self.pollinterval = 50 # millisec
 
+ if TTK:
+ self.set_theme(Style(self.root))
+
 def get_standard_extension_names(self):
 return idleConf.GetExtensions(shell_only=True)
 
@@ -878,6 +881,10 @@
 def get_warning_stream(self):
 return warning_stream
 
+ def set_theme(self, ttkstyle):
+ ttkstyle.theme_use(idleConf.GetOption('main', 'Theme',
+ 'displaytheme'))
+
 def toggle_debugger(self, event=None):
 if self.executing:
 tkMessageBox.showerror("Don't debug now",
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/config-main.def
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/config-main.def	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/config-main.def	Sat Jun 7 01:06:20 2008
@@ -49,7 +49,7 @@
 print-command-posix=lpr %s
 print-command-win=start /min notepad /p %s
 delete-exitfunc= 1
-use-ttk=0
+use-ttk = 0
 
 [EditorWindow]
 width= 80
@@ -69,6 +69,7 @@
 [Theme]
 default= 1
 name= IDLE Classic
+displaytheme = default
 
 [Keys]
 default= 1
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	Sat Jun 7 01:06:20 2008
@@ -359,6 +359,7 @@
 self.startupEdit=IntVar(self)
 self.autoSave=IntVar(self)
 self.encoding=StringVar(self)
+ self.themename = StringVar(self)
 self.userHelpBrowser=BooleanVar(self)
 self.helpBrowser=StringVar(self)
 #widget creation
@@ -372,6 +373,8 @@
 frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
 frameParaSize=Frame(frame,borderwidth=2,relief=GROOVE)
 frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE)
+ if TTK:
+ frameTheme = Frame(frame, borderwidth=2, relief=GROOVE)
 frameHelp=LabelFrame(frame,borderwidth=2,relief=GROOVE,
 text=' Additional Help Sources ')
 #frameRun
@@ -408,6 +411,11 @@
 value="utf-8",text="UTF-8")
 radioEncNone=Radiobutton(frameEncoding,variable=self.encoding,
 value="none",text="None")
+ #frameTheme
+ if TTK:
+ labelTheme = Label(frameTheme, text="Display Theme")
+ comboTheme = Combobox(frameTheme, textvariable=self.themename,
+ values=self.ttkstyle.theme_names(), state='readonly')
 #frameHelp
 frameHelpList=Frame(frameHelp)
 frameHelpListButtons=Frame(frameHelpList)
@@ -430,6 +438,8 @@
 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)
+ if TTK:
+ frameTheme.pack(side=TOP, padx=5, pady=5, fill=X)
 frameHelp.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
 #frameRun
 labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
@@ -453,6 +463,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
+ if TTK:
+ labelTheme.pack(side=LEFT, anchor=W, padx=5, pady=5)
+ comboTheme.pack(side=RIGHT, anchor=E, padx=5, pady=5)
 #frameHelp
 frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y)
 frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
@@ -483,6 +497,7 @@
 self.startupEdit.trace_variable('w',self.VarChanged_startupEdit)
 self.autoSave.trace_variable('w',self.VarChanged_autoSave)
 self.encoding.trace_variable('w',self.VarChanged_encoding)
+ self.themename.trace_variable('w', self.VarChanged_themename)
 
 def VarChanged_fontSize(self,*params):
 value=self.fontSize.get()
@@ -580,6 +595,10 @@
 value=self.encoding.get()
 self.AddChangedItem('main','EditorWindow','encoding',value)
 
+ def VarChanged_themename(self, *params):
+ value = self.themename.get()
+ self.AddChangedItem('main', 'Theme', 'displaytheme', 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
@@ -1023,6 +1042,10 @@
 self.PaintThemeSample()
 self.SetHighlightTarget()
 
+ if TTK:
+ displaytheme = idleConf.GetOption('main', 'Theme', 'displaytheme')
+ self.themename.set(displaytheme)
+
 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
@@ -1163,6 +1186,7 @@
 instance.set_notabs_indentwidth()
 instance.ApplyKeybindings()
 instance.reset_help_menu_entries()
+ instance.set_theme(self.ttkstyle)
 
 def Cancel(self):
 self.destroy()


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /