[Python-checkins] r63245 - sandbox/trunk/ttk-gsoc/samples/widget_state.py

guilherme.polo python-checkins at python.org
Thu May 15 00:27:10 CEST 2008


Author: guilherme.polo
Date: Thu May 15 00:27:10 2008
New Revision: 63245

Log:
Fixed a bug related to font sizes not being given in pixels size
depending on the platform (Windows).


Modified:
   sandbox/trunk/ttk-gsoc/samples/widget_state.py

Modified: sandbox/trunk/ttk-gsoc/samples/widget_state.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/widget_state.py	(original)
+++ sandbox/trunk/ttk-gsoc/samples/widget_state.py	Thu May 15 00:27:10 2008
@@ -29,13 +29,11 @@
         self.style = ttk.Style()
 
         # get default font size and family
-        button_font = self.style.lookup("TButton", "-font")
-        font_size = self.tk.eval("font configure %s -size" % button_font)
-        font_size = int(font_size[1:])
-        font_family = self.tk.eval("font configure %s -family" % button_font)
-
-        self.font_family = font_family
-        self.base_font_size = font_size
+        btn_font = self.style.lookup("TButton", "-font")
+        fsize = self.tk.eval("font configure %s -size" % btn_font)
+        self.font_family = self.tk.eval("font configure %s -family" % btn_font)
+        self.fsize_prefix = fsize[0] if fsize[0] == '-' else ''
+        self.base_fsize = int(fsize[1 if fsize[0] == '-' else 0:])
 
         # a list to hold all the widgets that will have their states changed
         self.update_widgets = [] 
@@ -43,8 +41,8 @@
         self._setup_widgets()
 
     def _set_font(self, extra=0):
-        self.style.configure("TButton", font="%s -%d" % (self.font_family, 
-            self.base_font_size + extra))
+        self.style.configure("TButton", font="%s %s%d" % (self.font_family, 
+            self.fsize_prefix, self.base_fsize + extra))
 
     def _new_state(self, widget, newtext):
         widget = self.nametowidget(widget)


More information about the Python-checkins mailing list