[Python-checkins] r64589 - sandbox/trunk/ttk-gsoc/samples/theming.py

guilherme.polo python-checkins at python.org
Sun Jun 29 05:59:38 CEST 2008


Author: guilherme.polo
Date: Sun Jun 29 05:59:38 2008
New Revision: 64589

Log:
Adjusted Notebook and Treeview sublayouts so applying changes on them will
actually work;


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

Modified: sandbox/trunk/ttk-gsoc/samples/theming.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/theming.py	(original)
+++ sandbox/trunk/ttk-gsoc/samples/theming.py	Sun Jun 29 05:59:38 2008
@@ -56,12 +56,13 @@
             widget_d['layouts'] = ('Horizontal.T%s' % name,
                 'Vertical.T%s' % name)
         elif name == 'Notebook':
-            widget_d['layouts'] = ('TNotebook', 'Tab')
+            widget_d['layouts'] = ('TNotebook', 'TNotebook.Tab')
         elif name == 'Panedwindow':
             widget_d['layouts'] = ('TPanedwindow', 'Horizontal.Sash',
                 'Vertical.Sash')
         elif name == 'Treeview':
-            widget_d['layouts'] = ('Treeview', 'Item', 'Cell', 'Heading', 'Row')
+            widget_d['layouts'] = ('Treeview', 'Treeview.Item',
+                'Treeview.Cell', 'Treeview.Heading', 'Treeview.Row')
 
         if name in sample:
             widget_d['factory'] = sample[name]
@@ -408,7 +409,7 @@
         opts = {}
 
         if self._is_layout(widget_name, sel): # not a widget, but a layout
-            self._update_layout_text(widget_name)
+            self._update_layout_text("Custom.%s" % widget_name)
             if 'Horizontal' in widget_name or 'Vertical' in widget_name:
                 opts['orient'] = widget_name.split('.')[0].lower()
                 widget_style = "Custom.%s" % widget_name
@@ -417,7 +418,7 @@
             self._empty_layout_text()
 
         widget = self._widget[widget_name]
-        widget_style = widget_style or "Custom.%s" % widget['class']
+        widget_style = widget_style or widget['class']
         curr_widget = self._current_widget
 
         if not invalid and curr_widget['layout'] == widget_style:
@@ -507,15 +508,17 @@
         layout = output.getvalue()
         output.close()
         self._empty_layout_text()
+        self.layouttext.layout = layout_name
         self.layouttext.insert('1.0', layout) # set new text
 
     def _empty_layout_text(self):
         """Clear current text in the layout text widget."""
         self.layouttext.delete('1.0', 'end')
+        self.layouttext.layout = None
 
     def _apply_layout(self):
         """Apply the supposed new layout for the current selected widget."""
-        layout = self._current_widget['layout']
+        layout = self.layouttext.layout
         if not layout: # nothing to do
             return
 
@@ -527,12 +530,12 @@
 
     def _reset_layout(self):
         """Reset the layout for current selected widget."""
-        widget = self._current_widget
-        if widget['widget'] is None: # nothing to reset
+        layout = self.layouttext.layout
+        if not layout: # nothing to reset
             return
 
-        orig_name = widget['layout'][widget['layout'].find('.', 1) + 1:]
-        self._update_layout_text(orig_name)
+        self._update_layout_text(layout[layout.find('.') + 1:])
+        self.layouttext.layout = layout
 
     def _ask_new_frame_opt(self, frame, func):
         """Open a dialog asking for a new option to be added in the
@@ -606,7 +609,8 @@
         children = opts.pop('layouts')
 
         parent = treeview.insert('', 'end', text=name)
-        self._widget[name] = {'tv_item': parent, 'class': children[0]}
+        self._widget[name] = {'tv_item': parent,
+            'class': "Custom.%s" % children[0]}
         self._widget[name].update(opts)
 
         for child in children:
@@ -712,6 +716,7 @@
         textframe = ttk.Frame(layoutframe)
         textframe.pack(side='left', fill='both', expand=True)
         self.layouttext = ScrolledText(textframe)
+        self.layouttext.layout = None
         self.layouttext.pack(expand=True, fill='both')
         btnsframe = ttk.Frame(layoutframe, padding=[6, 0, 0, 0])
         btnsframe.pack(side='right', anchor='n', fill='x')


More information about the Python-checkins mailing list