[Python-checkins] r64277 - sandbox/trunk/ttk-gsoc/samples/ttkcalendar.py

guilherme.polo python-checkins at python.org
Sat Jun 14 15:38:20 CEST 2008


Author: guilherme.polo
Date: Sat Jun 14 15:38:20 2008
New Revision: 64277

Log:
Repositioned __setup_selection;
No longer uses clam theme under windows.


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

Modified: sandbox/trunk/ttk-gsoc/samples/ttkcalendar.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/ttkcalendar.py	(original)
+++ sandbox/trunk/ttk-gsoc/samples/ttkcalendar.py	Sat Jun 14 15:38:20 2008
@@ -58,16 +58,6 @@
         # insert dates in the currently empty calendar
         self._build_calendar()
 
-    def __setup_selection(self, sel_bg, sel_fg):
-        self._font = tkFont.Font()
-        self._canvas = canvas = Tkinter.Canvas(self._calendar,
-            background=sel_bg, borderwidth=0, highlightthickness=0)
-        canvas.text = canvas.create_text(0, 0, fill=sel_fg, anchor='w')
-
-        canvas.bind('<ButtonPress-1>', lambda evt: canvas.place_forget())
-        self._calendar.bind('<Configure>', lambda evt: canvas.place_forget())
-        self._calendar.bind('<ButtonPress-1>', self._pressed)
-
     def __setup_styles(self):
         # custom ttk styles
         style = ttk.Style(self.master)
@@ -104,6 +94,16 @@
         for col in cols:
             self._calendar.column(col, width=maxwidth, anchor='e')
 
+    def __setup_selection(self, sel_bg, sel_fg):
+        self._font = tkFont.Font()
+        self._canvas = canvas = Tkinter.Canvas(self._calendar,
+            background=sel_bg, borderwidth=0, highlightthickness=0)
+        canvas.text = canvas.create_text(0, 0, fill=sel_fg, anchor='w')
+
+        canvas.bind('<ButtonPress-1>', lambda evt: canvas.place_forget())
+        self._calendar.bind('<Configure>', lambda evt: canvas.place_forget())
+        self._calendar.bind('<ButtonPress-1>', self._pressed)
+
     def _build_calendar(self):
         year, month = self._date.year, self._date.month
 
@@ -187,14 +187,17 @@
         year, month = self._date.year, self._date.month
         return self.datetime(year, month, int(self._selection[0]))
 
-
+import sys
 def test():
     root = Tkinter.Tk()
     root.title('Ttk Calendar')
     ttkcal = Calendar(firstweekday=calendar.SUNDAY)
     ttkcal.pack(expand=1, fill='both')
-    style = ttk.Style()
-    style.theme_use('clam')
+
+    if 'win' not in sys.platform:
+        style = ttk.Style()
+        style.theme_use('clam')
+
     root.mainloop()
 
 if __name__ == '__main__':


More information about the Python-checkins mailing list