[Skencil-commits] r730 - skencil/branches/skencil-0.6/src/Sketch/UI

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 22 23:54:03 CEST 2010


Author: igor_n
Date: 2010-09-22 23:53:59 +0200 (Wed, 22 Sep 2010)
New Revision: 730

Modified:
   skencil/branches/skencil-0.6/src/Sketch/UI/aligndlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/blenddlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/canvas.py
   skencil/branches/skencil-0.6/src/Sketch/UI/colordlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/command.py
   skencil/branches/skencil-0.6/src/Sketch/UI/cursorstack.py
   skencil/branches/skencil-0.6/src/Sketch/UI/curvedlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/export.py
   skencil/branches/skencil-0.6/src/Sketch/UI/filldlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/fontdlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/gradientedit.py
   skencil/branches/skencil-0.6/src/Sketch/UI/griddlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/guidedlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/layerdlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/layoutdlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/lengthvar.py
   skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py
   skencil/branches/skencil-0.6/src/Sketch/UI/miniscroll.py
   skencil/branches/skencil-0.6/src/Sketch/UI/modes.py
   skencil/branches/skencil-0.6/src/Sketch/UI/optiondlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/palette.py
   skencil/branches/skencil-0.6/src/Sketch/UI/plugindlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/poslabel.py
   skencil/branches/skencil-0.6/src/Sketch/UI/printdlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/prompt.py
   skencil/branches/skencil-0.6/src/Sketch/UI/reloaddlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py
   skencil/branches/skencil-0.6/src/Sketch/UI/skapp.py
   skencil/branches/skencil-0.6/src/Sketch/UI/sketchdlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/skpixmaps.py
   skencil/branches/skencil-0.6/src/Sketch/UI/styledlg.py
   skencil/branches/skencil-0.6/src/Sketch/UI/tkext.py
   skencil/branches/skencil-0.6/src/Sketch/UI/tooltips.py
   skencil/branches/skencil-0.6/src/Sketch/UI/view.py
   skencil/branches/skencil-0.6/src/Sketch/UI/viewport.py
Log:
mixed indents are removed

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/aligndlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/aligndlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/aligndlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -45,80 +45,80 @@
     title = _("Align")
 
     def __init__(self, master, canvas, doc):
-	CommandPanel.__init__(self, master, canvas, doc)
+        CommandPanel.__init__(self, master, canvas, doc)
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	framey = Frame(top)
-	framey.pack(side = LEFT, expand = 1, fill = Y, padx = 2, pady = 2)
-	framex = Frame(top)
-	framex.pack(side = TOP, expand = 1, fill = X, padx = 2, pady = 2,
-		    anchor = 'n')
+        framey = Frame(top)
+        framey.pack(side = LEFT, expand = 1, fill = Y, padx = 2, pady = 2)
+        framex = Frame(top)
+        framex.pack(side = TOP, expand = 1, fill = X, padx = 2, pady = 2,
+                    anchor = 'n')
 
-	x_pixmaps = [pixmaps.AlignLeft, pixmaps.AlignCenterX,
-		     pixmaps.AlignRight]
-	y_pixmaps = [pixmaps.AlignTop, pixmaps.AlignCenterY,
-		     pixmaps.AlignBottom]
-	self.var_x = IntVar(top)
-	self.var_x.set(0)
+        x_pixmaps = [pixmaps.AlignLeft, pixmaps.AlignCenterX,
+                     pixmaps.AlignRight]
+        y_pixmaps = [pixmaps.AlignTop, pixmaps.AlignCenterY,
+                     pixmaps.AlignBottom]
+        self.var_x = IntVar(top)
+        self.var_x.set(0)
         self.value_x = 0
-	self.var_y = IntVar(top)
-	self.var_y.set(0)
+        self.var_y = IntVar(top)
+        self.var_y.set(0)
         self.value_y = 0
 
-	for i in range(1, 4):
-	    button = make_button(framex, bitmap = x_pixmaps[i - 1],
-				 value = i, variable = self.var_x,
+        for i in range(1, 4):
+            button = make_button(framex, bitmap = x_pixmaps[i - 1],
+                                 value = i, variable = self.var_x,
                                  command = self.set_x)
-	    button.pack(side = LEFT, padx = 1, pady = 1,
-			ipadx = 1, ipady = 1)
-	    button = make_button(framey, bitmap = y_pixmaps[i - 1],
-				 value = i, variable = self.var_y,
+            button.pack(side = LEFT, padx = 1, pady = 1,
+                        ipadx = 1, ipady = 1)
+            button = make_button(framey, bitmap = y_pixmaps[i - 1],
+                                 value = i, variable = self.var_y,
                                  command = self.set_y)
-	    button.pack(side = TOP, padx = 1, pady = 1,
-			ipadx = 1, ipady = 1)
+            button.pack(side = TOP, padx = 1, pady = 1,
+                        ipadx = 1, ipady = 1)
 
-	button_frame = Frame(top)
-	button_frame.pack(expand = 1, fill = BOTH)
+        button_frame = Frame(top)
+        button_frame.pack(expand = 1, fill = BOTH)
         button_frame.rowconfigure(3, minsize = 5)
 
-	apply_button = UpdatedButton(button_frame, text = _("Apply"),
-			       command = self.apply,
-			       sensitivecb = self.can_apply)
-	apply_button.grid(row = 4, column = 0, #columnspan= 2,
+        apply_button = UpdatedButton(button_frame, text = _("Apply"),
+                                     command = self.apply,
+                                     sensitivecb = self.can_apply)
+        apply_button.grid(row = 4, column = 0, #columnspan= 2,
                           sticky = 'ew')
-	self.Subscribe(SELECTION, apply_button.Update)
+        self.Subscribe(SELECTION, apply_button.Update)
 
-	#button = UpdatedButton(button_frame, text = _("Reset"),
-	#		       command = self.reset)
-	#button.grid(column = 0, row = 4, sticky = 'ew')
+        #button = UpdatedButton(button_frame, text = _("Reset"),
+        #		       command = self.reset)
+        #button.grid(column = 0, row = 4, sticky = 'ew')
 
-	button = UpdatedButton(button_frame, text = _("Close"),
-			       command = self.close_dlg)
-	button.grid(column = 1, row = 4, sticky = 'ew')
+        button = UpdatedButton(button_frame, text = _("Close"),
+                               command = self.close_dlg)
+        button.grid(column = 1, row = 4, sticky = 'ew')
 
-	self.var_reference = StringVar(top)
-	self.var_reference.set('selection')
-	radio = UpdatedRadiobutton(button_frame, value = 'selection',
+        self.var_reference = StringVar(top)
+        self.var_reference.set('selection')
+        radio = UpdatedRadiobutton(button_frame, value = 'selection',
                                    text = _("Relative To Selection"),
                                    variable = self.var_reference,
                                    command = apply_button.Update)
-	radio.grid(row = 0, column = 0, columnspan = 2, sticky = 'ew')
-	radio = UpdatedRadiobutton(button_frame, value = 'lowermost',
+        radio.grid(row = 0, column = 0, columnspan = 2, sticky = 'ew')
+        radio = UpdatedRadiobutton(button_frame, value = 'lowermost',
                                    text = _("Relative To Lowermost"),
                                    variable = self.var_reference,
                                    command = apply_button.Update)
-	radio.grid(row = 1, column = 0, columnspan = 2, sticky = 'ew')
-	radio = UpdatedRadiobutton(button_frame, value = 'page',
+        radio.grid(row = 1, column = 0, columnspan = 2, sticky = 'ew')
+        radio = UpdatedRadiobutton(button_frame, value = 'page',
                                    text = _("Relative To Page"),
                                    variable = self.var_reference,
                                    command = apply_button.Update)
-	radio.grid(row = 2, column = 0, columnspan = 2, sticky = 'ew')
+        radio.grid(row = 2, column = 0, columnspan = 2, sticky = 'ew')
 
 
     def init_from_doc(self):
-	self.issue(SELECTION)
+        self.issue(SELECTION)
 
     def set_x(self):
         value = self.var_x.get()
@@ -127,7 +127,7 @@
             self.value_x = 0
         else:
             self.value_x = value
-            
+
     def set_y(self):
         value = self.var_y.get()
         if value == self.value_y:
@@ -137,18 +137,18 @@
             self.value_y = value
 
     def apply(self):
-	x = self.var_x.get()
-	y = self.var_y.get()
-	reference = self.var_reference.get()
-	self.document.AlignSelection(x, y, reference = reference)
+        x = self.var_x.get()
+        y = self.var_y.get()
+        reference = self.var_reference.get()
+        self.document.AlignSelection(x, y, reference = reference)
 
     def reset(self):
-	self.var_x.set(0)
-	self.var_y.set(0)
+        self.var_x.set(0)
+        self.var_y.set(0)
 
     def can_apply(self):
-	if self.document.CountSelected() > 1:
-	    return 1
+        if self.document.CountSelected() > 1:
+            return 1
         reference = self.var_reference.get()
-	return reference == 'page' and self.doc_has_selection()
+        return reference == 'page' and self.doc_has_selection()
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/blenddlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/blenddlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/blenddlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -37,108 +37,108 @@
 
     title = _("Blend")
     def __init__(self, master, main_window, doc):
-	PropertyPanel.__init__(self, master, main_window, doc,
-			       name = 'blenddlg')
+        PropertyPanel.__init__(self, master, main_window, doc,
+                               name = 'blenddlg')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	button_frame = Frame(top)
-	button_frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
+        button_frame = Frame(top)
+        button_frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
 
-	self.update_buttons = []
-	button = UpdatedButton(top, text = _("Apply"),
-			       command = self.apply_blend,
-			       sensitivecb = self.doc_can_blend)
-	button.pack(in_ = button_frame, side = LEFT, expand = 1, fill = X)
-	self.Subscribe(SELECTION, button.Update)
+        self.update_buttons = []
+        button = UpdatedButton(top, text = _("Apply"),
+                               command = self.apply_blend,
+                               sensitivecb = self.doc_can_blend)
+        button.pack(in_ = button_frame, side = LEFT, expand = 1, fill = X)
+        self.Subscribe(SELECTION, button.Update)
 
-	button = UpdatedButton(top, text = _("Close"),
-			       command = self.close_dlg)
-	button.pack(in_ = button_frame, side = RIGHT, expand = 1, fill = X)
+        button = UpdatedButton(top, text = _("Close"),
+                               command = self.close_dlg)
+        button.pack(in_ = button_frame, side = RIGHT, expand = 1, fill = X)
 
-	steps_frame = Frame(top, relief = GROOVE, bd = 2)
-	steps_frame.pack(side = TOP, fill = X, expand = 1)
-	label = Label(steps_frame, text = _("Steps"))
-	label.pack(side = LEFT, anchor = E)
-	self.var_steps = IntVar(top)
-	self.var_steps.set(config.preferences.blend_panel_default_steps)
-	self.entry = MyEntry(steps_frame, name = 'steps',
+        steps_frame = Frame(top, relief = GROOVE, bd = 2)
+        steps_frame.pack(side = TOP, fill = X, expand = 1)
+        label = Label(steps_frame, text = _("Steps"))
+        label.pack(side = LEFT, anchor = E)
+        self.var_steps = IntVar(top)
+        self.var_steps.set(config.preferences.blend_panel_default_steps)
+        self.entry = MyEntry(steps_frame, name = 'steps',
                              textvariable = self.var_steps,
-			     command = self.apply_blend)
-	self.entry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
-	scroll = MiniScroller(steps_frame, variable = self.var_steps,
-			      min = 2, max = None, step = 1)
-	scroll.pack(side = LEFT, fill = Y)
+                             command = self.apply_blend)
+        self.entry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
+        scroll = MiniScroller(steps_frame, variable = self.var_steps,
+                              min = 2, max = None, step = 1)
+        scroll.pack(side = LEFT, fill = Y)
 
-	button = UpdatedButton(top, text = _("Select Start"),
-			       sensitivecb = self.can_select,
-			       command = self.select_control,
-			       args = SelectStart)
-	button.pack(side = BOTTOM, fill = X, expand = 1)
-	self.Subscribe(SELECTION, button.Update)
+        button = UpdatedButton(top, text = _("Select Start"),
+                               sensitivecb = self.can_select,
+                               command = self.select_control,
+                               args = SelectStart)
+        button.pack(side = BOTTOM, fill = X, expand = 1)
+        self.Subscribe(SELECTION, button.Update)
 
-	button = UpdatedButton(top, text = _("Select End"),
-			       sensitivecb = self.can_select,
-			       command = self.select_control,
-			       args = SelectEnd)
-	button.pack(side = BOTTOM, fill = X, expand = 1)
-	self.Subscribe(SELECTION, button.Update)
+        button = UpdatedButton(top, text = _("Select End"),
+                               sensitivecb = self.can_select,
+                               command = self.select_control,
+                               args = SelectEnd)
+        button.pack(side = BOTTOM, fill = X, expand = 1)
+        self.Subscribe(SELECTION, button.Update)
 
     def doc_can_blend(self):
-	return ((self.document.CanBlend() or self.current_obj_is_blend())
-		and self.var_steps.get() >= 2)
+        return ((self.document.CanBlend() or self.current_obj_is_blend())
+                and self.var_steps.get() >= 2)
 
     def current_obj_is_blend(self):
-	object = self.document.CurrentObject()
-	return (object is not None
+        object = self.document.CurrentObject()
+        return (object is not None
                 and (object.is_BlendInterpolation
                      or (object.is_Blend and object.NumObjects() == 3)))
 
     def current_object(self):
-	# assume current_obj_is_blend() yields true
-	object = self.document.CurrentObject()
+        # assume current_obj_is_blend() yields true
+        object = self.document.CurrentObject()
         if object.is_Blend:
             # XXX reaching into object.objects is ugly
             object = object.objects[1]
         return object
 
     def init_from_doc(self):
-	self.Update()
-	self.issue(SELECTION)
+        self.Update()
+        self.issue(SELECTION)
 
     def Update(self):
-	if self.current_obj_is_blend():
+        if self.current_obj_is_blend():
             steps = self.current_object().Steps()
-	    self.var_steps.set(steps)
-	    if self.doc_can_blend():
-		self.entry['state'] = NORMAL
-	    else:
-		self.entry['state'] = DISABLED
+            self.var_steps.set(steps)
+            if self.doc_can_blend():
+                self.entry['state'] = NORMAL
+            else:
+                self.entry['state'] = DISABLED
 
     def apply_blend(self, *args):
-	steps = self.var_steps.get()
-	if self.current_obj_is_blend() and steps >= 2:
-	    doc = self.document
-	    doc.BeginTransaction(_("Set %d Blend Steps") % steps)
-	    try:
-		try:
-		    doc.AddUndo(self.current_object().SetParameters(steps))
-		except:
-		    doc.AbortTransaction()
-	    finally:
-		doc.EndTransaction()
-	else:
-	    self.document.Blend(steps)
+        steps = self.var_steps.get()
+        if self.current_obj_is_blend() and steps >= 2:
+            doc = self.document
+            doc.BeginTransaction(_("Set %d Blend Steps") % steps)
+            try:
+                try:
+                    doc.AddUndo(self.current_object().SetParameters(steps))
+                except:
+                    doc.AbortTransaction()
+            finally:
+                doc.EndTransaction()
+        else:
+            self.document.Blend(steps)
 
     def can_select(self):
-	object = self.document.CurrentObject()
-	return (object is not None
+        object = self.document.CurrentObject()
+        return (object is not None
                 and (object.parent.is_Blend or object.is_Blend))
 
     def select_control(self, which):
-	object = self.document.CurrentObject()
-	if object is not None:
+        object = self.document.CurrentObject()
+        if object is not None:
             if object.is_Blend:
                 # XXX reaching into object.objects is ugly
                 if which == SelectStart:

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/canvas.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/canvas.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/canvas.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -53,9 +53,9 @@
 
 
 constraint_keysyms =   {'Control_L' : const.ControlMask,
-			'Control_R' : const.ControlMask,
-			'Shift_L'   : const.ShiftMask,
-			'Shift_R'   : const.ShiftMask}
+                        'Control_R' : const.ControlMask,
+                        'Shift_L'   : const.ShiftMask,
+                        'Shift_R'   : const.ShiftMask}
 
 command_list = []
 def AddCmd(name, menu_name, method_name = None, subscribe_to = STATE, **kw):
@@ -63,24 +63,24 @@
     kw['menu_name'] = menu_name
     kw['subscribe_to'] = subscribe_to
     if not method_name:
-	method_name = name
+        method_name = name
     cmd = apply(command.CommandClass, (name, method_name), kw)
     command_list.append(cmd)
 
 def AddSelCmd(*args, **kw):
     if not kw.has_key('sensitive_cb'):
-	kw['sensitive_cb'] = ('document', 'HasSelection')
+        kw['sensitive_cb'] = ('document', 'HasSelection')
     if not kw.has_key('subscribe_to'):
-	kw['subscribe_to'] = SELECTION
+        kw['subscribe_to'] = SELECTION
     apply(AddCmd, args, kw)
 
 def AddModeCmd(*args, **kw):
     if not kw.has_key('value_cb'):
-	kw['value_cb'] = 'ModeName'
+        kw['value_cb'] = 'ModeName'
     if not kw.has_key('subscribe_to'):
-	kw['subscribe_to'] = MODE
+        kw['subscribe_to'] = MODE
     if not kw.has_key('is_check'):
-	kw['is_check'] = 1
+        kw['is_check'] = 1
     apply(AddCmd, args, kw)
 
 class CanvasError(SketchInternalError):
@@ -96,13 +96,13 @@
 def selection_type(state):
     state = state & const.AllowedModifierMask
     if state  == const.AddSelectionMask:
-	type = SelectAdd
+        type = SelectAdd
     elif state == const.SubtractSelectionMask:
-	type = SelectSubtract
+        type = SelectSubtract
     elif state == const.SubobjectSelectionMask:
-	type = SelectSubobjects
+        type = SelectSubobjects
     else:
-	type = SelectSet
+        type = SelectSet
     return type
 
 class SketchCanvas(SketchView, CursorStack, WidgetWithModes):
@@ -111,116 +111,116 @@
     commands = None
 
     context_menu_items = ['CreateFillStyleDialog',
-			  'FillSolid',
-			  'FillNone',
-			  None,
-			  'CreateLineStyleDialog',
-			  'LineNone',
-			  None,
-			  'CreateFontDialog',
-			  None,
-			  'CreateStyleFromSelection',
-			  None,
-			  'FitSelectedToWindow',
-			  'FitPageToWindow']
+                          'FillSolid',
+                          'FillNone',
+                          None,
+                          'CreateLineStyleDialog',
+                          'LineNone',
+                          None,
+                          'CreateFontDialog',
+                          None,
+                          'CreateStyleFromSelection',
+                          None,
+                          'FitSelectedToWindow',
+                          'FitPageToWindow']
 
     def __init__(self, master=None, toplevel = None, main_window = None,
-		 document = None, **kw):
-	self.init_handles()
-	self.init_modes()
+                 document = None, **kw):
+        self.init_handles()
+        self.init_modes()
         self.init_cross_hairs()
-	WidgetWithModes.__init__(self)
-	kw['show_visible'] = 1
-	kw['show_printable'] = 0
-	self.snap_to_object = 0
-	self.snap_to_guide = 0
+        WidgetWithModes.__init__(self)
+        kw['show_visible'] = 1
+        kw['show_printable'] = 0
+        self.snap_to_object = 0
+        self.snap_to_guide = 0
         self.snap_correction_rect = 1
         self.snap_move_relative = 0 #1
-	apply(SketchView.__init__, (self, master, toplevel, document), kw)
-	CursorStack.__init__(self, const.CurStd, self.set_handle_cursor)
+        apply(SketchView.__init__, (self, master, toplevel, document), kw)
+        CursorStack.__init__(self, const.CurStd, self.set_handle_cursor)
 
-	self.main_window = main_window
+        self.main_window = main_window
 
-	self.current_pos = Point(0, 0)
-	self.current_info_text = None
-	self.expect_release_event = 0
-	self.ignore_key_press_events = 0
-	self.start_drag = 0
+        self.current_pos = Point(0, 0)
+        self.current_info_text = None
+        self.expect_release_event = 0
+        self.ignore_key_press_events = 0
+        self.start_drag = 0
         self.start_pos = None
-	self.dragging = 0	# true if dragging with left button down
-	self.current = None	# currently dragged/edited object
-	self.correction = Point(0, 0)
-	self.create_creator = None	# Class of object to create
-				# None while in select/edit mode
-	self.create_type = ''
-	self.snap_to_grid = 0
-	self.snap_points = ()
-	self.init_bindings()
+        self.dragging = 0	# true if dragging with left button down
+        self.current = None	# currently dragged/edited object
+        self.correction = Point(0, 0)
+        self.create_creator = None	# Class of object to create
+                                # None while in select/edit mode
+        self.create_type = ''
+        self.snap_to_grid = 0
+        self.snap_points = ()
+        self.init_bindings()
 
-	self.SelectionMode()
-	self.create_commands()
-	self.context_commands = None
+        self.SelectionMode()
+        self.create_commands()
+        self.context_commands = None
 
         preferences.Subscribe(CHANGED, self.preference_changed)
 
     def init_modes(self):
-	self.modes = m = Empty()
-	m.selection_mode = MajorMode(self.selection_enter,
-				     self.selection_down, self.drag_mouse,
-				     self.selection_up, noop,
-				     self.selection_cancel,
-				     start_drag = self.selection_start_drag,
-				     name = 'Select',
-				     text = _("Select"))
-	m.edit_mode = MajorMode(self.edit_enter,
-				self.edit_down, self.drag_mouse, self.edit_up,
-				noop, self.edit_cancel,
-				start_drag = self.edit_start_drag,
-				name = 'Edit',
-				text = _("Edit"))
-	m.creation_mode = MajorMode(self.creation_enter,
-				    self.creation_begin, self.drag_to,
-				    self.creation_end, self.creation_exit,
-				    self.creation_cancel,
-				    name = 'Create',
-				    text = _("Create"))
-	m.zoom_mode = TemporaryMode(self.zoom_enter, self.zoom_begin,
-				    self.drag_to, self.zoom_end,
-				    noop, self.zoom_cancel,
-				    name = 'Zoom',
-				    text = _("Zoom Area"))
-	m.pick_mode = TemporaryMode(self.pick_enter, self.pick_begin, noop,
-				    self.pick_end, noop, self.pick_cancel,
-				    name = 'Pick',
-				    text = _("Pick Object"))
-	m.place_mode = TemporaryMode(self.place_enter, self.place_begin,
-				     self.place_drag, self.place_end,
-				     noop, self.place_cancel,
-				     name = 'Place',
-				     text = _("Place Object"))
+        self.modes = m = Empty()
+        m.selection_mode = MajorMode(self.selection_enter,
+                                     self.selection_down, self.drag_mouse,
+                                     self.selection_up, noop,
+                                     self.selection_cancel,
+                                     start_drag = self.selection_start_drag,
+                                     name = 'Select',
+                                     text = _("Select"))
+        m.edit_mode = MajorMode(self.edit_enter,
+                                self.edit_down, self.drag_mouse, self.edit_up,
+                                noop, self.edit_cancel,
+                                start_drag = self.edit_start_drag,
+                                name = 'Edit',
+                                text = _("Edit"))
+        m.creation_mode = MajorMode(self.creation_enter,
+                                    self.creation_begin, self.drag_to,
+                                    self.creation_end, self.creation_exit,
+                                    self.creation_cancel,
+                                    name = 'Create',
+                                    text = _("Create"))
+        m.zoom_mode = TemporaryMode(self.zoom_enter, self.zoom_begin,
+                                    self.drag_to, self.zoom_end,
+                                    noop, self.zoom_cancel,
+                                    name = 'Zoom',
+                                    text = _("Zoom Area"))
+        m.pick_mode = TemporaryMode(self.pick_enter, self.pick_begin, noop,
+                                    self.pick_end, noop, self.pick_cancel,
+                                    name = 'Pick',
+                                    text = _("Pick Object"))
+        m.place_mode = TemporaryMode(self.place_enter, self.place_begin,
+                                     self.place_drag, self.place_end,
+                                     noop, self.place_cancel,
+                                     name = 'Place',
+                                     text = _("Place Object"))
 
     def init_bindings(self):
-	self.bind('<ButtonPress>', self.ButtonPressEvent)
-	self.bind('<Motion>', self.PointerMotionEvent)
-	self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
-	self.bind('<KeyPress>', self.KeyPressEvent)
-	self.bind('<KeyRelease>', self.KeyReleaseEvent)
-	self.bind('<Leave>', self.LeaveEvent)
-	self.bind('<Enter>', self.EnterEvent)
-	self.last_event = None
+        self.bind('<ButtonPress>', self.ButtonPressEvent)
+        self.bind('<Motion>', self.PointerMotionEvent)
+        self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
+        self.bind('<KeyPress>', self.KeyPressEvent)
+        self.bind('<KeyRelease>', self.KeyReleaseEvent)
+        self.bind('<Leave>', self.LeaveEvent)
+        self.bind('<Enter>', self.EnterEvent)
+        self.last_event = None
 
     scroll_timer = None
     def start_auto_scroll(self):
-	intervall = preferences.autoscroll_interval
-	if intervall:
-	    self.scroll_timer = self.after(intervall, self.auto_scroll)
+        intervall = preferences.autoscroll_interval
+        if intervall:
+            self.scroll_timer = self.after(intervall, self.auto_scroll)
 
     def cancel_auto_scroll(self):
-	if self.scroll_timer is not None:
-	    self.after_cancel(self.scroll_timer)
+        if self.scroll_timer is not None:
+            self.after_cancel(self.scroll_timer)
 
     def auto_scroll(self):
-	x, y, state = self.tkwin.QueryPointer()[4:7]
+        x, y, state = self.tkwin.QueryPointer()[4:7]
         if state & const.Button1Mask:
             amount = preferences.autoscroll_amount
             self.begin_transaction()
@@ -237,73 +237,73 @@
             self.end_transaction()
 
     def LeaveEvent(self, event):
-	if event.state & const.Button1Mask:
-	    self.start_auto_scroll()
+        if event.state & const.Button1Mask:
+            self.start_auto_scroll()
         self.hide_crosshairs()
         self.crosshairs_visible = 0
 
     def EnterEvent(self, event):
-	self.cancel_auto_scroll()
+        self.cancel_auto_scroll()
         self.crosshairs_visible = 1
         self.show_crosshairs()
 
     def create_obj_cmds(self, commands):
-	cmds = command.Commands()
-	keymap = command.Keymap()
-	for cmd_class in commands:
-	    cmd = cmd_class.InstantiateFor(self)
-	    setattr(cmds, cmd.name, cmd)
-	    keymap.AddCommand(cmd)
-	return cmds, keymap
+        cmds = command.Commands()
+        keymap = command.Keymap()
+        for cmd_class in commands:
+            cmd = cmd_class.InstantiateFor(self)
+            setattr(cmds, cmd.name, cmd)
+            keymap.AddCommand(cmd)
+        return cmds, keymap
 
     def create_commands(self):
-	cmds = command.Commands()
-	keymap = command.Keymap()
-	for cmd_class in command_list:
-	    cmd = cmd_class.InstantiateFor(self)
-	    setattr(cmds, cmd.name, cmd)
-	    keymap.AddCommand(cmd)
-	self.keymap = keymap
+        cmds = command.Commands()
+        keymap = command.Keymap()
+        for cmd_class in command_list:
+            cmd = cmd_class.InstantiateFor(self)
+            setattr(cmds, cmd.name, cmd)
+            keymap.AddCommand(cmd)
+        self.keymap = keymap
 
-	class_maps = {}
-	classes = Sketch.command_classes
-	for aclass in classes:
+        class_maps = {}
+        classes = Sketch.command_classes
+        for aclass in classes:
             name = aclass.__name__
-	    if aclass.is_Editor:
-		#name = aclass.EditedClass.__name__
-		commands = aclass.commands + aclass.EditedClass.commands
-	    else:
-		commands = aclass.commands
-	    ocmds, keymap = self.create_obj_cmds(commands)
-	    setattr(cmds, name, ocmds)
-	    class_maps[name] = keymap
+            if aclass.is_Editor:
+                #name = aclass.EditedClass.__name__
+                commands = aclass.commands + aclass.EditedClass.commands
+            else:
+                commands = aclass.commands
+            ocmds, keymap = self.create_obj_cmds(commands)
+            setattr(cmds, name, ocmds)
+            class_maps[name] = keymap
 
-	    if self.context_menu_items[-1] != None:
-		# insert a separator if necessary
-		self.context_menu_items.append(None)
-	    self.context_menu_items = self.context_menu_items \
-				      + list(aclass.context_commands)
+            if self.context_menu_items[-1] != None:
+                # insert a separator if necessary
+                self.context_menu_items.append(None)
+            self.context_menu_items = self.context_menu_items \
+                + list(aclass.context_commands)
 
-	self.commands = cmds
-	self.object_keymap = None
-	self.class_maps = class_maps
+        self.commands = cmds
+        self.object_keymap = None
+        self.class_maps = class_maps
 
     def find_map(self, classes):
-	maps = self.class_maps
-	result = None
-	for c in classes:
-	    map = maps.get(c.__name__)
-	    if map is not None:
-		result =  map
-		break
-	    map = self.find_map(c.__bases__)
-	    if map is not None:
-		result =  map
-		break
-	return result
+        maps = self.class_maps
+        result = None
+        for c in classes:
+            map = maps.get(c.__name__)
+            if map is not None:
+                result =  map
+                break
+            map = self.find_map(c.__bases__)
+            if map is not None:
+                result =  map
+                break
+        return result
 
     def update_object_keymap(self):
-	self.object_keymap = None
+        self.object_keymap = None
         obj = self.document.CurrentObject()
         if obj is not None:
             if self.document.selection.is_EditSelection:
@@ -314,41 +314,41 @@
             self.object_keymap = self.find_map((cls,))
 
     def UpdateCommands(self):
-	# currently needed to ensure that all buttons have correct
-	# sensitivity at startup
-	self.commands.Update()
+        # currently needed to ensure that all buttons have correct
+        # sensitivity at startup
+        self.commands.Update()
 
     def init_gcs(self):
-	# XXX: integrate with SketchView
-	self.gc.init_gc(self.tkwin, graphics_exposures = 1)
-	self.invgc = InvertingDevice()
-	self.invgc.init_gc(self.tkwin)
-	self.hitgc = HitTestDevice()
-	self.hitgc.init_gc(self.tkwin)
-	#self.tk.call(self._w, 'motionhints')
-	self.draw_handle_funcs = [self.invgc.DrawRectHandle,
-				  self.invgc.DrawRectHandle,
-				  self.invgc.DrawSmallRectHandle,
-				  self.invgc.DrawSmallRectHandle,
+        # XXX: integrate with SketchView
+        self.gc.init_gc(self.tkwin, graphics_exposures = 1)
+        self.invgc = InvertingDevice()
+        self.invgc.init_gc(self.tkwin)
+        self.hitgc = HitTestDevice()
+        self.hitgc.init_gc(self.tkwin)
+        #self.tk.call(self._w, 'motionhints')
+        self.draw_handle_funcs = [self.invgc.DrawRectHandle,
+                                  self.invgc.DrawRectHandle,
+                                  self.invgc.DrawSmallRectHandle,
+                                  self.invgc.DrawSmallRectHandle,
                                   self.invgc.DrawCircleHandle,
                                   self.invgc.DrawCircleHandle,
                                   self.invgc.DrawSmallCircleHandle,
                                   self.invgc.DrawSmallCircleHandle,
-				  self.invgc.DrawSmallRectHandleList,
-				  self.invgc.DrawHandleLine,
-				  self.invgc.DrawPixmapHandle,
-				  self.invgc.DrawCaretHandle]
-	self.gcs_initialized = 1
-	self.FitPageToWindow(save_viewport = 0)
-	self.set_gc_transforms()
+                                  self.invgc.DrawSmallRectHandleList,
+                                  self.invgc.DrawHandleLine,
+                                  self.invgc.DrawPixmapHandle,
+                                  self.invgc.DrawCaretHandle]
+        self.gcs_initialized = 1
+        self.FitPageToWindow(save_viewport = 0)
+        self.set_gc_transforms()
 
     def set_gc_transforms(self):
-	SketchView.set_gc_transforms(self)
-	if self.gcs_initialized:
-	    self.invgc.SetViewportTransform(self.scale, self.doc_to_win,
-					    self.win_to_doc)
-	    self.hitgc.SetViewportTransform(self.scale, self.doc_to_win,
-					    self.win_to_doc)
+        SketchView.set_gc_transforms(self)
+        if self.gcs_initialized:
+            self.invgc.SetViewportTransform(self.scale, self.doc_to_win,
+                                            self.win_to_doc)
+            self.hitgc.SetViewportTransform(self.scale, self.doc_to_win,
+                                            self.win_to_doc)
 
 
     #
@@ -356,33 +356,33 @@
     #
 
     def issue_selection(self):
-	self.queue_message(SELECTION)
+        self.queue_message(SELECTION)
 
     def issue_mode(self):
-	self.queue_message(MODE)
+        self.queue_message(MODE)
 
     def queue_update_handles(self):
-	self.handle_update_pending = 1
+        self.handle_update_pending = 1
 
     def init_transactions(self):
-	SketchView.init_transactions(self)
-	self.handle_update_pending = 0
+        SketchView.init_transactions(self)
+        self.handle_update_pending = 0
 
     def end_transaction(self):
-	SketchView.end_transaction(self)
-	if self.transaction == 0:
-	    if self.handle_update_pending:
-		self.update_handles()
-	    self.handle_update_pending = 0
+        SketchView.end_transaction(self)
+        if self.transaction == 0:
+            if self.handle_update_pending:
+                self.update_handles()
+            self.handle_update_pending = 0
 
     def check_transaction(self):
-	# for debugging, check whether a transaction is active
-	if not self.transaction:
-	    pdebug(None, 'Warning: no transaction')
+        # for debugging, check whether a transaction is active
+        if not self.transaction:
+            pdebug(None, 'Warning: no transaction')
 
     def call_document_method(self, method, *args, **kwargs):
-	method = getattr(self.document, method)
-	apply(method, args, kwargs)
+        method = getattr(self.document, method)
+        apply(method, args, kwargs)
 
     #
     #	receivers for channels
@@ -395,160 +395,160 @@
 
     def selection_changed(self):
         self.selection_info_text = None
-	self.issue_selection()
-	self.update_handles()
-	self.update_object_keymap()
+        self.issue_selection()
+        self.update_handles()
+        self.update_object_keymap()
         if self.gcs_initialized:
             x, y = self.tkwin.QueryPointer()[4:6]
             self.set_handle_cursor(x, y)
 
     def doc_was_edited(self, *rest):
         self.selection_info_text = None
-	self.update_snap_points()
-	self.update_handles()
-	self.queue_message(EDITED)
+        self.update_snap_points()
+        self.update_handles()
+        self.queue_message(EDITED)
 
     # extend the method of SketchView. SketchView subscribes this.
     def layer_changed(self, *args):
-	if args:
-	    recompute = 0
-	    if args[0] == LAYER_STATE:
-		layer, visible_changed, printable_changed, outlined_changed \
-		       = args[1]
-		if layer.NumObjects():
-		    if ((self.show_printable and printable_changed)
-			or (self.show_visible and visible_changed)):
-			recompute = 1
-	    elif args[0] == LAYER_ACTIVE:
-		if (self.mode is self.modes.creation_mode
-		    and self.document.ActiveLayer() is None):
-		    self.mode.cancel()
-		else:
-		    self.issue_mode()
-	    if recompute:
-		self.update_snap_points()
-	apply(SketchView.layer_changed, (self,) + args)
+        if args:
+            recompute = 0
+            if args[0] == LAYER_STATE:
+                layer, visible_changed, printable_changed, outlined_changed \
+                     = args[1]
+                if layer.NumObjects():
+                    if ((self.show_printable and printable_changed)
+                        or (self.show_visible and visible_changed)):
+                        recompute = 1
+            elif args[0] == LAYER_ACTIVE:
+                if (self.mode is self.modes.creation_mode
+                    and self.document.ActiveLayer() is None):
+                    self.mode.cancel()
+                else:
+                    self.issue_mode()
+            if recompute:
+                self.update_snap_points()
+        apply(SketchView.layer_changed, (self,) + args)
 
     #
     #	Widget Methods (Redraw, ... )
     #
 
     def RedrawMethod(self, region = None):
-	#self.hide_handles()
-	#print 'RedrawMethod', region
-	if hasattr(preferences, 'profile_redraw'):
-	    import profile
-	    warn(INTERNAL, 'profiling...')
-	    prof = profile.Profile()
-	    prof.runctx('region = SketchView.RedrawMethod(self, region)',
-			globals(), locals())
-	    prof.dump_stats('/tmp/redraw.prof')
-	    warn(INTERNAL, 'profiling... (done)')
-	    del preferences.profile_redraw
-	else:
-	    region = SketchView.RedrawMethod(self, region)
+        #self.hide_handles()
+        #print 'RedrawMethod', region
+        if hasattr(preferences, 'profile_redraw'):
+            import profile
+            warn(INTERNAL, 'profiling...')
+            prof = profile.Profile()
+            prof.runctx('region = SketchView.RedrawMethod(self, region)',
+                        globals(), locals())
+            prof.dump_stats('/tmp/redraw.prof')
+            warn(INTERNAL, 'profiling... (done)')
+            del preferences.profile_redraw
+        else:
+            region = SketchView.RedrawMethod(self, region)
 
-	# draw the handles
-	self.invgc.InitClip()
-	if region:
-	    self.invgc.PushClip()
-	    self.invgc.ClipRegion(region)
-	if self.current is not None:
-	    self.current.DrawDragged(self.invgc, 0)
-	else:
-	    self.show_handles(1)
+        # draw the handles
+        self.invgc.InitClip()
+        if region:
+            self.invgc.PushClip()
+            self.invgc.ClipRegion(region)
+        if self.current is not None:
+            self.current.DrawDragged(self.invgc, 0)
+        else:
+            self.show_handles(1)
         self.show_crosshairs(1)
-	if region:
-	    self.invgc.PopClip()
-	#self.show_handles()
+        if region:
+            self.invgc.PopClip()
+        #self.show_handles()
 
-	# The sync helps to avoid the scroll bug. Clicking once into the
-	# scroll bar to scroll by a page could scroll twice for a
-	# complex drawing.
-	self.tkwin.Sync()
+        # The sync helps to avoid the scroll bug. Clicking once into the
+        # scroll bar to scroll by a page could scroll twice for a
+        # complex drawing.
+        self.tkwin.Sync()
 
     #
     #	Event handler
     #
 
     def ButtonPressEvent(self, event):
-	# handle button press event
+        # handle button press event
         self.begin_transaction()
-	self.expect_release_event = 1
-	self.last_event = event
-	try:
-	    self.ignore_key_press_events = 1
-	    button = event.num
-	    if button == const.Button1:
-		p = self.WinToDoc(event.x, event.y)
-		self.mode.button_down(p, button, event.state)
-	    elif button == const.ContextButton:
-		self.popup_context_menu(event.x_root, event.y_root,
-					button, event.state)
-		self.ignore_key_press_events = 0
+        self.expect_release_event = 1
+        self.last_event = event
+        try:
+            self.ignore_key_press_events = 1
+            button = event.num
+            if button == const.Button1:
+                p = self.WinToDoc(event.x, event.y)
+                self.mode.button_down(p, button, event.state)
+            elif button == const.ContextButton:
+                self.popup_context_menu(event.x_root, event.y_root,
+                                        button, event.state)
+                self.ignore_key_press_events = 0
             elif button == const.Button4:
                 self.ScrollYUnits(-3)
             elif button == const.Button5:
                 self.ScrollYUnits(3)
-	finally:
-	    self.end_transaction()
+        finally:
+            self.end_transaction()
 
     def PointerMotionEvent(self, event):
-	# handle Motion events
-	#event.button = event.num
-	#event.x, event.y = self.tkwin.QueryPointer()[4:6]
-	self.last_event = event
-	p = self.WinToDoc(event.x, event.y)
-	self.set_current_pos(p, snap = 1)
-	if self.start_drag or self.dragging:
-	    self.mode.mouse_move(p, event.state)
+        # handle Motion events
+        #event.button = event.num
+        #event.x, event.y = self.tkwin.QueryPointer()[4:6]
+        self.last_event = event
+        p = self.WinToDoc(event.x, event.y)
+        self.set_current_pos(p, snap = 1)
+        if self.start_drag or self.dragging:
+            self.mode.mouse_move(p, event.state)
             self.update_current_info_text()
-	else:
-	    if self.cursor_function:
-		self.cursor_function(event.x, event.y)
+        else:
+            if self.cursor_function:
+                self.cursor_function(event.x, event.y)
         self.hide_crosshairs()
         self.show_crosshairs()
 
     def ButtonReleaseEvent(self, event):
-	self.grab_release()
-	self.cancel_auto_scroll()
-	if not self.expect_release_event:
-	    return
-	self.last_event = event
-	self.begin_transaction()
-	try:
-	    p = self.WinToDoc(event.x, event.y)
-	    event.button = event.num
-	    if event.button == const.Button1:
-		self.mode.button_up(p, event.button, event.state)
-		self.dragging = 0
-	    elif event.button == const.Button2:
-		self.mode.button_up(p, event.button, event.state,
-				    force_stop = stop_regular)
-		self.dragging = 0
-	finally:
-	    if self.mode.isTemporaryMode:
-		self.exit_temporary_mode()
-	    self.ignore_key_press_events = 0
-	    self.expect_release_event = 0
-	    self.end_transaction()
+        self.grab_release()
+        self.cancel_auto_scroll()
+        if not self.expect_release_event:
+            return
+        self.last_event = event
+        self.begin_transaction()
+        try:
+            p = self.WinToDoc(event.x, event.y)
+            event.button = event.num
+            if event.button == const.Button1:
+                self.mode.button_up(p, event.button, event.state)
+                self.dragging = 0
+            elif event.button == const.Button2:
+                self.mode.button_up(p, event.button, event.state,
+                                    force_stop = stop_regular)
+                self.dragging = 0
+        finally:
+            if self.mode.isTemporaryMode:
+                self.exit_temporary_mode()
+            self.ignore_key_press_events = 0
+            self.expect_release_event = 0
+            self.end_transaction()
 
     def MapKeystroke(self, stroke):
-	if self.object_keymap:
-	    cmd = self.object_keymap.MapKeystroke(stroke)
-	    if cmd:
-		return cmd
-	cmd = self.keymap.MapKeystroke(stroke)
-	if cmd:
-	    return cmd
+        if self.object_keymap:
+            cmd = self.object_keymap.MapKeystroke(stroke)
+            if cmd:
+                return cmd
+        cmd = self.keymap.MapKeystroke(stroke)
+        if cmd:
+            return cmd
 
-	return self.main_window.MapKeystroke(stroke)
+        return self.main_window.MapKeystroke(stroke)
 
     def KeyPressEvent(self, event):
-	self.begin_transaction()
-	try:
-	    state = event.state
-	    sym = event.keysym
+        self.begin_transaction()
+        try:
+            state = event.state
+            sym = event.keysym
             char = event.char
             try:
                 char = self.tk.utf8_to_latin1(char)
@@ -557,114 +557,114 @@
                 # handle this case properly, bit it only happens with
                 # python <= 1.5.1, so it shouldn't be much of a problem
                 pass
-	    # key events should probably be also handled by the modes
-	    if sym == 'Escape':
-		self.cancel_current_mode()
-		return
-	    mask = constraint_keysyms.get(sym, 0)
-	    if mask:
+            # key events should probably be also handled by the modes
+            if sym == 'Escape':
+                self.cancel_current_mode()
+                return
+            mask = constraint_keysyms.get(sym, 0)
+            if mask:
                 # generate a `fake' motion event if a modifier changed. This is
                 # done to reflect changes in the constraints during a drag
                 # immediately.
                 # modify the state, because it reflects the state before the
                 # key press
-		event.state = event.state ^ mask
-		self.PointerMotionEvent(event)
-	    if self.ignore_key_press_events:
-		return
-	    if char and ord(char) < 32:
-		char = ''
+                event.state = event.state ^ mask
+                self.PointerMotionEvent(event)
+            if self.ignore_key_press_events:
+                return
+            if char and ord(char) < 32:
+                char = ''
 
-	    # build the modifier part of the key for the keymap
-	    modm = state & const.MetaMask and 'M-' or ''
-	    modc = state & const.ControlMask and 'C-' or ''
-	    mods = state & const.ShiftMask and 'S-' or ''
-	    if char:
-		mod = modm + modc
-	    else:
-		mod = modm + modc + mods
+            # build the modifier part of the key for the keymap
+            modm = state & const.MetaMask and 'M-' or ''
+            modc = state & const.ControlMask and 'C-' or ''
+            mods = state & const.ShiftMask and 'S-' or ''
+            if char:
+                mod = modm + modc
+            else:
+                mod = modm + modc + mods
 
-	    cmd = None
-	    if char:
-		# the key produced a normal character. Try the binding
-		# for this first.
-		stroke = mod + char
-		cmd = self.MapKeystroke(stroke)
+            cmd = None
+            if char:
+                # the key produced a normal character. Try the binding
+                # for this first.
+                stroke = mod + char
+                cmd = self.MapKeystroke(stroke)
 
-	    if not cmd and char != sym:
-		# there was no character or no entry in the keymap. Try
-		# the keysym next.
-		#
-		# XXX: The current implementation allows bindings for
-		# the Shift- and Control-keys, etc.
-		stroke = mod + sym
-		cmd = self.MapKeystroke(stroke)
+            if not cmd and char != sym:
+                # there was no character or no entry in the keymap. Try
+                # the keysym next.
+                #
+                # XXX: The current implementation allows bindings for
+                # the Shift- and Control-keys, etc.
+                stroke = mod + sym
+                cmd = self.MapKeystroke(stroke)
 
-	    if cmd:
-		if cmd.invoke_with_keystroke:
-		    cmd.Invoke(stroke)
-		else:
-		    cmd.Invoke()
-	finally:
-	    self.end_transaction()
+            if cmd:
+                if cmd.invoke_with_keystroke:
+                    cmd.Invoke(stroke)
+                else:
+                    cmd.Invoke()
+        finally:
+            self.end_transaction()
 
     def KeyReleaseEvent(self, event):
-	# generate a `fake' motion event if a modifier changed. This is
-	# done to reflect changes in the constraints during a drag
-	# immediately.
-	mask = constraint_keysyms.get(event.keysym, 0)
-	if mask:
-	    # modify the state, because it reflects the state before the
-	    # key release
-	    event.state = event.state ^ mask
-	    self.PointerMotionEvent(event)
+        # generate a `fake' motion event if a modifier changed. This is
+        # done to reflect changes in the constraints during a drag
+        # immediately.
+        mask = constraint_keysyms.get(event.keysym, 0)
+        if mask:
+            # modify the state, because it reflects the state before the
+            # key release
+            event.state = event.state ^ mask
+            self.PointerMotionEvent(event)
 
 
     #
     #
 
     def build_context_commands(self):
-	items = []
-	for entry in self.context_menu_items:
-	    if entry:
-		cmd = self.commands.Get(entry)
-		if not cmd:
-		    cmd = self.main_window.commands.Get(entry)
-		if cmd:
-		    items.append(cmd)
-		else:
-		    # XXX: if the context menu is configurable by the
-		    # user, this should be visible to the user.
-		    warn(INTERNAL, 'unknown command', entry)
-	    else:
-		items.append(entry)
-	self.context_commands = items
+        items = []
+        for entry in self.context_menu_items:
+            if entry:
+                cmd = self.commands.Get(entry)
+                if not cmd:
+                    cmd = self.main_window.commands.Get(entry)
+                if cmd:
+                    items.append(cmd)
+                else:
+                    # XXX: if the context menu is configurable by the
+                    # user, this should be visible to the user.
+                    warn(INTERNAL, 'unknown command', entry)
+            else:
+                items.append(entry)
+        self.context_commands = items
 
 
     def popup_context_menu(self, x, y, button, state):
-	if state & const.AllButtonsMask == 0:
-	    if __debug__:
-		pdebug('context_menu', 'popup_context_menu',
-		       x, y, button, state)
-	    if self.context_commands is None:
-		self.build_context_commands()
+        if state & const.AllButtonsMask == 0:
+            if __debug__:
+                pdebug('context_menu', 'popup_context_menu',
+                       x, y, button, state)
+            if self.context_commands is None:
+                self.build_context_commands()
 
-	    items = []
-	    last = None
-	    for cmd in self.context_commands:
-		if cmd and not cmd.InContext():
-		    cmd = None
-		if cmd != last:
-		    items.append(cmd)
-		last = cmd
-	    if items and items[0] is None:
-		del items[0]
-	    if items and items[-1] is None:
-		del items[-1]
-	    if items:
-		context_menu = UpdatedMenu(self, map(MakeCommand, items))
-		context_menu.Popup(x, y)
-		context_menu.clean_up()
+            items = []
+            last = None
+            for cmd in self.context_commands:
+                if cmd and not cmd.InContext():
+                    cmd = None
+                if cmd != last:
+                    items.append(cmd)
+                last = cmd
+            if items and items[0] is None:
+                del items[0]
+            if items and items[-1] is None:
+                del items[-1]
+            if items:
+                context_menu = UpdatedMenu(self, map(MakeCommand, items))
+                context_menu.Popup(x, y)
+                context_menu.clean_up()
 
     #
     #	Report the current pointer position in doc coords.
@@ -672,13 +672,13 @@
     #
 
     def set_current_pos(self, p, snap = 0):
-	if snap and preferences.snap_current_pos:
-	    p = self.snap_point(p)
-	self.current_pos = p
-	self.issue(POSITION)
+        if snap and preferences.snap_current_pos:
+            p = self.snap_point(p)
+        self.current_pos = p
+        self.issue(POSITION)
 
     def GetCurrentPos(self):
-	return self.current_pos
+        return self.current_pos
 
     #
     #	Report the current state of the dragged object.
@@ -711,138 +711,138 @@
     #	Extend some inherited methods to issue the appropriate messages
 
     def push_mode(self, mode):
-	WidgetWithModes.push_mode(self, mode)
-	self.issue_mode()
+        WidgetWithModes.push_mode(self, mode)
+        self.issue_mode()
 
     def pop_mode(self):
-	WidgetWithModes.pop_mode(self)
-	self.issue_mode()
+        WidgetWithModes.pop_mode(self)
+        self.issue_mode()
 
     def enter_mode(self, mode, *args):
-	apply(WidgetWithModes.enter_mode, (self, mode) + args)
-	self.issue_mode()
+        apply(WidgetWithModes.enter_mode, (self, mode) + args)
+        self.issue_mode()
 
 
     #
     def cancel_current_mode(self):
-	if self.mode.isTemporaryMode:
-	    self.cancel_temporary_mode()
-	else:
-	    self.mode.cancel()
+        if self.mode.isTemporaryMode:
+            self.cancel_temporary_mode()
+        else:
+            self.mode.cancel()
     #
     #	Creation mode
     #
 
     def can_create(self):
-	return self.document.ActiveLayer() is not None
+        return self.document.ActiveLayer() is not None
 
     # enter creation mode for a gfx_name objects
     AddModeCmd('CreateRectangle', _("Draw Rectangle"), 'Create',
-	       args = 'RectangleCreator', bitmap = pixmaps.CreateRect,
-	       value_on = 'Create:RectangleCreator',
-	       sensitive_cb = 'can_create')
+               args = 'RectangleCreator', bitmap = pixmaps.CreateRect,
+               value_on = 'Create:RectangleCreator',
+               sensitive_cb = 'can_create')
     AddModeCmd('CreateEllipse', _("Draw Ellipse"), 'Create',
-	       args = 'EllipseCreator', bitmap = pixmaps.CreateEllipse,
-	       value_on = 'Create:EllipseCreator',
-	       sensitive_cb = 'can_create')
+               args = 'EllipseCreator', bitmap = pixmaps.CreateEllipse,
+               value_on = 'Create:EllipseCreator',
+               sensitive_cb = 'can_create')
     AddModeCmd('CreatePolyBezier', _("Draw Curve"), 'Create',
-	       args = 'PolyBezierCreator', bitmap = pixmaps.CreateCurve,
-	       value_on = 'Create:PolyBezierCreator',
-	       sensitive_cb = 'can_create')
+               args = 'PolyBezierCreator', bitmap = pixmaps.CreateCurve,
+               value_on = 'Create:PolyBezierCreator',
+               sensitive_cb = 'can_create')
     AddModeCmd('CreatePolyLine', _("Draw Poly-Line"), 'Create',
-	       args = 'PolyLineCreator', bitmap = pixmaps.CreatePoly,
-	       value_on = 'Create:PolyLineCreator',
-	       sensitive_cb = 'can_create')
+               args = 'PolyLineCreator', bitmap = pixmaps.CreatePoly,
+               value_on = 'Create:PolyLineCreator',
+               sensitive_cb = 'can_create')
     AddModeCmd('CreateSimpleText', _("Draw Text"), 'Create',
-	       args = 'SimpleTextCreator', bitmap = pixmaps.Text,
-	       value_on = 'Create:SimpleTextCreator',
-	       sensitive_cb = 'can_create')
+               args = 'SimpleTextCreator', bitmap = pixmaps.Text,
+               value_on = 'Create:SimpleTextCreator',
+               sensitive_cb = 'can_create')
     def Create(self, gfx_name = None):
-	self.begin_transaction()
-	if gfx_name is None:
-	    gfx_name = self.create_type
-	self.enter_mode(self.modes.creation_mode, gfx_name)
-	self.end_transaction()
+        self.begin_transaction()
+        if gfx_name is None:
+            gfx_name = self.create_type
+        self.enter_mode(self.modes.creation_mode, gfx_name)
+        self.end_transaction()
 
     def creation_enter(self, gfx_name):
-	self.create_creator = getattr(Sketch, gfx_name)
-	self.create_type = gfx_name
-	self.push_static_cursor(const.CurCreate)
-	self.mode.text = self.create_creator.creation_text
+        self.create_creator = getattr(Sketch, gfx_name)
+        self.create_type = gfx_name
+        self.push_static_cursor(const.CurCreate)
+        self.mode.text = self.create_creator.creation_text
 
     def creation_begin(self, p, button, state):
-	# Begin creating an instance of self.create_creator.
-	if __debug__:
-	    self.check_transaction()
-	if self.create_creator is None:
-	    raise CanvasError('no create_creator in creation mode')
-	self.begin_creator(self.create_creator, p, button, state)
+        # Begin creating an instance of self.create_creator.
+        if __debug__:
+            self.check_transaction()
+        if self.create_creator is None:
+            raise CanvasError('no create_creator in creation mode')
+        self.begin_creator(self.create_creator, p, button, state)
 
     def begin_creator(self, creator, p, button, state):
-	# Begin creating an instance of creator
-	# also used by zoom_mode
-	self.hide_handles()
-	if self.current is not None:
-	    self.current.Hide(self.invgc)
-	snapped = self.snap_point(p)
-	self.current = creator(snapped)
-	self.set_correction(self.current.ButtonDown(snapped, button, state))
-	self.current.Show(self.invgc)
-	self.start_drag = 1
-	self.dragging = 0
+        # Begin creating an instance of creator
+        # also used by zoom_mode
+        self.hide_handles()
+        if self.current is not None:
+            self.current.Hide(self.invgc)
+        snapped = self.snap_point(p)
+        self.current = creator(snapped)
+        self.set_correction(self.current.ButtonDown(snapped, button, state))
+        self.current.Show(self.invgc)
+        self.start_drag = 1
+        self.dragging = 0
 
 
     def creation_end(self, p, button, state, force_stop = stop_continue):
-	if __debug__:
-	    self.check_transaction()
-	if self.current is None:
-	    # current might be none if the user ends creation before
-	    # she's begun creating something (i.e. clicking button-2
-	    # immediately after selecting CreateCurve)
-	    self.creation_cancel()
-	    return
-	self.current.ButtonUp(self.correct_and_snap(p), button, state)
-	self.do_end_creation(force_stop, set_mode = 1)
+        if __debug__:
+            self.check_transaction()
+        if self.current is None:
+            # current might be none if the user ends creation before
+            # she's begun creating something (i.e. clicking button-2
+            # immediately after selecting CreateCurve)
+            self.creation_cancel()
+            return
+        self.current.ButtonUp(self.correct_and_snap(p), button, state)
+        self.do_end_creation(force_stop, set_mode = 1)
 
     def do_end_creation(self, force_stop = stop_regular, set_mode = 0):
-	if __debug__:
-	    self.check_transaction()
-	self.pop_cursor_state()
-	obj = self.current
-	obj.Hide(self.invgc)
-	self.current = None
-	was_ok = 1
+        if __debug__:
+            self.check_transaction()
+        self.pop_cursor_state()
+        obj = self.current
+        obj.Hide(self.invgc)
+        self.current = None
+        was_ok = 1
 
-	if force_stop:
-	    self.create_creator = None
-	    was_ok = obj.EndCreation()
-	else:
-	    self.create_creator = obj.ContinueCreation()
-	if self.create_creator is None:
-	    self.start_drag = 0
-	    self.dragging = 0
-	    if preferences.creation_is_temporary:
-		new_mode = self.SelectionMode
-	    else:
-		new_mode = self.Create
-	    if was_ok:
-		self.document.Insert(obj.CreatedObject())
-		# switch to edit mode if the new object is a text object.
-		# There should be a better way to achieve this
-		if obj.is_Text:
-		    new_mode = self.EditMode
-	    else:
-		self.document.SelectNone()
-	    if set_mode:
-		new_mode()
-	else:
-	    self.push_static_cursor(const.CurCreate)
-	    self.current = obj
-	    obj.Show(self.invgc)
+        if force_stop:
+            self.create_creator = None
+            was_ok = obj.EndCreation()
+        else:
+            self.create_creator = obj.ContinueCreation()
+        if self.create_creator is None:
+            self.start_drag = 0
+            self.dragging = 0
+            if preferences.creation_is_temporary:
+                new_mode = self.SelectionMode
+            else:
+                new_mode = self.Create
+            if was_ok:
+                self.document.Insert(obj.CreatedObject())
+                # switch to edit mode if the new object is a text object.
+                # There should be a better way to achieve this
+                if obj.is_Text:
+                    new_mode = self.EditMode
+            else:
+                self.document.SelectNone()
+            if set_mode:
+                new_mode()
+        else:
+            self.push_static_cursor(const.CurCreate)
+            self.current = obj
+            obj.Show(self.invgc)
 
     def creation_exit(self, set_mode = 0):
-	if self.current is not None:
-	    self.do_end_creation(set_mode = set_mode)
+        if self.current is not None:
+            self.do_end_creation(set_mode = set_mode)
 
     def creation_cancel(self):
         self.dragging = 0
@@ -860,51 +860,51 @@
 
     # two methods shared by the selection and edit modes
     def begin_edit_object(self, p, button, state, handle = None):
-	# begin to edit OBJ
-	self.current = self.document
-	if handle is not None:
-	    self.current.SelectHandle(handle, SelectDrag)
-	else:
-	    self.current.SelectPointPart(p, self.hitgc, SelectDrag)
-	self.hide_handles()
-	self.set_correction(self.current.ButtonDown(p, button, state))
-	self.current.Show(self.invgc, 1)
+        # begin to edit OBJ
+        self.current = self.document
+        if handle is not None:
+            self.current.SelectHandle(handle, SelectDrag)
+        else:
+            self.current.SelectPointPart(p, self.hitgc, SelectDrag)
+        self.hide_handles()
+        self.set_correction(self.current.ButtonDown(p, button, state))
+        self.current.Show(self.invgc, 1)
 
     def stop_edit_object(self, p, button, state, force_stop = 0):
-	if __debug__:
-	    self.check_transaction()
-	if self.current is None:
-	    return None
-	obj = self.current
+        if __debug__:
+            self.check_transaction()
+        if self.current is None:
+            return None
+        obj = self.current
         p = self.correct_and_snap(p)
-	self.current = None
-	self.start_drag = 0
-	self.dragging = 0
-	obj.Hide(self.invgc, 1)
-	obj.ButtonUp(p, button, state)
-	return obj
+        self.current = None
+        self.start_drag = 0
+        self.dragging = 0
+        obj.Hide(self.invgc, 1)
+        obj.ButtonUp(p, button, state)
+        return obj
 
     def drag_mouse(self, p, state):
-	if self.start_drag:
-	    # XXX it sometimes happens that self.start_pos has not been
-	    # set yet. Why?
-	    if abs(self.start_pos[0] - p) * self.scale > 3:
-		apply(self.mode.start_drag, self.start_pos)
-		self.start_drag = 0
-	    else:
-		return
-	self.dragging = 1
-	if self.current is not None and (state & self.current.drag_mask):
-	    # if something is being edited, hide it and show it at new
-	    # position
-	    self.current.Hide(self.invgc, 1)
-	    self.current.MouseMove(self.correct_and_snap(p), state)
-	    self.current.Show(self.invgc, 1)
+        if self.start_drag:
+            # XXX it sometimes happens that self.start_pos has not been
+            # set yet. Why?
+            if abs(self.start_pos[0] - p) * self.scale > 3:
+                apply(self.mode.start_drag, self.start_pos)
+                self.start_drag = 0
+            else:
+                return
+        self.dragging = 1
+        if self.current is not None and (state & self.current.drag_mask):
+            # if something is being edited, hide it and show it at new
+            # position
+            self.current.Hide(self.invgc, 1)
+            self.current.MouseMove(self.correct_and_snap(p), state)
+            self.current.Show(self.invgc, 1)
 
     def selection_rect(self, p, button, state):
-	self.current = SelectionRectangle(p)
-	self.set_correction(self.current.ButtonDown(p, button, state))
-	self.current.Show(self.invgc)
+        self.current = SelectionRectangle(p)
+        self.set_correction(self.current.ButtonDown(p, button, state))
+        self.current.Show(self.invgc)
 
     #
     #	Selection
@@ -912,190 +912,190 @@
 
     # enter selection mode
     AddModeCmd('SelectionMode', _("Selection Mode"), value_on = 'Select',
-	       bitmap = pixmaps.SelectionMode)
+               bitmap = pixmaps.SelectionMode)
     def SelectionMode(self):
-	self.begin_transaction()
-	self.document.SetMode(SelectionMode)
-	self.end_transaction()
+        self.begin_transaction()
+        self.document.SetMode(SelectionMode)
+        self.end_transaction()
 
     def selection_mode(self):
-	self.enter_mode(self.modes.selection_mode)
+        self.enter_mode(self.modes.selection_mode)
 
     def selection_enter(self):
-	self.create_creator = None
-	self.set_active_cursor(self.set_handle_cursor, const.CurStd)
+        self.create_creator = None
+        self.set_active_cursor(self.set_handle_cursor, const.CurStd)
 
     def selection_down(self, p, button, state):
-	self.start_pos = (p, button, state)
-	self.start_drag = 1
-	self.dragging = 0
-	self.hide_handles()
+        self.start_pos = (p, button, state)
+        self.start_drag = 1
+        self.dragging = 0
+        self.hide_handles()
 
     def selection_start_drag(self, p, button, state):
-	if selection_type(state) == SelectSet:
-	    handle = self.handle_hit(p)
-	    if handle is not None or self.document.SelectionHit(p, self.hitgc):
-		# something is already selected and the user pressed the
-		# button somewhere on the selection. Edit the current
-		# object(s)
-		self.begin_edit_object(p, button, state, handle)
-		return
-	# there's no selection or the user pressed the button somewhere
-	# outside the current selection.
+        if selection_type(state) == SelectSet:
+            handle = self.handle_hit(p)
+            if handle is not None or self.document.SelectionHit(p, self.hitgc):
+                # something is already selected and the user pressed the
+                # button somewhere on the selection. Edit the current
+                # object(s)
+                self.begin_edit_object(p, button, state, handle)
+                return
+        # there's no selection or the user pressed the button somewhere
+        # outside the current selection.
 
-	# test for a guide line
-	guide = self.document.SelectPoint(p, self.hitgc, SelectGuide)
-	if guide is not None:
-	    self.current = guide
-	    self.set_correction(self.current.ButtonDown(p, button, state))
-	    self.current.Show(self.invgc)
-	else:
-	    # Make a new selection
-	    self.selection_rect(p, button, state)
+        # test for a guide line
+        guide = self.document.SelectPoint(p, self.hitgc, SelectGuide)
+        if guide is not None:
+            self.current = guide
+            self.set_correction(self.current.ButtonDown(p, button, state))
+            self.current.Show(self.invgc)
+        else:
+            # Make a new selection
+            self.selection_rect(p, button, state)
 
     def selection_click(self, p, button, state):
-	type = selection_type(state)
-	if type == SelectSet and self.document.SelectionHit(p, self.hitgc):
-	    self.document.ToggleSelectionBehaviour()
-	else:
-	    self.document.SelectPoint(p, self.hitgc, type)
+        type = selection_type(state)
+        if type == SelectSet and self.document.SelectionHit(p, self.hitgc):
+            self.document.ToggleSelectionBehaviour()
+        else:
+            self.document.SelectPoint(p, self.hitgc, type)
 
     def selection_up(self, p, button, state, force_stop = 0):
-	if not self.dragging:
-	    self.selection_click(p, button, state)
-	else:
-	    obj = self.stop_edit_object(p, button, state, force_stop)
-	    if obj is not None:
-		if isinstance(obj, SelectionRectangle):
-		    self.document.SelectRect(obj.bounding_rect,
-					     selection_type(state))
-		elif obj.is_GuideLine:
-		    # a guideline
-		    x = self.last_event.x
-		    y = self.last_event.y
-		    if (0 <= x < self.winfo_width()
-			and 0 <= y <= self.winfo_height()):
-			self.document.MoveGuideLine(obj, obj.drag_cur)
-		    else:
-			self.document.RemoveGuideLine(obj)
+        if not self.dragging:
+            self.selection_click(p, button, state)
+        else:
+            obj = self.stop_edit_object(p, button, state, force_stop)
+            if obj is not None:
+                if isinstance(obj, SelectionRectangle):
+                    self.document.SelectRect(obj.bounding_rect,
+                                             selection_type(state))
+                elif obj.is_GuideLine:
+                    # a guideline
+                    x = self.last_event.x
+                    y = self.last_event.y
+                    if (0 <= x < self.winfo_width()
+                        and 0 <= y <= self.winfo_height()):
+                        self.document.MoveGuideLine(obj, obj.drag_cur)
+                    else:
+                        self.document.RemoveGuideLine(obj)
 
-	self.show_handles()
-	self.current = None
-	self.start_drag = self.dragging = 0
+        self.show_handles()
+        self.current = None
+        self.start_drag = self.dragging = 0
 
     def selection_cancel(self):
-	if self.dragging:
-	    if self.current is not None:
-		self.current.Hide(self.invgc)
-		self.current = None
-	    self.dragging = 0
-	else:
-	    self.document.SelectNone()
-	self.start_drag = 0
+        if self.dragging:
+            if self.current is not None:
+                self.current.Hide(self.invgc)
+                self.current = None
+            self.dragging = 0
+        else:
+            self.document.SelectNone()
+        self.start_drag = 0
 
     #
     #	Edit mode
     #
     AddModeCmd('EditMode', _("Edit Mode"), bitmap = pixmaps.EditMode,
-	       value_on = 'Edit')
+               value_on = 'Edit')
     def EditMode(self):
-	self.begin_transaction()
-	self.document.SetMode(EditMode)
-	self.end_transaction()
+        self.begin_transaction()
+        self.document.SetMode(EditMode)
+        self.end_transaction()
 
     def edit_mode(self):
-	self.enter_mode(self.modes.edit_mode)
+        self.enter_mode(self.modes.edit_mode)
 
     def edit_enter(self):
-	self.create_creator = None
-	self.set_active_cursor(self.set_handle_cursor, const.CurEdit)
+        self.create_creator = None
+        self.set_active_cursor(self.set_handle_cursor, const.CurEdit)
 
     def edit_down(self, p, button, state):
-	self.start_pos = (p, button, state)
-	self.start_drag = 1
-	self.dragging = 0
+        self.start_pos = (p, button, state)
+        self.start_drag = 1
+        self.dragging = 0
 
     def edit_start_drag(self, p, button, state):
-	handle = self.handle_hit(p)
-	if handle is None:
-	    self.hitgc.StartOutlineMode()
-	    is_hit = self.document.SelectionHit(p, self.hitgc, test_all = 0)
-	    self.hitgc.EndOutlineMode()
-	else:
-	    is_hit = 1
-	if is_hit:
-	    # something is already selected and the user pressed the
-	    # button somewhere on the selection. Edit the current object
-	    self.begin_edit_object(p, button, state, handle)
-	else:
-	    # there's no selection or the user pressed the button
-	    # somewhere outside the current selection.
+        handle = self.handle_hit(p)
+        if handle is None:
+            self.hitgc.StartOutlineMode()
+            is_hit = self.document.SelectionHit(p, self.hitgc, test_all = 0)
+            self.hitgc.EndOutlineMode()
+        else:
+            is_hit = 1
+        if is_hit:
+            # something is already selected and the user pressed the
+            # button somewhere on the selection. Edit the current object
+            self.begin_edit_object(p, button, state, handle)
+        else:
+            # there's no selection or the user pressed the button
+            # somewhere outside the current selection.
 
-	    # test for a guide line
-	    guide = self.document.SelectPoint(p, self.hitgc, SelectGuide)
-	    if guide is not None:
-		# edit the guide line
-		self.current = guide
-		self.set_correction(self.current.ButtonDown(p, button, state))
-		self.current.Show(self.invgc)
-	    else:
-		# Make a new selection
-		self.selection_rect(p, button, state)
+            # test for a guide line
+            guide = self.document.SelectPoint(p, self.hitgc, SelectGuide)
+            if guide is not None:
+                # edit the guide line
+                self.current = guide
+                self.set_correction(self.current.ButtonDown(p, button, state))
+                self.current.Show(self.invgc)
+            else:
+                # Make a new selection
+                self.selection_rect(p, button, state)
 
     def edit_click(self, p, button, state):
-	handle = self.handle_hit(p)
-	if handle is not None:
-	    self.document.SelectHandle(handle, selection_type(state))
-	else:
+        handle = self.handle_hit(p)
+        if handle is not None:
+            self.document.SelectHandle(handle, selection_type(state))
+        else:
             self.hitgc.StartOutlineMode()
-	    is_hit = self.document.SelectionHit(p, self.hitgc, test_all = 0)
-	    self.hitgc.EndOutlineMode()
+            is_hit = self.document.SelectionHit(p, self.hitgc, test_all = 0)
+            self.hitgc.EndOutlineMode()
             if is_hit:
                 self.document.SelectPointPart(p, self.hitgc)
             else:
                 self.document.SelectPoint(p, self.hitgc)
 
     def edit_up(self, p, button, state, force_stop = stop_continue):
-	if not self.dragging:
-	    self.edit_click(p, button, state)
-	else:
-	    obj = self.stop_edit_object(p, button, state, force_stop)
-	    if obj.__class__ == SelectionRectangle:
-		self.document.SelectRectPart(obj.bounding_rect,
-					     selection_type(state))
-	    elif obj.is_GuideLine:
-		# a guideline
-		x = self.last_event.x
-		y = self.last_event.y
-		if 0 <= x < self.winfo_width() and 0<= y <=self.winfo_height():
-		    self.document.MoveGuideLine(obj, obj.drag_cur)
-		else:
-		    self.document.RemoveGuideLine(obj)
-	self.current = None
-	self.show_handles()
-	self.start_drag = 0
-	self.dragging = 0
+        if not self.dragging:
+            self.edit_click(p, button, state)
+        else:
+            obj = self.stop_edit_object(p, button, state, force_stop)
+            if obj.__class__ == SelectionRectangle:
+                self.document.SelectRectPart(obj.bounding_rect,
+                                             selection_type(state))
+            elif obj.is_GuideLine:
+                # a guideline
+                x = self.last_event.x
+                y = self.last_event.y
+                if 0 <= x < self.winfo_width() and 0<= y <=self.winfo_height():
+                    self.document.MoveGuideLine(obj, obj.drag_cur)
+                else:
+                    self.document.RemoveGuideLine(obj)
+        self.current = None
+        self.show_handles()
+        self.start_drag = 0
+        self.dragging = 0
 
     def edit_cancel(self):
-	if self.dragging:
-	    self.current.Hide(self.invgc)
-	    self.current = None
-	    self.dragging = 0
-	self.show_handles()
-	self.start_drag = 0
+        if self.dragging:
+            self.current.Hide(self.invgc)
+            self.current = None
+            self.dragging = 0
+        self.show_handles()
+        self.start_drag = 0
 
     #
     #	the standard mouse_move method for the modes
     #
 
     def drag_to(self, p, state):
-	self.dragging = 1
-	if self.current is not None and (state & self.current.drag_mask):
-	    # if something is being created/edited, hide it and show it
-	    # at new position
-	    self.current.Hide(self.invgc, 1)
-	    self.current.MouseMove(self.correct_and_snap(p), state)
-	    self.current.Show(self.invgc, 1)
+        self.dragging = 1
+        if self.current is not None and (state & self.current.drag_mask):
+            # if something is being created/edited, hide it and show it
+            # at new position
+            self.current.Hide(self.invgc, 1)
+            self.current.MouseMove(self.correct_and_snap(p), state)
+            self.current.Show(self.invgc, 1)
 
 
 
@@ -1108,155 +1108,155 @@
     #
 
     def PlaceObject(self, object, text = None):
-	self.begin_transaction()
+        self.begin_transaction()
         if self.IsCreationMode():
             self.creation_exit(set_mode = 1)
-	self.enter_mode(self.modes.place_mode, object, text)
-	self.end_transaction()
+        self.enter_mode(self.modes.place_mode, object, text)
+        self.end_transaction()
 
     def place_enter(self, object, text):
-	#self.create_creator = None
-	self.push_static_cursor(const.CurPlace)
-	self.place_object = object
-	self.place_text = text
-	self.start_drag = 1
+        #self.create_creator = None
+        self.push_static_cursor(const.CurPlace)
+        self.place_object = object
+        self.place_text = text
+        self.start_drag = 1
 
     def place_begin(self, p, button, state):
-	if self.start_drag:
-	    self.place_start_drag(p, state)
+        if self.start_drag:
+            self.place_start_drag(p, state)
 
     def place_start_drag(self, p, state):
-	if self.place_object.is_GuideLine:
-	    self.place_object.SetPoint(p)
-	    self.current = self.place_object
-	else:
-	    self.place_object.SetLowerLeftCorner(p)
-	    self.current = SelectionRectangle(self.place_object.coord_rect,
-                                    anchor = self.place_object.LayoutPoint())
-	    self.current.Select()
-	# selection rect doesn't use button and state:
-	self.set_correction(self.current.ButtonDown(p, 0, state))
-	self.current.Show(self.invgc)
-	self.dragging = 1
-	self.start_drag = 0
+        if self.place_object.is_GuideLine:
+            self.place_object.SetPoint(p)
+            self.current = self.place_object
+        else:
+            self.place_object.SetLowerLeftCorner(p)
+            self.current = SelectionRectangle(self.place_object.coord_rect,
+                                              anchor = self.place_object.LayoutPoint())
+            self.current.Select()
+        # selection rect doesn't use button and state:
+        self.set_correction(self.current.ButtonDown(p, 0, state))
+        self.current.Show(self.invgc)
+        self.dragging = 1
+        self.start_drag = 0
 
     def place_drag(self, p, state):
-	if self.start_drag:
-	    self.place_start_drag(p, state)
-	self.dragging = 1
-	if self.current is not None:
-	    # if something is being placed, hide it and show it at new
-	    # position
-	    self.current.Hide(self.invgc, 1)
-	    state = state | const.Button1Mask
-	    self.current.MouseMove(self.correct_and_snap(p), state)
-	    self.current.Show(self.invgc, 1)
+        if self.start_drag:
+            self.place_start_drag(p, state)
+        self.dragging = 1
+        if self.current is not None:
+            # if something is being placed, hide it and show it at new
+            # position
+            self.current.Hide(self.invgc, 1)
+            state = state | const.Button1Mask
+            self.current.MouseMove(self.correct_and_snap(p), state)
+            self.current.Show(self.invgc, 1)
 
     def place_cancel(self):
-	self.pop_cursor_state()
-	if self.current is not None:
-	    self.current.Hide(self.invgc)
-	self.current = None
-	self.place_object = None
-	self.place_text = None
-	self.dragging = 0
-	self.start_drag = 0
+        self.pop_cursor_state()
+        if self.current is not None:
+            self.current.Hide(self.invgc)
+        self.current = None
+        self.place_object = None
+        self.place_text = None
+        self.dragging = 0
+        self.start_drag = 0
 
     def place_end(self, p, button, state, force_stop = stop_continue):
-	self.pop_cursor_state()
-	if self.current is None:
-	    return
-	rect = self.current
-	rect.Hide(self.invgc)
-	p = self.correct_and_snap(p)
-	rect.ButtonUp(p, button, state)
-	self.current = None
+        self.pop_cursor_state()
+        if self.current is None:
+            return
+        rect = self.current
+        rect.Hide(self.invgc)
+        p = self.correct_and_snap(p)
+        rect.ButtonUp(p, button, state)
+        self.current = None
 
-	obj = self.place_object
-	self.place_object = None
-	if obj.is_GuideLine:
-	    x = self.last_event.x
-	    y = self.last_event.y
-	    if (0 <= x < self.winfo_width() and 0 <= y <= self.winfo_height()):
-		obj.SetPoint(p)
-	    else:
-		# guide line is outside of the canvas window.
-		obj = None
-	else:
-	    obj.SetLowerLeftCorner(rect.start)
-	if obj:
-	    if self.place_text:
-		self.document.Insert(obj, self.place_text)
-	    else:
-		self.document.Insert(obj)
-	self.place_text = None
+        obj = self.place_object
+        self.place_object = None
+        if obj.is_GuideLine:
+            x = self.last_event.x
+            y = self.last_event.y
+            if (0 <= x < self.winfo_width() and 0 <= y <= self.winfo_height()):
+                obj.SetPoint(p)
+            else:
+                # guide line is outside of the canvas window.
+                obj = None
+        else:
+            obj.SetLowerLeftCorner(rect.start)
+        if obj:
+            if self.place_text:
+                self.document.Insert(obj, self.place_text)
+            else:
+                self.document.Insert(obj)
+        self.place_text = None
 
     #
     #		Pick object mode
     #
 
     def PickObject(self, callback, args = ()):
-	self.begin_transaction()
-	self.enter_mode(self.modes.pick_mode, callback, args)
-	self.end_transaction()
+        self.begin_transaction()
+        self.enter_mode(self.modes.pick_mode, callback, args)
+        self.end_transaction()
 
     def pick_enter(self, callback, args):
-	self.create_creator = None
-	self.push_static_cursor(const.CurPick)
-	self.pick_object_cb = callback, args
+        self.create_creator = None
+        self.push_static_cursor(const.CurPick)
+        self.pick_object_cb = callback, args
 
     def pick_begin(self, p, button, state):
-	pass
+        pass
 
     def pick_cancel(self):
-	self.pop_cursor_state()
-	self.pick_object_cb = None
+        self.pop_cursor_state()
+        self.pick_object_cb = None
 
     def pick_end(self, p, button, state, force_stop = stop_continue):
-	self.pop_cursor_state()
-	object = self.document.PickObject(self.hitgc, p)
-	cb, args = self.pick_object_cb
-	self.pick_object_cb = None
-	args = (object,) + args
-	apply(cb, args)
+        self.pop_cursor_state()
+        object = self.document.PickObject(self.hitgc, p)
+        cb, args = self.pick_object_cb
+        self.pick_object_cb = None
+        args = (object,) + args
+        apply(cb, args)
 
     #
     #		Zoom mode
     #
 
     AddModeCmd('ZoomMode', _("Zoom Area"), bitmap = pixmaps.Zoom,
-	       value_on = 'Zoom')
+               value_on = 'Zoom')
     def ZoomMode(self):
-	self.begin_transaction()
-	self.enter_mode(self.modes.zoom_mode)
-	self.end_transaction()
+        self.begin_transaction()
+        self.enter_mode(self.modes.zoom_mode)
+        self.end_transaction()
 
     def zoom_enter(self):
-	self.push_static_cursor(const.CurZoom)
+        self.push_static_cursor(const.CurZoom)
 
     def zoom_begin(self, p, button, state):
-	self.begin_creator(SelectionRectangle, p, button, state)
+        self.begin_creator(SelectionRectangle, p, button, state)
 
     def zoom_cancel(self):
-	self.pop_cursor_state()
-	if self.current is not None:
-	    self.current.Hide(self.invgc)
-	self.current = None
-	self.dragging = 0
-	self.start_drag = 0
+        self.pop_cursor_state()
+        if self.current is not None:
+            self.current.Hide(self.invgc)
+        self.current = None
+        self.dragging = 0
+        self.start_drag = 0
 
     def zoom_end(self, p, button, state, force_stop = stop_continue):
-	self.pop_cursor_state()
-	obj = None
-	if self.current is not None:
-	    obj = self.current
-	    obj.Hide(self.invgc)
-	    obj.ButtonUp(self.correct_and_snap(p), button, state)
-	    self.current = None
+        self.pop_cursor_state()
+        obj = None
+        if self.current is not None:
+            obj = self.current
+            obj.Hide(self.invgc)
+            obj.ButtonUp(self.correct_and_snap(p), button, state)
+            self.current = None
 
         zoom_out = state & const.ControlMask
 
-	self.save_viewport()
+        self.save_viewport()
         if self.dragging and obj is not None:
             epsilon = 1e-10
             rect = obj.bounding_rect
@@ -1285,53 +1285,53 @@
         self.SetScale(scale / self.pixel_per_point, do_center = 0)
         self.SetCenter(center, move_contents = 0)
 
-	self.start_drag = 0
-	self.dragging = 0
+        self.start_drag = 0
+        self.dragging = 0
 
     #
     #	Other mode related methods
     #
 
     AddCmd('ToggleMode', _("Toggle Mode"), key_stroke = (' ', 'C-space'),
-	   subscribe_to = None)
+           subscribe_to = None)
     def ToggleMode(self):
-	self.begin_transaction()
-	try:
-	    if self.IsCreationMode():
-		self.SelectionMode()
-	    elif self.IsSelectionMode():
-		self.EditMode()
-	    else:
-		# go to selection mode as default
-		self.SelectionMode()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            if self.IsCreationMode():
+                self.SelectionMode()
+            elif self.IsSelectionMode():
+                self.EditMode()
+            else:
+                # go to selection mode as default
+                self.SelectionMode()
+        finally:
+            self.end_transaction()
 
     def set_mode_from_doc(self, *args, **kwargs):
-	mode = self.document.Mode()
-	if mode == SelectionMode:
-	    self.selection_mode()
-	else:
-	    self.edit_mode()
-	self.update_object_keymap()
+        mode = self.document.Mode()
+        if mode == SelectionMode:
+            self.selection_mode()
+        else:
+            self.edit_mode()
+        self.update_object_keymap()
 
     def IsSelectionMode(self):
-	return self.mode == self.modes.selection_mode
+        return self.mode == self.modes.selection_mode
 
     def IsEditMode(self):
-	return self.mode == self.modes.edit_mode
+        return self.mode == self.modes.edit_mode
 
     def IsCreationMode(self):
-	return self.mode == self.modes.creation_mode
+        return self.mode == self.modes.creation_mode
 
     def ModeInfoText(self):
-	return self.mode.text
+        return self.mode.text
 
     def ModeName(self):
-	name = self.mode.name
-	if name == 'Create':
-	    name = name + ':' + self.create_type
-	return name
+        name = self.mode.name
+        if name == 'Create':
+            name = name + ':' + self.create_type
+        return name
 
 
 
@@ -1340,8 +1340,8 @@
     #
 
     def SelectionInfoText(self):
-	# Return a string describing the currently selected objects
-	return self.document.SelectionInfoText()
+        # Return a string describing the currently selected objects
+        return self.document.SelectionInfoText()
 
 
     #
@@ -1349,36 +1349,36 @@
     #
 
     def set_correction(self, correct):
-	if type(correct) == TupleType:
-	    correct, rect = correct
-	else:
-	    rect = None
-	    if correct is None:
-		correct = Point(0, 0)
-	self.correction = correct
-	self.correction_rect = rect
+        if type(correct) == TupleType:
+            correct, rect = correct
+        else:
+            rect = None
+            if correct is None:
+                correct = Point(0, 0)
+        self.correction = correct
+        self.correction_rect = rect
 
     snap_update_installed = 0
     def update_snap_points(self):
-	if self.snap_to_object and not self.snap_update_installed:
-	    self.after_idle(self.idle_update_snap_points)
-	    self.snap_update_installed = 1
+        if self.snap_to_object and not self.snap_update_installed:
+            self.after_idle(self.idle_update_snap_points)
+            self.snap_update_installed = 1
 
     def extract_snap_points(self, obj):
-	self.snap_points[0:0] = obj.GetSnapPoints()
+        self.snap_points[0:0] = obj.GetSnapPoints()
 
     def idle_update_snap_points(self):
-	self.snap_update_installed = 0
-	self.snap_points = []
-	self.document.WalkHierarchy(self.extract_snap_points, visible = 1,
-				    printable = 0)
-	self.snap_points.sort()
+        self.snap_update_installed = 0
+        self.snap_points = []
+        self.document.WalkHierarchy(self.extract_snap_points, visible = 1,
+                                    printable = 0)
+        self.snap_points.sort()
 
     def correct_and_snap(self, point):
-	point = point - self.correction
+        point = point - self.correction
         points = [point]
-	if self.correction_rect and self.snap_correction_rect:
-	    l, b, r, t = self.correction_rect.translated(point)
+        if self.correction_rect and self.snap_correction_rect:
+            l, b, r, t = self.correction_rect.translated(point)
             points = points + [Point(l,b), Point(l,t), Point(r,b), Point(r,t)]
 
         if self.dragging and self.start_pos \
@@ -1396,20 +1396,20 @@
                 mindist = dist
                 result = point - p + snapped
 
-	self.set_current_pos(result)
-	return result
+        self.set_current_pos(result)
+        return result
 
     def snap_point(self, p):
-	dist, p = self.snap_point_dist(p)
-	return p
+        dist, p = self.snap_point_dist(p)
+        return p
 
     def snap_point_dist(self, p):
-	maxdist = preferences.max_snap_distance / self.scale
-	pgrid = pobj = pguide = pmax = (maxdist, p)
-	if self.snap_to_grid:
-	    pgrid = self.document.SnapToGrid(p)
-	if self.snap_to_guide:
-	    pgh, pgv, pguide = self.document.SnapToGuide(p, maxdist)
+        maxdist = preferences.max_snap_distance / self.scale
+        pgrid = pobj = pguide = pmax = (maxdist, p)
+        if self.snap_to_grid:
+            pgrid = self.document.SnapToGrid(p)
+        if self.snap_to_guide:
+            pgh, pgv, pguide = self.document.SnapToGuide(p, maxdist)
             if (self.current is None
                 or isinstance(self.current, SelectionRectangle)
                 or not self.current.is_GuideLine):
@@ -1417,129 +1417,129 @@
                 # or to guide-objects. Otherwise, only snap to guide
                 # objects
                 pguide = min(pgh, pgv, pguide)
-	    if pguide == pgh or pguide == pgv:
-		dist, (x, y) = pguide
-		if x is None:
-		    if pgv[0] < maxdist:
-			x = pgv[-1][0]
-			dist = dist + pgv[0] - maxdist
-		    else:
-			x = p.x
-		else:
-		    if pgh[0] < maxdist:
-			y = pgh[-1][1]
-			dist = dist + pgh[0] - maxdist
-		    else:
-			y = p.y
-		pguide = dist, Point(x, y)
-	if self.snap_to_object and self.snap_points:
-	    x, y = p
-	    mindist = 1e100;
-	    xlow = x - maxdist; ylow = y - maxdist
-	    xhigh = x + maxdist; yhigh = y + maxdist
-	    points = self.snap_points
-	    ilow = 0; ihigh = len(points)
-	    while ilow < ihigh:
-		imid = (ilow + ihigh) / 2
-		if points[imid].x > xlow:
-		    ihigh = imid
-		else:
-		    ilow = imid + 1
-	    for idx in range(ilow, len(points)):
-		pmin = points[idx]
-		if pmin.x > xhigh:
-		    break
-		if ylow < pmin.y < yhigh:
-		    dist = max(abs(pmin.x - x), abs(pmin.y - y))
-		    if dist < mindist:
-			pobj = pmin
-			mindist = dist
-	    if type(pobj) != TupleType:
-		pobj = (abs(pobj - p), pobj)
+            if pguide == pgh or pguide == pgv:
+                dist, (x, y) = pguide
+                if x is None:
+                    if pgv[0] < maxdist:
+                        x = pgv[-1][0]
+                        dist = dist + pgv[0] - maxdist
+                    else:
+                        x = p.x
+                else:
+                    if pgh[0] < maxdist:
+                        y = pgh[-1][1]
+                        dist = dist + pgh[0] - maxdist
+                    else:
+                        y = p.y
+                pguide = dist, Point(x, y)
+        if self.snap_to_object and self.snap_points:
+            x, y = p
+            mindist = 1e100;
+            xlow = x - maxdist; ylow = y - maxdist
+            xhigh = x + maxdist; yhigh = y + maxdist
+            points = self.snap_points
+            ilow = 0; ihigh = len(points)
+            while ilow < ihigh:
+                imid = (ilow + ihigh) / 2
+                if points[imid].x > xlow:
+                    ihigh = imid
+                else:
+                    ilow = imid + 1
+            for idx in range(ilow, len(points)):
+                pmin = points[idx]
+                if pmin.x > xhigh:
+                    break
+                if ylow < pmin.y < yhigh:
+                    dist = max(abs(pmin.x - x), abs(pmin.y - y))
+                    if dist < mindist:
+                        pobj = pmin
+                        mindist = dist
+            if type(pobj) != TupleType:
+                pobj = (abs(pobj - p), pobj)
 
-	result = min(pgrid, pguide, pobj, pmax)
-	return result
+        result = min(pgrid, pguide, pobj, pmax)
+        return result
 
     AddCmd('ToggleSnapToGrid', _("Snap to Grid"), bitmap = pixmaps.GridOn,
-	   value = 0, value_cb = 'IsSnappingToGrid', is_check = 1)
+           value = 0, value_cb = 'IsSnappingToGrid', is_check = 1)
     def ToggleSnapToGrid(self):
-	self.begin_transaction()
-	try:
-	    self.snap_to_grid = not self.snap_to_grid
-	    self.issue_state()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            self.snap_to_grid = not self.snap_to_grid
+            self.issue_state()
+        finally:
+            self.end_transaction()
 
     def IsSnappingToGrid(self):
-	return self.snap_to_grid
+        return self.snap_to_grid
 
 
     AddCmd('ToggleSnapToObjects', _("Snap to Objects"),
-	   value = 0, value_cb = 'IsSnappingToObjects', is_check = 1)
+           value = 0, value_cb = 'IsSnappingToObjects', is_check = 1)
     def ToggleSnapToObjects(self):
-	self.begin_transaction()
-	try:
-	    self.snap_to_object = not self.snap_to_object
-	    self.snap_points = ()
-	    self.update_snap_points()
-	    self.issue_state()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            self.snap_to_object = not self.snap_to_object
+            self.snap_points = ()
+            self.update_snap_points()
+            self.issue_state()
+        finally:
+            self.end_transaction()
 
     def IsSnappingToObjects(self):
-	return self.snap_to_object
+        return self.snap_to_object
 
     AddCmd('ToggleSnapToGuides', _("Snap to Guides"),
-	   value = 0, value_cb = 'IsSnappingToGuides', is_check = 1)
+           value = 0, value_cb = 'IsSnappingToGuides', is_check = 1)
     def ToggleSnapToGuides(self):
-	self.begin_transaction()
-	try:
-	    self.snap_to_guide = not self.snap_to_guide
-	    self.issue_state()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            self.snap_to_guide = not self.snap_to_guide
+            self.issue_state()
+        finally:
+            self.end_transaction()
 
     def IsSnappingToGuides(self):
-	return self.snap_to_guide
+        return self.snap_to_guide
 
     AddCmd('ToggleSnapBoundingRect', _("Snap Bounding Rect"),
-	   value = 0, value_cb = 'IsSnappingBoundingRect', is_check = 1)
+           value = 0, value_cb = 'IsSnappingBoundingRect', is_check = 1)
     def ToggleSnapBoundingRect(self):
-	self.begin_transaction()
-	try:
-	    self.snap_correction_rect = not self.snap_correction_rect
-	    self.issue_state()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            self.snap_correction_rect = not self.snap_correction_rect
+            self.issue_state()
+        finally:
+            self.end_transaction()
 
     def IsSnappingBoundingRect(self):
-	return self.snap_correction_rect
+        return self.snap_correction_rect
 
     AddCmd('ToggleSnapMoveRelative', _("Snap Move Relative"),
-	   value = 0, value_cb = 'IsSnappingRelative', is_check = 1)
+           value = 0, value_cb = 'IsSnappingRelative', is_check = 1)
     def ToggleSnapMoveRelative(self):
-	self.begin_transaction()
-	try:
+        self.begin_transaction()
+        try:
             self.snap_move_relative = not self.snap_move_relative
             self.issue_state()
-	finally:
-	    self.end_transaction()
+        finally:
+            self.end_transaction()
 
     def IsSnappingRelative(self):
-	return self.snap_move_relative
+        return self.snap_move_relative
 
     def SnapInfoText(self):
-	# NLS might make problems here
-	snap = []
-	if self.snap_to_grid:
-	    snap.append(_("Grid"))
-	if self.snap_to_object:
-	    snap.append(_("Objects"))
-	if self.snap_to_guide:
-	    snap.append(_("Guide"))
-	if snap:
-	    return _("Snap: ") + string.join(snap, '/')
-	return _("No Snap")
+        # NLS might make problems here
+        snap = []
+        if self.snap_to_grid:
+            snap.append(_("Grid"))
+        if self.snap_to_object:
+            snap.append(_("Objects"))
+        if self.snap_to_guide:
+            snap.append(_("Guide"))
+        if snap:
+            return _("Snap: ") + string.join(snap, '/')
+        return _("No Snap")
 
     #
     #   Crosshairs
@@ -1571,126 +1571,126 @@
         self.crosshairs_drawn = 0
 
     AddCmd('ToggleCrosshairs', _("Crosshairs"), key_stroke = 'F2',
-	   value = 0, value_cb = 'IsShowingCrosshairs', is_check = 1)
+           value = 0, value_cb = 'IsShowingCrosshairs', is_check = 1)
     def ToggleCrosshairs(self):
-	self.begin_transaction()
-	try:
+        self.begin_transaction()
+        try:
             self.hide_crosshairs()
             self.crosshairs = not self.crosshairs
             self.show_crosshairs()
             self.issue_state()
-	finally:
-	    self.end_transaction()
+        finally:
+            self.end_transaction()
 
     def IsShowingCrosshairs(self):
-	return self.crosshairs
+        return self.crosshairs
 
 
-    
+
     #
     #	Handles
     #
 
     def init_handles(self):
-	self.handle_points = []
-	self.handle_funcs = []
-	self.handles_drawn = 0
+        self.handle_points = []
+        self.handle_funcs = []
+        self.handles_drawn = 0
 
     handle_update_installed = 0
     def update_handles(self):
-	self.hide_handles()
-	if not self.handle_update_installed:
-	    self.after_idle(self.idle_update_handles)
-	self.handle_update_installed = 1
+        self.hide_handles()
+        if not self.handle_update_installed:
+            self.after_idle(self.idle_update_handles)
+        self.handle_update_installed = 1
 
     def idle_update_handles(self):
-	self.handle_update_installed = 0
-	self.set_handles(self.document.GetSelectionHandles())
+        self.handle_update_installed = 0
+        self.set_handles(self.document.GetSelectionHandles())
 
     def set_handles(self, handles):
-	from Sketch.const import HandleLine, Handle_Pixmap, Handle_Caret, \
-	     Handle_SmallOpenRectList
-	points = []
-	funcs = []
+        from Sketch.const import HandleLine, Handle_Pixmap, Handle_Caret, \
+             Handle_SmallOpenRectList
+        points = []
+        funcs = []
         used = {}
-	if self.gcs_initialized:
-	    factor = self.gc.LengthToDoc(8)
-	else:
-	    factor = 1
+        if self.gcs_initialized:
+            factor = self.gc.LengthToDoc(8)
+        else:
+            factor = 1
 
-	for handle in handles:
-	    handle_type = handle.type
-	    p = handle.p
-	    cursor = handle.cursor
+        for handle in handles:
+            handle_type = handle.type
+            p = handle.p
+            cursor = handle.cursor
 
-	    if handle.offset is not None:
-		offset = handle.offset
-		p = p + Point(offset[0] * factor, offset[1] * factor)
+            if handle.offset is not None:
+                offset = handle.offset
+                p = p + Point(offset[0] * factor, offset[1] * factor)
 
-	    if handle_type == HandleLine:
-		funcs.append((self.invgc.DrawHandleLine, (p, handle.p2)))
-	    elif handle_type == Handle_Pixmap:
-		if cursor:
-		    points.append(self.DocToWin(p) + (cursor, handle))
-		funcs.append((self.draw_handle_funcs[handle_type],
+            if handle_type == HandleLine:
+                funcs.append((self.invgc.DrawHandleLine, (p, handle.p2)))
+            elif handle_type == Handle_Pixmap:
+                if cursor:
+                    points.append(self.DocToWin(p) + (cursor, handle))
+                funcs.append((self.draw_handle_funcs[handle_type],
                               (p, handle.pixmap)))
-	    elif handle_type == Handle_Caret:
-		funcs.append((self.invgc.DrawCaretHandle, (p, handle.p2)))
-	    elif handle_type == Handle_SmallOpenRectList:
-		p = handle.list
-		if p:
-		    pts = map(self.DocToWin, p)
-		    last = pts[-1]
-		    for idx in range(len(p) - 2, -1, -1):
-			if pts[idx] == last:
-			    del p[idx]
-			else:
-			    last = pts[idx]
-		    funcs.append((self.draw_handle_funcs[handle_type], (p, 0)))
-	    else:
+            elif handle_type == Handle_Caret:
+                funcs.append((self.invgc.DrawCaretHandle, (p, handle.p2)))
+            elif handle_type == Handle_SmallOpenRectList:
+                p = handle.list
+                if p:
+                    pts = map(self.DocToWin, p)
+                    last = pts[-1]
+                    for idx in range(len(p) - 2, -1, -1):
+                        if pts[idx] == last:
+                            del p[idx]
+                        else:
+                            last = pts[idx]
+                    funcs.append((self.draw_handle_funcs[handle_type], (p, 0)))
+            else:
                 win = self.DocToWin(p)
                 if cursor:
-		    points.append(win + (cursor, handle))
+                    points.append(win + (cursor, handle))
                 if not used.has_key(win):
                     funcs.append((self.draw_handle_funcs[handle_type],
                                   (p, handle_type & 1)))
                     used[win] = 0
 
-	self.hide_handles()
-	self.handle_points = points
-	self.handle_funcs  = funcs
-	self.show_handles()
+        self.hide_handles()
+        self.handle_points = points
+        self.handle_funcs  = funcs
+        self.show_handles()
 
     def show_handles(self, force = 0):
-	if __debug__:
-	    pdebug('handles',
-		   'show_handles: drawn = %d, force = %d, update = %d',
-		   self.handles_drawn, force, self.handle_update_installed)
-	if not self.handle_update_installed\
-	   and (not self.handles_drawn or force):
-	    self.draw_handles()
-	    self.handles_drawn = 1
+        if __debug__:
+            pdebug('handles',
+                   'show_handles: drawn = %d, force = %d, update = %d',
+                   self.handles_drawn, force, self.handle_update_installed)
+        if not self.handle_update_installed\
+           and (not self.handles_drawn or force):
+            self.draw_handles()
+            self.handles_drawn = 1
 
     def hide_handles(self):
-	if __debug__:
-	    pdebug('handles', 'hide_handles: drawn = %d', self.handles_drawn)
-	if self.handles_drawn:
-	    self.draw_handles()
-	    self.handles_drawn = 0
+        if __debug__:
+            pdebug('handles', 'hide_handles: drawn = %d', self.handles_drawn)
+        if self.handles_drawn:
+            self.draw_handles()
+            self.handles_drawn = 0
 
     def draw_handles(self):
-	for f, args in self.handle_funcs:
-	    apply(f, args)
+        for f, args in self.handle_funcs:
+            apply(f, args)
 
 
     handle_hit_radius = 4
     def set_handle_cursor(self, x, y):
-	dist = self.handle_hit_radius
-	for xp, yp, cursor, handle in self.handle_points:
-	    if abs(xp - x) < dist and abs(yp - y) < dist:
-		self.set_window_cursor(cursor)
-		break
-	else:
+        dist = self.handle_hit_radius
+        for xp, yp, cursor, handle in self.handle_points:
+            if abs(xp - x) < dist and abs(yp - y) < dist:
+                self.set_window_cursor(cursor)
+                break
+        else:
             cursor = self.cursor_shape
             if preferences.active_cursor:
                 object = self.document.PickActiveObject(self.hitgc,
@@ -1703,18 +1703,18 @@
                             cursor = const.CurVGuide
                     elif self.IsSelectionMode():
                         cursor = const.CurMove
-	    self.set_window_cursor(cursor)
+            self.set_window_cursor(cursor)
 
     def handle_hit(self, p):
-	x, y = self.DocToWin(p)
-	dist = self.handle_hit_radius
-	handle_points = self.handle_points
-	for idx in range(len(handle_points)):
-	    xp, yp, cursor, handle = handle_points[idx]
-	    if abs(xp - x) < dist and abs(yp - y) < dist:
-		handle.index = idx
-		return handle
-	return None
+        x, y = self.DocToWin(p)
+        dist = self.handle_hit_radius
+        handle_points = self.handle_points
+        for idx in range(len(handle_points)):
+            xp, yp, cursor, handle = handle_points[idx]
+            if abs(xp - x) < dist and abs(yp - y) < dist:
+                handle.index = idx
+                return handle
+        return None
 
     #
     #	Viewport- and related methods
@@ -1727,24 +1727,24 @@
 
 
     def set_origin(self, xorg, yorg, move_contents = 1):
-	self.begin_transaction()
-	try:
-	    #self.hide_handles()
-	    SketchView.set_origin(self, xorg, yorg,
-				  move_contents = move_contents)
-	    self.queue_update_handles()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            #self.hide_handles()
+            SketchView.set_origin(self, xorg, yorg,
+                                  move_contents = move_contents)
+            self.queue_update_handles()
+        finally:
+            self.end_transaction()
 
     def SetScale(self, scale, do_center = 1):
-	# Set current scale
-	self.begin_transaction()
-	try:
-	    self.hide_handles() # XXX: really necessary ?
-	    SketchView.SetScale(self, scale, do_center = do_center)
-	    self.queue_update_handles()
-	finally:
-	    self.end_transaction()
+        # Set current scale
+        self.begin_transaction()
+        try:
+            self.hide_handles() # XXX: really necessary ?
+            SketchView.SetScale(self, scale, do_center = do_center)
+            self.queue_update_handles()
+        finally:
+            self.end_transaction()
 
     def ZoomFactor(self, factor):
         self.SetScale(self.scale * factor)
@@ -1752,101 +1752,101 @@
            key_stroke = '>')
     AddCmd('ZoomOut', _("Zoom Out"), 'ZoomFactor', args = 0.5,
            key_stroke = '<')
-           
 
 
+
     # add commands for inherited methods
     AddCmd('ScrollYPages', 'Page Up', args = -1, key_stroke = 'Prior',
-	   subscribe_to = None)
+           subscribe_to = None)
     AddCmd('ScrollYPages', 'Page Down', args = +1, key_stroke = 'Next',
-	   subscribe_to = None)
+           subscribe_to = None)
 
     # scrolling with the cursor keys
     AddCmd('ScrollYPages', '', args = -1, key_stroke = 'C-Up',
-	   subscribe_to = None)
+           subscribe_to = None)
     AddCmd('ScrollYPages', '', args = +1, key_stroke = 'C-Down',
-	   subscribe_to = None)
+           subscribe_to = None)
     AddCmd('ScrollXPages', '', args = -1, key_stroke = 'C-Left',
-	   subscribe_to = None)
+           subscribe_to = None)
     AddCmd('ScrollXPages', '', args = +1, key_stroke = 'C-Right',
-	   subscribe_to = None)
+           subscribe_to = None)
 
     #	other view related methods
 
     AddCmd('FitToWindow', _("Fit to Window"), key_stroke = 'S-F4',
-	   subscribe_to = None)
+           subscribe_to = None)
     AddSelCmd('FitSelectedToWindow', _("Fit Selected to Window"),
-	      'FitToWindow', args = 1, key_stroke = 'C-F4')
+              'FitToWindow', args = 1, key_stroke = 'C-F4')
     def FitToWindow(self, selected_only = 0, save_viewport = 1):
-	self.begin_transaction()
-	try:
-	    self.hide_handles() # XXX: really necessary ?
-	    SketchView.FitToWindow(self, selected_only = selected_only,
-				   save_viewport = save_viewport)
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            self.hide_handles() # XXX: really necessary ?
+            SketchView.FitToWindow(self, selected_only = selected_only,
+                                   save_viewport = save_viewport)
+        finally:
+            self.end_transaction()
 
     AddCmd('FitPageToWindow', _("Fit Page to Window"), key_stroke = 'F4',
-	   subscribe_to = None)
+           subscribe_to = None)
     def FitPageToWindow(self, save_viewport = 1):
-	self.begin_transaction()
-	try:
-	    self.hide_handles()	 # XXX: really necessary ?
-	    SketchView.FitPageToWindow(self, save_viewport = save_viewport)
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            self.hide_handles()	 # XXX: really necessary ?
+            SketchView.FitPageToWindow(self, save_viewport = save_viewport)
+        finally:
+            self.end_transaction()
 
     def CanRestoreViewport(self):
-	return len(self.viewport_ring)
+        return len(self.viewport_ring)
 
     AddCmd('RestoreViewport', _("Restore Previous View"), key_stroke = 'F3',
-	   subscribe_to = VIEW, sensitive_cb = 'CanRestoreViewport')
+           subscribe_to = VIEW, sensitive_cb = 'CanRestoreViewport')
     def RestoreViewport(self):
-	if self.viewport_ring:
-	    self.begin_transaction()
-	    try:
-		self.restore_viewport()
-	    finally:
-		self.end_transaction()
+        if self.viewport_ring:
+            self.begin_transaction()
+            try:
+                self.restore_viewport()
+            finally:
+                self.end_transaction()
 
     AddCmd('ToggleOutlineMode', _("Outline"), key_stroke = 'S-F9',
-	   value = 0, value_cb = 'IsOutlineMode', subscribe_to = VIEW,
-	   is_check = 1)
+           value = 0, value_cb = 'IsOutlineMode', subscribe_to = VIEW,
+           is_check = 1)
 
     AddCmd('TogglePageOutlineMode', _("Draw Page Outline"),
-	   value = 0, value_cb = 'IsPageOutlineMode', subscribe_to = VIEW,
-	   is_check = 1)
+           value = 0, value_cb = 'IsPageOutlineMode', subscribe_to = VIEW,
+           is_check = 1)
 
     #
     #
     #
 
     def unsubscribe_doc(self):
-	if self.document is not None:
-	    self.document.Unsubscribe(SELECTION,self.selection_changed)
-	    self.document.Unsubscribe(EDITED,self.doc_was_edited)
-	    self.document.Unsubscribe(MODE, self.set_mode_from_doc)
-	SketchView.unsubscribe_doc(self)
+        if self.document is not None:
+            self.document.Unsubscribe(SELECTION,self.selection_changed)
+            self.document.Unsubscribe(EDITED,self.doc_was_edited)
+            self.document.Unsubscribe(MODE, self.set_mode_from_doc)
+        SketchView.unsubscribe_doc(self)
 
     def subscribe_doc(self):
-	self.document.Subscribe(SELECTION, self.selection_changed)
-	self.document.Subscribe(EDITED,self.doc_was_edited)
-	self.document.Subscribe(MODE, self.set_mode_from_doc)
-	SketchView.subscribe_doc(self)
+        self.document.Subscribe(SELECTION, self.selection_changed)
+        self.document.Subscribe(EDITED,self.doc_was_edited)
+        self.document.Subscribe(MODE, self.set_mode_from_doc)
+        SketchView.subscribe_doc(self)
 
     def SetDocument(self, doc):
-	self.begin_transaction()
-	try:
-	    SketchView.SetDocument(self, doc)
-	    self.SelectionMode()
-	    self.hide_handles()
-	    self.issue_selection()
-	    self.issue_mode()
-	    self.update_handles()
-	    self.update_snap_points()
-	finally:
-	    self.end_transaction()
-	    self.init_viewport_ring()
+        self.begin_transaction()
+        try:
+            SketchView.SetDocument(self, doc)
+            self.SelectionMode()
+            self.hide_handles()
+            self.issue_selection()
+            self.issue_mode()
+            self.update_handles()
+            self.update_snap_points()
+        finally:
+            self.end_transaction()
+            self.init_viewport_ring()
 
 
     #
@@ -1855,18 +1855,18 @@
 
     AddSelCmd('FillSolid', _("Set Fill Color..."))
     def FillSolid(self, col = None):
-	# Set the fill style of the currently selected objects to a
-	# solid fill of color COL. If COL is None let the user
-	# interactively select a color.
-	if col is None:
-	    import colordlg
-	    current_color = self.document.CurrentFillColor()
-	    if current_color is None:
-		current_color = StandardColors.white
-	    col = colordlg.GetColor(self, current_color)
-	    if not col:
-		return
-	from Sketch import SolidPattern
+        # Set the fill style of the currently selected objects to a
+        # solid fill of color COL. If COL is None let the user
+        # interactively select a color.
+        if col is None:
+            import colordlg
+            current_color = self.document.CurrentFillColor()
+            if current_color is None:
+                current_color = StandardColors.white
+            col = colordlg.GetColor(self, current_color)
+            if not col:
+                return
+        from Sketch import SolidPattern
         import styledlg
         styledlg.set_properties(self.master, self.document,
                                 _("Set Fill Color"), 'fill',
@@ -1877,13 +1877,13 @@
     #	LineStyle
     #
     def LineColor(self, color):
-	# Set the line color of the currently selected objects to COLOR
-	# XXX: should be removed; only needed by skapp to connect
-	# palette with canvas. (Dec 97)
-	if self.document.CountSelected() > 1:
-	    self.call_document_method('SetLineColor', color)
-	else:
-	    from Sketch import SolidPattern
+        # Set the line color of the currently selected objects to COLOR
+        # XXX: should be removed; only needed by skapp to connect
+        # palette with canvas. (Dec 97)
+        if self.document.CountSelected() > 1:
+            self.call_document_method('SetLineColor', color)
+        else:
+            from Sketch import SolidPattern
             import styledlg
             styledlg.set_properties(self.master, self.document,
                                     _("Set Line Color"), 'line',

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/colordlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/colordlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/colordlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -42,48 +42,48 @@
 class MyDoubleVar(DoubleVar):
 
     def __init__(self, master = None, precision = 3):
-	self.precision = precision
-	DoubleVar.__init__(self, master)
+        self.precision = precision
+        DoubleVar.__init__(self, master)
 
     def set(self, value):
-	DoubleVar.set(self, round(value, self.precision))
+        DoubleVar.set(self, round(value, self.precision))
 
     def set_precision(self, precision):
-	self.precision = precision
+        self.precision = precision
 
 
 class ColorSample(PyWidget):
 
     def __init__(self, master=None, color = None, **kw):
-	apply(PyWidget.__init__, (self, master), kw)
-	self.gc_initialized = 0
-	if color is None:
-	    color = StandardColors.black
-	self.color = color
+        apply(PyWidget.__init__, (self, master), kw)
+        self.gc_initialized = 0
+        if color is None:
+            color = StandardColors.black
+        self.color = color
 
     def MapMethod(self):
-	if not self.gc_initialized:
-	    self.init_gc()
-	    self.gc_initialized = 1
+        if not self.gc_initialized:
+            self.init_gc()
+            self.gc_initialized = 1
 
     def init_gc(self):
-	self.visual = color.skvisual
-	self.set_color(self.color)
+        self.visual = color.skvisual
+        self.set_color(self.color)
 
     def set_color(self, color):
-	self.color = color
-	self.tkwin.SetBackground(self.visual.get_pixel(self.color))
-	self.UpdateWhenIdle()
+        self.color = color
+        self.tkwin.SetBackground(self.visual.get_pixel(self.color))
+        self.UpdateWhenIdle()
 
     def SetColor(self, color):
-	if self.color != color:
-	    self.set_color(color)
+        if self.color != color:
+            self.set_color(color)
 
     def RedrawMethod(self, region = None):
-	self.tkwin.ClearArea(0, 0, 0, 0, 0)
+        self.tkwin.ClearArea(0, 0, 0, 0, 0)
 
     def ResizedMethod(self, width, height):
-	pass
+        pass
 
 
 class ImageView(PyWidget):
@@ -91,175 +91,175 @@
     # display a PIL Image
 
     def __init__(self, master, image, **kw):
-	width, height = image.size
-	if not kw.has_key('width'):
-	    kw["width"] = width
-	if not kw.has_key('height'):
-	    kw["height"] = height
-	apply(PyWidget.__init__, (self, master), kw)
-	self.gc_initialized = 0
-	self.image = image
-	self.ximage = None
+        width, height = image.size
+        if not kw.has_key('width'):
+            kw["width"] = width
+        if not kw.has_key('height'):
+            kw["height"] = height
+        apply(PyWidget.__init__, (self, master), kw)
+        self.gc_initialized = 0
+        self.image = image
+        self.ximage = None
 
     def MapMethod(self):
-	if not self.gc_initialized:
-	    self.init_gc()
-	    self.gc_initialized = 1
+        if not self.gc_initialized:
+            self.init_gc()
+            self.gc_initialized = 1
 
     def init_gc(self):
-	self.gc = self.tkwin.GetGC()
-	self.visual = color.skvisual
-	w = self.tkwin
-	width, height = self.image.size
-	depth = self.visual.depth
-	if depth > 16:
-	    bpl = 4 * width
-	elif depth > 8:
-	    bpl = ((2 * width + 3) / 4) * 4
-	elif depth == 8:
-	    bpl = ((width + 3) / 4) * 4
-	else:
-	    raise SketchError('unsupported depth for images')
-	self.ximage = w.CreateImage(depth, ZPixmap, 0, None, width, height,
-				    32, bpl)
-	self.set_image(self.image)
+        self.gc = self.tkwin.GetGC()
+        self.visual = color.skvisual
+        w = self.tkwin
+        width, height = self.image.size
+        depth = self.visual.depth
+        if depth > 16:
+            bpl = 4 * width
+        elif depth > 8:
+            bpl = ((2 * width + 3) / 4) * 4
+        elif depth == 8:
+            bpl = ((width + 3) / 4) * 4
+        else:
+            raise SketchError('unsupported depth for images')
+        self.ximage = w.CreateImage(depth, ZPixmap, 0, None, width, height,
+                                    32, bpl)
+        self.set_image(self.image)
 
     def set_image(self, image):
-	self.image = image
-	if self.ximage:
-	    ximage = self.ximage
-	    _sketch.copy_image_to_ximage(self.visual, image.im, ximage,
-					 0, 0, ximage.width, ximage.height)
-	    self.UpdateWhenIdle()
+        self.image = image
+        if self.ximage:
+            ximage = self.ximage
+            _sketch.copy_image_to_ximage(self.visual, image.im, ximage,
+                                         0, 0, ximage.width, ximage.height)
+            self.UpdateWhenIdle()
 
     def RedrawMethod(self, region = None):
-	self.gc.PutImage(self.ximage, 0, 0, 0, 0,
-			 self.ximage.width, self.ximage.height)
+        self.gc.PutImage(self.ximage, 0, 0, 0, 0,
+                         self.ximage.width, self.ximage.height)
 
     def ResizedMethod(self, width, height):
-	pass
+        pass
 
 class ChooseComponent(ImageView, Publisher):
 
     def __init__(self, master, width, height, color = (0, 0, 0), **kw):
-	image = PIL.Image.new('RGB', (width, height))
-	apply(ImageView.__init__, (self, master, image), kw)
-	self.set_color(color)
-	self.drawn = 0
-	self.dragging = 0
-	self.drag_start = (0, 0, 0)
-	self.update_pending = 1
-	self.invgc = None
-	self.bind('<ButtonPress>', self.ButtonPressEvent)
-	self.bind('<Motion>', self.PointerMotionEvent)
-	self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
+        image = PIL.Image.new('RGB', (width, height))
+        apply(ImageView.__init__, (self, master, image), kw)
+        self.set_color(color)
+        self.drawn = 0
+        self.dragging = 0
+        self.drag_start = (0, 0, 0)
+        self.update_pending = 1
+        self.invgc = None
+        self.bind('<ButtonPress>', self.ButtonPressEvent)
+        self.bind('<Motion>', self.PointerMotionEvent)
+        self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
 
     def destroy(self):
-	ImageView.destroy(self)
-	Publisher.Destroy(self)
+        ImageView.destroy(self)
+        Publisher.Destroy(self)
 
     def set_color(self, color):
-	self.color = tuple(color)
+        self.color = tuple(color)
 
     def init_gc(self):
-	ImageView.init_gc(self)
-	self.invgc = self.tkwin.GetGC(foreground = ~0,
-				      function = GXxor)
-	self.tk.call(self._w, 'motionhints')
-	self.show_mark()
+        ImageView.init_gc(self)
+        self.invgc = self.tkwin.GetGC(foreground = ~0,
+                                      function = GXxor)
+        self.tk.call(self._w, 'motionhints')
+        self.show_mark()
 
     def ButtonPressEvent(self, event):
-	if not self.dragging:
-	    self.drag_start = self.color
-	self.dragging = self.dragging + 1
-	self.move_to(self.win_to_color(event.x, event.y), event.state)
+        if not self.dragging:
+            self.drag_start = self.color
+        self.dragging = self.dragging + 1
+        self.move_to(self.win_to_color(event.x, event.y), event.state)
 
     def ButtonReleaseEvent(self, event):
-	self.dragging = self.dragging - 1
-	self.move_to(self.win_to_color(event.x, event.y), event.state)
+        self.dragging = self.dragging - 1
+        self.move_to(self.win_to_color(event.x, event.y), event.state)
 
     def PointerMotionEvent(self, event):
-	if self.dragging:
-	    x, y = self.tkwin.QueryPointer()[4:6]
-	    self.move_to(self.win_to_color(x, y), event.state)
+        if self.dragging:
+            x, y = self.tkwin.QueryPointer()[4:6]
+            self.move_to(self.win_to_color(x, y), event.state)
 
     #def moveto(self, x, y): #to be supplied by derived classes
 
     def hide_mark(self):
-	if self.drawn:
-	    self.draw_mark()
-	    self.drawn = 0
+        if self.drawn:
+            self.draw_mark()
+            self.drawn = 0
 
     def show_mark(self):
-	if not self.drawn and self.invgc:
-	    self.draw_mark()
-	    self.drawn = 1
+        if not self.drawn and self.invgc:
+            self.draw_mark()
+            self.drawn = 1
 
     #def draw_mark(self):	# to be supplied by derived classes
 
     def UpdateWhenIdle(self):
-	if not self.update_pending:
-	    self.update_pending = 1
-	    ImageView.UpdateWhenIdle(self)
+        if not self.update_pending:
+            self.update_pending = 1
+            ImageView.UpdateWhenIdle(self)
 
     def RedrawMethod(self, region = None):
-	if self.update_pending:
-	    self.update_ramp()
-	    self.update_pending = 0
-	ImageView.RedrawMethod(self, region)
-	if self.drawn:
-	    self.draw_mark()
+        if self.update_pending:
+            self.update_ramp()
+            self.update_pending = 0
+        ImageView.RedrawMethod(self, region)
+        if self.drawn:
+            self.draw_mark()
 
     def RGBColor(self):
-	return apply(CreateRGBColor, apply(hsv_to_rgb, self.color))
+        return apply(CreateRGBColor, apply(hsv_to_rgb, self.color))
 
 class ChooseRGBXY(ChooseComponent):
 
     def __init__(self, master, width, height, xcomp = 0, ycomp = 1,
-		 color = (0, 0, 0), **kw):
-	self.xcomp = xcomp
-	self.ycomp = ycomp
-	self.win_to_color = Trafo(1 / float(width - 1), 0,
-				  0, -1 / float(height - 1),
-				  0, 1)
-	self.color_to_win = self.win_to_color.inverse()
-	apply(ChooseComponent.__init__, (self, master, width, height, color),
-	      kw)
+                 color = (0, 0, 0), **kw):
+        self.xcomp = xcomp
+        self.ycomp = ycomp
+        self.win_to_color = Trafo(1 / float(width - 1), 0,
+                                  0, -1 / float(height - 1),
+                                  0, 1)
+        self.color_to_win = self.win_to_color.inverse()
+        apply(ChooseComponent.__init__, (self, master, width, height, color),
+              kw)
 
     def SetColor(self, color):
-	color = apply(rgb_to_hsv, tuple(color))
-	otheridx = 3 - self.xcomp - self.ycomp
-	if color[otheridx] != self.color[otheridx]:
-	    self.UpdateWhenIdle()
-	self.hide_mark()
-	self.color = color
-	self.show_mark()
+        color = apply(rgb_to_hsv, tuple(color))
+        otheridx = 3 - self.xcomp - self.ycomp
+        if color[otheridx] != self.color[otheridx]:
+            self.UpdateWhenIdle()
+        self.hide_mark()
+        self.color = color
+        self.show_mark()
 
     def update_ramp(self):
-	_sketch.fill_hsv_xy(self.image.im, self.xcomp, self.ycomp, self.color)
-	self.set_image(self.image)
+        _sketch.fill_hsv_xy(self.image.im, self.xcomp, self.ycomp, self.color)
+        self.set_image(self.image)
 
     def move_to(self, p, state):
-	x, y = p
-	if state & ConstraintMask:
-	    sx = self.drag_start[self.xcomp]
-	    sy = self.drag_start[self.ycomp]
-	    if abs(sx - x) < abs(sy - y):
-		x = sx
-	    else:
-		y = sy
-	if x < 0:	x = 0
-	elif x >= 1.0:	x = 1.0
-	if y < 0:	y = 0
-	elif y >= 1.0:	y = 1.0
+        x, y = p
+        if state & ConstraintMask:
+            sx = self.drag_start[self.xcomp]
+            sy = self.drag_start[self.ycomp]
+            if abs(sx - x) < abs(sy - y):
+                x = sx
+            else:
+                y = sy
+        if x < 0:	x = 0
+        elif x >= 1.0:	x = 1.0
+        if y < 0:	y = 0
+        elif y >= 1.0:	y = 1.0
 
-	color = list(self.color)
-	color[self.xcomp] = x
-	color[self.ycomp] = y
-	self.hide_mark()
-	self.color = tuple(color)
-	self.show_mark()
-	self.issue(CHANGED, self.RGBColor())
+        color = list(self.color)
+        color[self.xcomp] = x
+        color[self.ycomp] = y
+        self.hide_mark()
+        self.color = tuple(color)
+        self.show_mark()
+        self.issue(CHANGED, self.RGBColor())
 
     def draw_mark(self):
         color = self.color
@@ -274,39 +274,39 @@
 class ChooseRGBZ(ChooseComponent):
 
     def __init__(self, master, width, height, comp = 1, color = (0, 0, 0),
-		 **kw):
-	self.comp = comp
-	self.win_to_color = Trafo(1, 0, 0, -1 / float(height - 1), 0, 1)
-	self.color_to_win = self.win_to_color.inverse()
-	apply(ChooseComponent.__init__, (self, master, width, height, color),
-	      kw)
+                 **kw):
+        self.comp = comp
+        self.win_to_color = Trafo(1, 0, 0, -1 / float(height - 1), 0, 1)
+        self.color_to_win = self.win_to_color.inverse()
+        apply(ChooseComponent.__init__, (self, master, width, height, color),
+              kw)
 
     def SetColor(self, color):
-	c = self.color;
-	color = apply(rgb_to_hsv, tuple(color))
-	if ((self.comp == 0 and (color[1] != c[1] or color[2] != c[2]))
-	    or (self.comp == 1 and (color[0] != c[0] or color[2] != c[2]))
-	    or (self.comp == 2 and (color[0] != c[0] or color[1] != c[1]))):
-	    self.hide_mark()
-	    self.color = color
-	    self.show_mark()
-	    self.UpdateWhenIdle()
+        c = self.color;
+        color = apply(rgb_to_hsv, tuple(color))
+        if ((self.comp == 0 and (color[1] != c[1] or color[2] != c[2]))
+            or (self.comp == 1 and (color[0] != c[0] or color[2] != c[2]))
+            or (self.comp == 2 and (color[0] != c[0] or color[1] != c[1]))):
+            self.hide_mark()
+            self.color = color
+            self.show_mark()
+            self.UpdateWhenIdle()
 
     def update_ramp(self):
-	_sketch.fill_hsv_z(self.image.im, self.comp, self.color)
-	self.set_image(self.image)
+        _sketch.fill_hsv_z(self.image.im, self.comp, self.color)
+        self.set_image(self.image)
 
     def move_to(self, p, state):
-	y = p.y
-	if y < 0:	y = 0
-	elif y >= 1.0:	y = 1.0
+        y = p.y
+        if y < 0:	y = 0
+        elif y >= 1.0:	y = 1.0
 
-	color = list(self.color)
-	color[self.comp] = y
-	self.hide_mark()
-	self.color = tuple(color)
-	self.show_mark()
-	self.issue(CHANGED, self.RGBColor())
+        color = list(self.color)
+        color[self.comp] = y
+        self.hide_mark()
+        self.color = tuple(color)
+        self.show_mark()
+        self.issue(CHANGED, self.RGBColor())
 
     def draw_mark(self):
         w, h = self.image.size
@@ -325,113 +325,113 @@
     class_name = 'ColorDialog'
 
     def __init__(self, master, color, **kw):
-	self.color = color
-	self.orig_color = color
-	apply(SKModal.__init__, (self, master), kw)
+        self.color = color
+        self.orig_color = color
+        apply(SKModal.__init__, (self, master), kw)
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	frame = Frame(top)
-	frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
-	button = Button(frame, text = _("OK"), command = self.ok)
-	button.pack(side = LEFT, expand = 1)
-	button = Button(frame, text = _("Cancel"), command = self.cancel)
-	button.pack(side = RIGHT, expand = 1)
+        frame = Frame(top)
+        frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
+        button = Button(frame, text = _("OK"), command = self.ok)
+        button.pack(side = LEFT, expand = 1)
+        button = Button(frame, text = _("Cancel"), command = self.cancel)
+        button.pack(side = RIGHT, expand = 1)
 
-	self.label = Label(top)
-	self.label.pack(side = BOTTOM)
+        self.label = Label(top)
+        self.label.pack(side = BOTTOM)
 
-	viewxy = ChooseRGBXY(top, xyramp_size[0], xyramp_size[1], 0, 1)
-	viewxy.pack(side = LEFT)
+        viewxy = ChooseRGBXY(top, xyramp_size[0], xyramp_size[1], 0, 1)
+        viewxy.pack(side = LEFT)
 
-	viewz = ChooseRGBZ(top, zramp_size[0], zramp_size[1], 2)
-	viewz.pack(side = LEFT)
+        viewz = ChooseRGBZ(top, zramp_size[0], zramp_size[1], 2)
+        viewz.pack(side = LEFT)
 
-	frame1 = Frame(top)
-	frame1.pack(side = RIGHT)
+        frame1 = Frame(top)
+        frame1.pack(side = RIGHT)
 
-	frame = Frame(frame1)
-	frame.pack(side = TOP)
+        frame = Frame(frame1)
+        frame.pack(side = TOP)
 
-	sample = ColorSample(frame, self.color, width = 30, height = 30)
-	sample.pack(side = RIGHT)
-	sample = ColorSample(frame, self.color, width = 30, height = 30)
-	sample.pack(side = RIGHT)
+        sample = ColorSample(frame, self.color, width = 30, height = 30)
+        sample.pack(side = RIGHT)
+        sample = ColorSample(frame, self.color, width = 30, height = 30)
+        sample.pack(side = RIGHT)
 
-	frame = Frame(frame1)
-	frame.pack(side = TOP)
-	label = Label(frame, text = "H")
-	label.pack(side = LEFT)
-	self.var1 = create_mini_entry(top, frame, self.component_changed,
-				      min = 0, max = 1.0, step = 0.01,
-				      vartype = MyDoubleVar)
-	frame = Frame(frame1)
-	frame.pack(side = TOP)
-	label = Label(frame, text = "S")
-	label.pack(side = LEFT)
-	self.var2 = create_mini_entry(top, frame, self.component_changed,
-				      min = 0, max = 1.0, step = 0.01,
-				      vartype = MyDoubleVar)
-	frame = Frame(frame1)
-	frame.pack(side = TOP)
-	label = Label(frame, text = "V")
-	label.pack(side = LEFT)
-	self.var3 = create_mini_entry(top, frame, self.component_changed,
-				      min = 0, max = 1.0, step = 0.01,
-				      vartype = MyDoubleVar)
+        frame = Frame(frame1)
+        frame.pack(side = TOP)
+        label = Label(frame, text = "H")
+        label.pack(side = LEFT)
+        self.var1 = create_mini_entry(top, frame, self.component_changed,
+                                      min = 0, max = 1.0, step = 0.01,
+                                      vartype = MyDoubleVar)
+        frame = Frame(frame1)
+        frame.pack(side = TOP)
+        label = Label(frame, text = "S")
+        label.pack(side = LEFT)
+        self.var2 = create_mini_entry(top, frame, self.component_changed,
+                                      min = 0, max = 1.0, step = 0.01,
+                                      vartype = MyDoubleVar)
+        frame = Frame(frame1)
+        frame.pack(side = TOP)
+        label = Label(frame, text = "V")
+        label.pack(side = LEFT)
+        self.var3 = create_mini_entry(top, frame, self.component_changed,
+                                      min = 0, max = 1.0, step = 0.01,
+                                      vartype = MyDoubleVar)
 
-	frame = Frame(frame1)
-	frame.pack(side = TOP)
-	label = Label(frame, text = "R")
-	label.pack(side = LEFT)
-	self.var4 = create_mini_entry(top, frame, self.rgb_component_changed,
-				      min = 0, max = 255, step = 1,
-				      vartype = IntVar)
+        frame = Frame(frame1)
+        frame.pack(side = TOP)
+        label = Label(frame, text = "R")
+        label.pack(side = LEFT)
+        self.var4 = create_mini_entry(top, frame, self.rgb_component_changed,
+                                      min = 0, max = 255, step = 1,
+                                      vartype = IntVar)
 
-	frame = Frame(frame1)
-	frame.pack(side = TOP)
-	label = Label(frame, text = "G")
-	label.pack(side = LEFT)
-	self.var5 = create_mini_entry(top, frame, self.rgb_component_changed,
-				      min = 0, max = 255, step = 1,
-				      vartype = IntVar)
+        frame = Frame(frame1)
+        frame.pack(side = TOP)
+        label = Label(frame, text = "G")
+        label.pack(side = LEFT)
+        self.var5 = create_mini_entry(top, frame, self.rgb_component_changed,
+                                      min = 0, max = 255, step = 1,
+                                      vartype = IntVar)
 
-	frame = Frame(frame1)
-	frame.pack(side = TOP)
-	label = Label(frame, text = "B")
-	label.pack(side = LEFT)
-	self.var6 = create_mini_entry(top, frame, self.rgb_component_changed,
-				      min = 0, max = 255, step = 1,
-				      vartype = IntVar)
+        frame = Frame(frame1)
+        frame.pack(side = TOP)
+        label = Label(frame, text = "B")
+        label.pack(side = LEFT)
+        self.var6 = create_mini_entry(top, frame, self.rgb_component_changed,
+                                      min = 0, max = 255, step = 1,
+                                      vartype = IntVar)
 
-	viewxy.Subscribe(CHANGED, self.color_changed)
-	viewz.Subscribe(CHANGED, self.color_changed)
-	self.viewxy = viewxy
-	self.viewz = viewz
-	self.sample = sample
+        viewxy.Subscribe(CHANGED, self.color_changed)
+        viewz.Subscribe(CHANGED, self.color_changed)
+        self.viewxy = viewxy
+        self.viewz = viewz
+        self.sample = sample
 
-	self.color_changed(self.color)
+        self.color_changed(self.color)
 
     def color_changed(self, color):
-	self.label.configure(text = '%.3f %.3f %.3f' % tuple(color))
-	self.viewxy.SetColor(color)
-	self.viewz.SetColor(color)
-	self.sample.SetColor(color)
-	v1, v2, v3 = apply(rgb_to_hsv, tuple(color))
-	self.var1.set(v1)
-	self.var2.set(v2)
-	self.var3.set(v3)
-	self.var4.set(int(color[0]*255))
-	self.var5.set(int(color[1]*255))
-	self.var6.set(int(color[2]*255))
-	self.color = color
+        self.label.configure(text = '%.3f %.3f %.3f' % tuple(color))
+        self.viewxy.SetColor(color)
+        self.viewz.SetColor(color)
+        self.sample.SetColor(color)
+        v1, v2, v3 = apply(rgb_to_hsv, tuple(color))
+        self.var1.set(v1)
+        self.var2.set(v2)
+        self.var3.set(v3)
+        self.var4.set(int(color[0]*255))
+        self.var5.set(int(color[1]*255))
+        self.var6.set(int(color[2]*255))
+        self.color = color
 
 
     def component_changed(self, *rest):
-	color = (self.var1.get(), self.var2.get(), self.var3.get())
-	color = apply(CreateRGBColor, apply(hsv_to_rgb, color))
-	self.color_changed(color)
+        color = (self.var1.get(), self.var2.get(), self.var3.get())
+        color = apply(CreateRGBColor, apply(hsv_to_rgb, color))
+        self.color_changed(color)
 
     def rgb_component_changed(self, *rest):
         self.color_changed(CreateRGBColor(self.var4.get() / 255.0,
@@ -441,7 +441,7 @@
 
 
     def ok(self, *args):
-	self.close_dlg(self.color)
+        self.close_dlg(self.color)
 
 def GetColor(master, color):
     dlg = ChooseColorDlg(master, color)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/command.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/command.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/command.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -30,108 +30,108 @@
 class Command(Publisher):
 
     def __init__(self, cmd_class, object):
-	self.cmd_class = cmd_class
-	self.object = object
+        self.cmd_class = cmd_class
+        self.object = object
 
     def __getattr__(self, attr):
-	try:
-	    return getattr(self.cmd_class, attr)
-	except AttributeError:
-	    if attr == 'button_name':
-		return self.menu_name
-	raise AttributeError, attr
+        try:
+            return getattr(self.cmd_class, attr)
+        except AttributeError:
+            if attr == 'button_name':
+                return self.menu_name
+        raise AttributeError, attr
 
     def get_method(self, path):
-	if callable(path):
-	    return path
-	method = self.object
-	if type(path) != TupleType:
-	    path = (path,)
-	for name in path:
-	    method = getattr(method, name)
-	return method
+        if callable(path):
+            return path
+        method = self.object
+        if type(path) != TupleType:
+            path = (path,)
+        for name in path:
+            method = getattr(method, name)
+        return method
 
     def Invoke(self, args = ()):
-	if type(args) != TupleType:
-	    args = (args,)
-	try:
-	    apply(self.get_method(self.command), self.args + args)
-	except:
-	    warn_tb(INTERNAL)
+        if type(args) != TupleType:
+            args = (args,)
+        try:
+            apply(self.get_method(self.command), self.args + args)
+        except:
+            warn_tb(INTERNAL)
 
     def Update(self):
-	# XXX: bitmaps and key_strokes should probably be also changeable
-	changed = self.set_name(self.get_name())
-	changed = self.set_sensitive(self.get_sensitive()) or changed
-	changed = self.set_value(self.get_value()) or changed
-	if changed:
-	    self.issue(CHANGED)
+        # XXX: bitmaps and key_strokes should probably be also changeable
+        changed = self.set_name(self.get_name())
+        changed = self.set_sensitive(self.get_sensitive()) or changed
+        changed = self.set_value(self.get_value()) or changed
+        if changed:
+            self.issue(CHANGED)
 
     def get_name(self):
-	if self.name_cb:
-	    method = self.get_method(self.name_cb)
-	    if method:
-		return method()
-	return self.menu_name
+        if self.name_cb:
+            method = self.get_method(self.name_cb)
+            if method:
+                return method()
+        return self.menu_name
 
     def set_name(self, menu_name = None):
-	changed = self.menu_name != menu_name
-	if changed:
-	    self.menu_name = menu_name
-	return changed
+        changed = self.menu_name != menu_name
+        if changed:
+            self.menu_name = menu_name
+        return changed
 
     def get_sensitive(self):
-	#print 'get_sensitive', self
-	if self.sensitive_cb:
-	    method = self.get_method(self.sensitive_cb)
-	    if method:
-		return method()
-	    else:
-		warn(INTERNAL, 'no method for sensitive_cb (%s)',
-		     self.sensitive_cb)
-		return 0
-	return 1
+        #print 'get_sensitive', self
+        if self.sensitive_cb:
+            method = self.get_method(self.sensitive_cb)
+            if method:
+                return method()
+            else:
+                warn(INTERNAL, 'no method for sensitive_cb (%s)',
+                     self.sensitive_cb)
+                return 0
+        return 1
 
     def set_sensitive(self, sensitive):
-	changed = self.sensitive != sensitive
-	if changed:
-	    self.sensitive = sensitive
-	return changed
+        changed = self.sensitive != sensitive
+        if changed:
+            self.sensitive = sensitive
+        return changed
 
     def get_value(self):
-	if self.value_cb:
-	    method = self.get_method(self.value_cb)
-	    if method:
-		return method()
-	return self.value
+        if self.value_cb:
+            method = self.get_method(self.value_cb)
+            if method:
+                return method()
+        return self.value
 
     def set_value(self, value):
-	changed = self.value != value
-	if changed:
-	    self.value = value
-	return changed
+        changed = self.value != value
+        if changed:
+            self.value = value
+        return changed
 
     def GetKeystroke(self):
-	return self.key_stroke
+        return self.key_stroke
 
     def GetValue(self):
-	return self.value
+        return self.value
 
     def IsOn(self):
         return self.value == self.value_on
 
     def InContext(self):
-	return 1
+        return 1
 
     def set_bitmap(self, bitmap):
-	if bitmap:
-	    changed = self.bitmap != bitmap
-	    self.bitmap = bitmap
-	    return changed
-	return 0
+        if bitmap:
+            changed = self.bitmap != bitmap
+            self.bitmap = bitmap
+            return changed
+        return 0
 
     def __repr__(self):
-	return 'Command: %s' % self.name
+        return 'Command: %s' % self.name
 
 
 
@@ -160,73 +160,73 @@
     callable_attributes = ('name_cb', 'sensitive_cb', 'value_cb')
 
     def __init__(self, name, command, subscribe_to = None, args = (),
-		 is_check = 0, **rest):
-	self.name = name
-	self.command = command
-	self.subscribe_to = subscribe_to
-	if type(args) != TupleType:
-	    self.args = (args,)
-	else:
-	    self.args = args
-	for key, value in rest.items():
-	    setattr(self, key, value)
+                 is_check = 0, **rest):
+        self.name = name
+        self.command = command
+        self.subscribe_to = subscribe_to
+        if type(args) != TupleType:
+            self.args = (args,)
+        else:
+            self.args = args
+        for key, value in rest.items():
+            setattr(self, key, value)
 
-	if is_check:
-	    self.is_check = 1
-	    self.is_command = 0
+        if is_check:
+            self.is_check = 1
+            self.is_command = 0
 
 
     def InstantiateFor(self, object):
-	cmd = self.cmd_class(self, object)
-	if self.subscribe_to:
-	    if type(self.subscribe_to) == TupleType:
-		attrs = self.subscribe_to[:-1]
-		for attr in attrs:
-		    object = getattr(object, attr)
-		subscribe_to = self.subscribe_to[-1]
-	    else:
-		subscribe_to = self.subscribe_to
-	    object.Subscribe(subscribe_to, cmd.Update)
-	return cmd
+        cmd = self.cmd_class(self, object)
+        if self.subscribe_to:
+            if type(self.subscribe_to) == TupleType:
+                attrs = self.subscribe_to[:-1]
+                for attr in attrs:
+                    object = getattr(object, attr)
+                subscribe_to = self.subscribe_to[-1]
+            else:
+                subscribe_to = self.subscribe_to
+            object.Subscribe(subscribe_to, cmd.Update)
+        return cmd
 
     def __repr__(self):
-	return 'CommandClass: %s' % self.name
+        return 'CommandClass: %s' % self.name
 
 
 
 class ObjectCommand(Command):
 
     def get_method(self, path):
-	if type(path) == type(""):
-	    return self.object.document.GetObjectMethod(self.object_class,path)
-	return Command.get_method(self, path)
+        if type(path) == type(""):
+            return self.object.document.GetObjectMethod(self.object_class,path)
+        return Command.get_method(self, path)
 
     def Invoke(self, args = ()):
-	if type(args) != TupleType:
-	    args = (args,)
-	try:
-	    apply(self.object.document.CallObjectMethod,
-		  (self.object_class, self.menu_name, self.command) \
-		  + self.args + args)
-	except:
-	    warn_tb(INTERNAL)
+        if type(args) != TupleType:
+            args = (args,)
+        try:
+            apply(self.object.document.CallObjectMethod,
+                  (self.object_class, self.menu_name, self.command) \
+                  + self.args + args)
+        except:
+            warn_tb(INTERNAL)
 
     def get_sensitive(self):
-	if self.object.document.CurrentObjectCompatible(self.object_class):
-	    return Command.get_sensitive(self)
-	return 0
+        if self.object.document.CurrentObjectCompatible(self.object_class):
+            return Command.get_sensitive(self)
+        return 0
 
     def GetKeystroke(self):
-	return self.key_stroke
+        return self.key_stroke
 
     def GetValue(self):
-	return self.value
+        return self.value
 
     def InContext(self):
-	return self.object.document.CurrentObjectCompatible(self.object_class)
+        return self.object.document.CurrentObjectCompatible(self.object_class)
 
     def __repr__(self):
-	return 'ObjectCommand: %s' % self.name
+        return 'ObjectCommand: %s' % self.name
 
 
 class ObjectCommandClass(CommandClass):
@@ -235,8 +235,8 @@
     object_class = None
 
     def SetClass(self, aclass):
-	if self.object_class is None:
-	    self.object_class = aclass
+        if self.object_class is None:
+            self.object_class = aclass
 
 
 #
@@ -246,23 +246,23 @@
 class Commands:
 
     def Update(self):
-	for item in self.__dict__.values():
-	    item.Update()
+        for item in self.__dict__.values():
+            item.Update()
 
     def __getitem__(self, key):
-	return getattr(self, key)
+        return getattr(self, key)
 
     def Get(self, name):
-	try:
-	    return getattr(self, name)
-	except AttributeError:
-	    for item in self.__dict__.values():
-		if item.__class__ == Commands:
-		    cmd = item.Get(name)
-		    if cmd:
-			return cmd
-	    else:
-		return None
+        try:
+            return getattr(self, name)
+        except AttributeError:
+            for item in self.__dict__.values():
+                if item.__class__ == Commands:
+                    cmd = item.Get(name)
+                    if cmd:
+                        return cmd
+            else:
+                return None
 #
 #
 #
@@ -270,24 +270,24 @@
 class Keymap:
 
     def __init__(self):
-	self.map = {}
+        self.map = {}
 
     def AddCommand(self, command):
-	key_stroke = command.GetKeystroke()
-	if key_stroke:
-	    if type(key_stroke) == StringType:
-		key_stroke = (key_stroke,)
-	    for stroke in key_stroke:
-		if self.map.has_key(stroke):
-		    # XXX: should be user visible if keybindings can be
-		    # changed by user
-		    warn(INTERNAL, 'Warning: Binding %s to %s replaces %s',
-			 command.name, stroke, self.map[stroke].name)
-		self.map[stroke] = command
+        key_stroke = command.GetKeystroke()
+        if key_stroke:
+            if type(key_stroke) == StringType:
+                key_stroke = (key_stroke,)
+            for stroke in key_stroke:
+                if self.map.has_key(stroke):
+                    # XXX: should be user visible if keybindings can be
+                    # changed by user
+                    warn(INTERNAL, 'Warning: Binding %s to %s replaces %s',
+                         command.name, stroke, self.map[stroke].name)
+                self.map[stroke] = command
 
     def MapKeystroke(self, stroke):
-	if self.map.has_key(stroke):
-	    return self.map[stroke]
+        if self.map.has_key(stroke):
+            return self.map[stroke]
 
 
 #
@@ -296,11 +296,11 @@
 
 def AddCmd(list, name, menu_name, method = None, **kw):
     if type(name) == FunctionType:
-	name = name.func_name
+        name = name.func_name
     if method is None:
-	method = name
+        method = name
     elif type(method) == FunctionType:
-	method = method.func_name
+        method = method.func_name
     kw['menu_name'] = menu_name
     kw['subscribe_to'] = SELECTION
     cmd = apply(ObjectCommandClass, (name, method), kw)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/cursorstack.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/cursorstack.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/cursorstack.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -32,44 +32,44 @@
 class CursorStack:
 
     def __init__(self, shape = None, function = None):
-	self.cursor_stack = None
-	self.cursor_function = self.set_handle_cursor
-	self.cursor_shape = shape
-	self.last_cursor = function
+        self.cursor_stack = None
+        self.cursor_function = self.set_handle_cursor
+        self.cursor_shape = shape
+        self.last_cursor = function
 
     def push_static_cursor(self, cursor):
-	self.push_cursor_state()
-	self.set_static_cursor(cursor)
+        self.push_cursor_state()
+        self.set_static_cursor(cursor)
 
     def set_static_cursor(self, cursor):
-	self.cursor_function = None
-	self.cursor_shape = cursor
-	self.set_window_cursor(cursor)
+        self.cursor_function = None
+        self.cursor_shape = cursor
+        self.set_window_cursor(cursor)
 
     def push_active_cursor(self, function, standard_shape):
-	self.push_cursor_state()
-	self.set_active_cursor(function, standard_shape)
+        self.push_cursor_state()
+        self.set_active_cursor(function, standard_shape)
 
     def set_active_cursor(self, function, standard_shape):
-	self.cursor_function = function
-	self.cursor_shape = standard_shape
-	if self.winfo_ismapped():
-	    x, y = self.tkwin.QueryPointer()[4:6]
-	    self.cursor_function(x, y)
+        self.cursor_function = function
+        self.cursor_shape = standard_shape
+        if self.winfo_ismapped():
+            x, y = self.tkwin.QueryPointer()[4:6]
+            self.cursor_function(x, y)
 
     def push_cursor_state(self):
-	self.cursor_stack = (self.cursor_shape, self.cursor_function,
-			     self.cursor_stack)
+        self.cursor_stack = (self.cursor_shape, self.cursor_function,
+                             self.cursor_stack)
 
     def pop_cursor_state(self):
-	self.cursor_shape, self.cursor_function, self.cursor_stack \
-			   = self.cursor_stack
-	if self.cursor_function:
-	    x, y = self.tkwin.QueryPointer()[4:6]
-	    self.cursor_function(x, y)
-	else:
-	    self.set_window_cursor(self.cursor_shape)
+        self.cursor_shape, self.cursor_function, self.cursor_stack \
+            = self.cursor_stack
+        if self.cursor_function:
+            x, y = self.tkwin.QueryPointer()[4:6]
+            self.cursor_function(x, y)
+        else:
+            self.set_window_cursor(self.cursor_shape)
 
     def set_window_cursor(self, cursor):
-	if cursor != self.last_cursor:
-	    self['cursor'] = self.last_cursor = cursor
+        if cursor != self.last_cursor:
+            self['cursor'] = self.last_cursor = cursor

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/curvedlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/curvedlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/curvedlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -31,31 +31,31 @@
     title = _("Curve")
 
     def __init__(self, master, main_window, doc):
-	CommandPanel.__init__(self, master, main_window, doc,
-			      name = 'curvedlg')
+        CommandPanel.__init__(self, master, main_window, doc,
+                              name = 'curvedlg')
 
     def build_dlg(self):
-	names = (('ContAngle', 'CloseNodes', 'OpenNodes'),
-		 ('ContSmooth', 'InsertNodes', 'DeleteNodes'),
-		 ('ContSymmetrical', 'SegmentsToLines', 'SegmentsToCurve'))
+        names = (('ContAngle', 'CloseNodes', 'OpenNodes'),
+                 ('ContSmooth', 'InsertNodes', 'DeleteNodes'),
+                 ('ContSymmetrical', 'SegmentsToLines', 'SegmentsToCurve'))
 
-	top = self.top
-	frame = Frame(top)
-	frame.pack(side = TOP, expand = 1, fill = BOTH)
+        top = self.top
+        frame = Frame(top)
+        frame.pack(side = TOP, expand = 1, fill = BOTH)
 
-	# XXX This dialog should have its own ObjectCommand objects
-	cmds = self.main_window.canvas.commands.PolyBezierEditor
-	for i in range(len(names)):
-	    for j in range(len(names[i])):
-		button = CommandButton(frame, getattr(cmds, names[i][j]),
-				       highlightthickness = 0)
-		button.grid(column = j, row = i)
+        # XXX This dialog should have its own ObjectCommand objects
+        cmds = self.main_window.canvas.commands.PolyBezierEditor
+        for i in range(len(names)):
+            for j in range(len(names[i])):
+                button = CommandButton(frame, getattr(cmds, names[i][j]),
+                                       highlightthickness = 0)
+                button.grid(column = j, row = i)
 
-	frame = Frame(top)
-	frame.pack(side = BOTTOM, expand = 0, fill = X)
+        frame = Frame(top)
+        frame.pack(side = BOTTOM, expand = 0, fill = X)
 
-	button = UpdatedButton(frame, text = _("Close"),
-			       command = self.close_dlg)
-	button.pack(anchor = CENTER)
+        button = UpdatedButton(frame, text = _("Close"),
+                               command = self.close_dlg)
+        button.pack(anchor = CENTER)
 
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/export.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/export.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/export.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -25,8 +25,8 @@
 from view import SketchView
 
 bitmap_types = [('Portable Pixmap (PPM)', 'ppmraw'),
-		('Portable Graymap (PGM)', 'pgmraw'),
-		('Portable Bitmap (PBM)', 'pbmraw')]
+                ('Portable Graymap (PGM)', 'pgmraw'),
+                ('Portable Bitmap (PBM)', 'pbmraw')]
 
 
 
@@ -35,53 +35,53 @@
     title = 'Export'
 
     def __init__(self, master, main_window, doc):
-	SketchPanel.__init__(self, master, main_window, doc, name = 'export')
+        SketchPanel.__init__(self, master, main_window, doc, name = 'export')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	self.view = SketchView(top, self.document, width = 200, height = 200,
-			       background = 'white')
-	self.view.pack(side = LEFT, fill = BOTH, expand = 1)
+        self.view = SketchView(top, self.document, width = 200, height = 200,
+                               background = 'white')
+        self.view.pack(side = LEFT, fill = BOTH, expand = 1)
 
-	self.opt_format = MyOptionMenu2(top, bitmap_types)
-	self.opt_format.pack(side = TOP)
+        self.opt_format = MyOptionMenu2(top, bitmap_types)
+        self.opt_format.pack(side = TOP)
 
-	frame = Frame(top)
-	frame.pack(side = TOP, expand = 1, fill = X)
-	label = Label(frame, text = 'Resolution')
-	label.pack(side = LEFT)
-	entry = MyEntry(frame, width = 4)
-	entry.pack(side = LEFT)
-	label = Label(frame, text = 'dpi')
-	label.pack(side = LEFT)
+        frame = Frame(top)
+        frame.pack(side = TOP, expand = 1, fill = X)
+        label = Label(frame, text = 'Resolution')
+        label.pack(side = LEFT)
+        entry = MyEntry(frame, width = 4)
+        entry.pack(side = LEFT)
+        label = Label(frame, text = 'dpi')
+        label.pack(side = LEFT)
 
-	frame = Frame(top)
-	frame.pack(side = TOP, expand = 1, fill = X)
-	label = Label(frame, text = 'Size')
-	label.pack(side = LEFT)
-	entry = MyEntry(frame, width = 4)
-	entry.pack(side = LEFT)
-	label = Label(frame, text = 'x')
-	label.pack(side = LEFT)
-	entry = MyEntry(frame, width = 4)
-	entry.pack(side = LEFT)
-	label = Label(frame, text = 'pixel')
-	label.pack(side = LEFT)
+        frame = Frame(top)
+        frame.pack(side = TOP, expand = 1, fill = X)
+        label = Label(frame, text = 'Size')
+        label.pack(side = LEFT)
+        entry = MyEntry(frame, width = 4)
+        entry.pack(side = LEFT)
+        label = Label(frame, text = 'x')
+        label.pack(side = LEFT)
+        entry = MyEntry(frame, width = 4)
+        entry.pack(side = LEFT)
+        label = Label(frame, text = 'pixel')
+        label.pack(side = LEFT)
 
-	check = UpdatedCheckbutton(top, text = 'antialiasing')
-	check.pack(side = TOP)
+        check = UpdatedCheckbutton(top, text = 'antialiasing')
+        check.pack(side = TOP)
 
-	frame = Frame(top)
-	frame.pack(side =TOP)
-	button = UpdatedButton(frame, text = 'Export')
-	button.pack(side = LEFT)
-	button = UpdatedButton(frame, text = 'Close', command = self.close_dlg)
-	button.pack(side = LEFT)
+        frame = Frame(top)
+        frame.pack(side =TOP)
+        button = UpdatedButton(frame, text = 'Export')
+        button.pack(side = LEFT)
+        button = UpdatedButton(frame, text = 'Close', command = self.close_dlg)
+        button.pack(side = LEFT)
 
 
     def init_from_doc(self):
-	self.view.SetDocument(self.document)
+        self.view.SetDocument(self.document)
 
 
 
@@ -97,19 +97,19 @@
     res = 72
     outfile = '/tmp/export.ppm'
     gs_cmd = 'gs -dNOPAUSE -g%(width)dx%(height)d -r%(res)d -sDEVICE=ppmraw '\
-	     '-sOutputFile=%(outfile)s -q -' % locals()
+           '-sOutputFile=%(outfile)s -q -' % locals()
     #gs_cmd = 'cat > ' + outfile
 
     if __debug__:
-	print gs_cmd
+        print gs_cmd
     file = os.popen(gs_cmd, 'w')
     try:
-	device = PostScriptDevice(file, as_eps = 0)
-	document.Draw(device)
-	device.Close()
-	file.write('quit\n')
+        device = PostScriptDevice(file, as_eps = 0)
+        document.Draw(device)
+        device.Close()
+        file.write('quit\n')
     finally:
-	file.close()
+        file.close()
 
 
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/filldlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/filldlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/filldlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -59,57 +59,57 @@
 class PatternSample(PyWidget):
 
     def __init__(self, master=None, **kw):
-	apply(PyWidget.__init__, (self, master), kw)
-	self.gc_initialized = 0
-	self.gc = GraphicsDevice()
-	self.pattern = EmptyPattern
-	self.properties = PropertyStack()
-	self.properties.AddStyle(EmptyLineStyle)
-	self.properties.SetProperty(fill_pattern = self.pattern)
-	self.gc.SetProperties(self.properties)
-	self.fill_rect = None
+        apply(PyWidget.__init__, (self, master), kw)
+        self.gc_initialized = 0
+        self.gc = GraphicsDevice()
+        self.pattern = EmptyPattern
+        self.properties = PropertyStack()
+        self.properties.AddStyle(EmptyLineStyle)
+        self.properties.SetProperty(fill_pattern = self.pattern)
+        self.gc.SetProperties(self.properties)
+        self.fill_rect = None
 
     def MapMethod(self):
-	self.fill_rect = Rect(0, 0, self.tkwin.width, self.tkwin.height)
-	if not self.gc_initialized:
-	    self.init_gc()
-	    self.gc_initialized = 1
+        self.fill_rect = Rect(0, 0, self.tkwin.width, self.tkwin.height)
+        if not self.gc_initialized:
+            self.init_gc()
+            self.gc_initialized = 1
 
     def init_gc(self):
-	self.gc.init_gc(self.tkwin)
-	self.compute_trafo()
+        self.gc.init_gc(self.tkwin)
+        self.compute_trafo()
 
     def compute_trafo(self):
-	height = self.tkwin.height
-	doc_to_win = Trafo(1, 0, 0, -1, 0, height)
-	win_to_doc = doc_to_win.inverse()
-	self.gc.SetViewportTransform(1.0, doc_to_win, win_to_doc)
-	self.fill_rect = Rect(0, 0, self.tkwin.width, self.tkwin.height)
-	self.gc.SetProperties(self.properties, self.fill_rect)
+        height = self.tkwin.height
+        doc_to_win = Trafo(1, 0, 0, -1, 0, height)
+        win_to_doc = doc_to_win.inverse()
+        self.gc.SetViewportTransform(1.0, doc_to_win, win_to_doc)
+        self.fill_rect = Rect(0, 0, self.tkwin.width, self.tkwin.height)
+        self.gc.SetProperties(self.properties, self.fill_rect)
 
     def SetPattern(self, pattern):
-	if pattern != self.pattern:
-	    self.pattern = pattern
-	    self.UpdateWhenIdle()
-	    self.properties.SetProperty(fill_pattern = pattern)
-	    self.gc.SetProperties(self.properties, self.fill_rect)
+        if pattern != self.pattern:
+            self.pattern = pattern
+            self.UpdateWhenIdle()
+            self.properties.SetProperty(fill_pattern = pattern)
+            self.gc.SetProperties(self.properties, self.fill_rect)
 
     def RedrawMethod(self, region = None):
-	win = self.tkwin
-	self.gc.StartDblBuffer()
-	self.gc.SetFillColor(StandardColors.white)
-	self.gc.FillRectangle(0, 0, win.width, win.height)
-	if self.properties.HasFill():
-	    self.gc.Rectangle(Trafo(win.width, 0, 0, win.height, 0, 0))
-	else:
-	    self.gc.SetLineColor(StandardColors.black)
-	    self.gc.DrawLineXY(0, win.height, win.width, 0)
-	self.gc.EndDblBuffer()
+        win = self.tkwin
+        self.gc.StartDblBuffer()
+        self.gc.SetFillColor(StandardColors.white)
+        self.gc.FillRectangle(0, 0, win.width, win.height)
+        if self.properties.HasFill():
+            self.gc.Rectangle(Trafo(win.width, 0, 0, win.height, 0, 0))
+        else:
+            self.gc.SetLineColor(StandardColors.black)
+            self.gc.DrawLineXY(0, win.height, win.width, 0)
+        self.gc.EndDblBuffer()
 
     def ResizedMethod(self, width, height):
-	self.gc.WindowResized(width, height)
-	self.UpdateWhenIdle()
-	self.compute_trafo()
+        self.gc.WindowResized(width, height)
+        self.UpdateWhenIdle()
+        self.compute_trafo()
 
 
 CENTER = 'center'
@@ -121,182 +121,182 @@
     allow_edit_dir = 0
 
     def __init__(self, master=None, **kw):
-	apply(PatternSample.__init__, (self, master), kw)
-	self.bind('<ButtonPress>', self.ButtonPressEvent)
-	self.bind('<Motion>', self.PointerMotionEvent)
-	self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
-	self.current_mode = 0	# 0: center, 1: direction
-	self.current_pos = (0, 0)
-	self.center = (0, 0)
-	self.drawn = 0
-	self.dragging = 0
+        apply(PatternSample.__init__, (self, master), kw)
+        self.bind('<ButtonPress>', self.ButtonPressEvent)
+        self.bind('<Motion>', self.PointerMotionEvent)
+        self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
+        self.current_mode = 0	# 0: center, 1: direction
+        self.current_pos = (0, 0)
+        self.center = (0, 0)
+        self.drawn = 0
+        self.dragging = 0
 
     def destroy(self):
-	Publisher.Destroy(self)
-	PatternSample.destroy(self)
+        Publisher.Destroy(self)
+        PatternSample.destroy(self)
 
     def SetEditMode(self, center, direction):
-	self.allow_edit_center = center
-	self.allow_edit_dir = direction
+        self.allow_edit_center = center
+        self.allow_edit_dir = direction
 
     def SetCenter(self, pos):
-	x, y = pos
-	x =	 x  * self.tkwin.width
-	y = (1 - y) * self.tkwin.height
-	self.center = (x, y)
+        x, y = pos
+        x =	 x  * self.tkwin.width
+        y = (1 - y) * self.tkwin.height
+        self.center = (x, y)
 
     def init_gc(self):
-	PatternSample.init_gc(self)
-	self.inv_gc = self.tkwin.CreateGC(foreground = ~0,
-					  function = Xconst.GXxor)
+        PatternSample.init_gc(self)
+        self.inv_gc = self.tkwin.CreateGC(foreground = ~0,
+                                          function = Xconst.GXxor)
 
     def ButtonPressEvent(self, event):
-	button = event.num
-	if button == Xconst.Button1 and self.allow_edit_center:
-	    self.current_mode = 0
-	elif self.allow_edit_dir:
-	    self.current_mode = 1
-	else:
-	    return
+        button = event.num
+        if button == Xconst.Button1 and self.allow_edit_center:
+            self.current_mode = 0
+        elif self.allow_edit_dir:
+            self.current_mode = 1
+        else:
+            return
 
-	self.current_pos = (event.x, event.y, event.state & ConstraintMask)
-	self.show_edit()
-	self.dragging = 1
+        self.current_pos = (event.x, event.y, event.state & ConstraintMask)
+        self.show_edit()
+        self.dragging = 1
 
     def PointerMotionEvent(self, event):
-	if self.dragging:
-	    self.hide_edit()
-	    self.current_pos = (event.x, event.y, event.state & ConstraintMask)
-	    self.show_edit()
+        if self.dragging:
+            self.hide_edit()
+            self.current_pos = (event.x, event.y, event.state & ConstraintMask)
+            self.show_edit()
 
     def ButtonReleaseEvent(self, event):
-	if self.dragging:
-	    self.hide_edit()
-	    self.current_pos = (event.x, event.y, event.state & ConstraintMask)
-	    self.report_edit()
-	    self.dragging = 0
+        if self.dragging:
+            self.hide_edit()
+            self.current_pos = (event.x, event.y, event.state & ConstraintMask)
+            self.report_edit()
+            self.dragging = 0
 
     def show_edit(self):
-	if not self.drawn:
-	    self.draw_edit()
-	    self.drawn = 1
+        if not self.drawn:
+            self.draw_edit()
+            self.drawn = 1
 
     def hide_edit(self):
-	if self.drawn:
-	    self.draw_edit()
-	    self.drawn = 0
+        if self.drawn:
+            self.draw_edit()
+            self.drawn = 0
 
     def constrain_center(self, x, y):
-	width = self.tkwin.width
-	height = self.tkwin.height
-	x = float(x) / width
-	y = float(y) / height
-	if   x < 0.25:	x = 0
-	elif x < 0.75:	x = 0.5
-	else:		x = 1.0
+        width = self.tkwin.width
+        height = self.tkwin.height
+        x = float(x) / width
+        y = float(y) / height
+        if   x < 0.25:	x = 0
+        elif x < 0.75:	x = 0.5
+        else:		x = 1.0
 
-	if   y < 0.25:	y = 0
-	elif y < 0.75:	y = 0.5
-	else:		y = 1.0
+        if   y < 0.25:	y = 0
+        elif y < 0.75:	y = 0.5
+        else:		y = 1.0
 
-	return (int(width * x), int(height * y))
+        return (int(width * x), int(height * y))
 
     def draw_edit(self):
-	x, y, constraint = self.current_pos
-	if self.current_mode == 0:
-	    if constraint:
-		x, y = self.constrain_center(x, y)
-	    self.inv_gc.DrawLine(0, y, self.tkwin.width, y)
-	    self.inv_gc.DrawLine(x, 0, x, self.tkwin.height)
-	else:
-	    cx, cy = self.center
+        x, y, constraint = self.current_pos
+        if self.current_mode == 0:
+            if constraint:
+                x, y = self.constrain_center(x, y)
+            self.inv_gc.DrawLine(0, y, self.tkwin.width, y)
+            self.inv_gc.DrawLine(x, 0, x, self.tkwin.height)
+        else:
+            cx, cy = self.center
 
-	    angle = atan2(y - cy, x - cx) + 2 * pi
-	    if constraint:
-		pi12 = pi / 12
-		angle = pi12 * int(angle / pi12 + 0.5)
+            angle = atan2(y - cy, x - cx) + 2 * pi
+            if constraint:
+                pi12 = pi / 12
+                angle = pi12 * int(angle / pi12 + 0.5)
 
-	    x = cx + cos(angle) * 1000.0
-	    y = cy + sin(angle) * 1000.0
+            x = cx + cos(angle) * 1000.0
+            y = cy + sin(angle) * 1000.0
 
-	    self.inv_gc.DrawLine(int(cx), int(cy), int(x), int(y))
+            self.inv_gc.DrawLine(int(cx), int(cy), int(x), int(y))
 
     def report_edit(self):
-	x, y, constraint = self.current_pos
-	if self.current_mode == 0:
-	    if constraint:
-		x, y = self.constrain_center(x, y)
-	    x =	    float(x) / self.tkwin.width
-	    y = 1 - float(y) / self.tkwin.height
-	    self.issue(CENTER, (x, y))
-	else:
-	    cx, cy = self.center
+        x, y, constraint = self.current_pos
+        if self.current_mode == 0:
+            if constraint:
+                x, y = self.constrain_center(x, y)
+            x =	    float(x) / self.tkwin.width
+            y = 1 - float(y) / self.tkwin.height
+            self.issue(CENTER, (x, y))
+        else:
+            cx, cy = self.center
 
-	    angle = atan2(y - cy, x - cx) + 2 * pi
-	    if constraint:
-		pi12 = pi / 12
-		angle = pi12 * int(angle / pi12 + 0.5)
+            angle = atan2(y - cy, x - cx) + 2 * pi
+            if constraint:
+                pi12 = pi / 12
+                angle = pi12 * int(angle / pi12 + 0.5)
 
-	    self.issue(DIRECTION, (cos(angle), -sin(angle)) )
+            self.issue(DIRECTION, (cos(angle), -sin(angle)) )
 
     def RedrawMethod(self, region):
-	PatternSample.RedrawMethod(self, region)
-	self.drawn = 0
+        PatternSample.RedrawMethod(self, region)
+        self.drawn = 0
 
 
 class PatternFrame(Frame, Publisher):
 
     def __init__(self, master=None, **kw):
-	apply(Frame.__init__, (self, master), kw)
-	self.dialog = None
-	self.pattern = EmptyPattern
+        apply(Frame.__init__, (self, master), kw)
+        self.dialog = None
+        self.pattern = EmptyPattern
 
     def SetPattern(self, pattern):
-	self.pattern = pattern.Duplicate()	# should be Copy...
+        self.pattern = pattern.Duplicate()	# should be Copy...
 
     def Pattern(self):
-	return self.pattern
+        return self.pattern
 
     def destroy(self):
-	Publisher.Destroy(self)
-	Frame.destroy(self)
+        Publisher.Destroy(self)
+        Frame.destroy(self)
 
     def SetCenter(self, center):
-	pass
+        pass
 
     def SetDirection(self, dir):
-	pass
+        pass
 
     def Center(self):
-	return (0.5, 0.5)
+        return (0.5, 0.5)
 
     def EditModes(self):
-	return (0, 0)
+        return (0, 0)
 
 
 class SolidPatternFrame(PatternFrame):
 
     def __init__(self, master=None, **kw):
-	apply(PatternFrame.__init__, (self, master), kw)
+        apply(PatternFrame.__init__, (self, master), kw)
 
-	label = Label(self, text = _("Color"))
-	label.pack(side = LEFT, expand = 1, anchor = E)
-	self.color_but = ColorButton(self, width = 3, height = 1,
-				     command = self.set_color)
-	self.color_but.pack(side = LEFT, expand = 1, anchor = W)
+        label = Label(self, text = _("Color"))
+        label.pack(side = LEFT, expand = 1, anchor = E)
+        self.color_but = ColorButton(self, width = 3, height = 1,
+                                     command = self.set_color)
+        self.color_but.pack(side = LEFT, expand = 1, anchor = W)
 
-	self.SetPattern(SolidPattern(StandardColors.black))
+        self.SetPattern(SolidPattern(StandardColors.black))
 
     def set_color(self):
-	self.pattern = SolidPattern(self.__get_color())
-	self.issue(CHANGED)
+        self.pattern = SolidPattern(self.__get_color())
+        self.issue(CHANGED)
 
     def __get_color(self):
-	return self.color_but.Color()
+        return self.color_but.Color()
 
     def SetPattern(self, pattern):
-	PatternFrame.SetPattern(self, pattern)
-	self.color_but.SetColor(pattern.Color())
+        PatternFrame.SetPattern(self, pattern)
+        self.color_but.SetColor(pattern.Color())
 
 
 gradient_types = [LinearGradient, ConicalGradient, RadialGradient]
@@ -304,254 +304,254 @@
 class GradientPatternFrame(PatternFrame):
 
     def __init__(self, master=None, **kw):
-	apply(PatternFrame.__init__, (self, master), kw)
+        apply(PatternFrame.__init__, (self, master), kw)
 
-	gradient = CreateSimpleGradient(StandardColors.white,
-					StandardColors.black)
-	frame = Frame(self)
-	frame.pack(side = TOP, fill = X)
-	self.var_gradient_type = IntVar(self)
-	for value, bitmap in [(0, 'linear'), (1, 'conical'), (2, 'radial')]:
-	    bitmap = getattr(pixmaps, 'gradient_' + bitmap)
-	    button = make_button(frame, bitmap = bitmap, value = value,
-				 variable = self.var_gradient_type,
-				 command = self.choose_type)
-	    button.pack(side = LEFT, fill = X, expand = 1)
+        gradient = CreateSimpleGradient(StandardColors.white,
+                                        StandardColors.black)
+        frame = Frame(self)
+        frame.pack(side = TOP, fill = X)
+        self.var_gradient_type = IntVar(self)
+        for value, bitmap in [(0, 'linear'), (1, 'conical'), (2, 'radial')]:
+            bitmap = getattr(pixmaps, 'gradient_' + bitmap)
+            button = make_button(frame, bitmap = bitmap, value = value,
+                                 variable = self.var_gradient_type,
+                                 command = self.choose_type)
+            button.pack(side = LEFT, fill = X, expand = 1)
 
-	frame = Frame(self)
-	frame.pack(side = TOP, expand = 1, fill = X)
-	self.colors = [None, None]
-	self.colors[0] = ColorButton(frame, height = 1,
-				     color = gradient.StartColor(),
-				     command = self.set_color, args = 0)
-	self.colors[0].pack(side = LEFT, fill = X, expand = 1)
-	self.colors[1] =  ColorButton(frame, height = 1,
-				      color = gradient.EndColor(),
-				      command = self.set_color, args = 1)
-	self.colors[1].pack(side = LEFT, fill = X, expand = 1)
+        frame = Frame(self)
+        frame.pack(side = TOP, expand = 1, fill = X)
+        self.colors = [None, None]
+        self.colors[0] = ColorButton(frame, height = 1,
+                                     color = gradient.StartColor(),
+                                     command = self.set_color, args = 0)
+        self.colors[0].pack(side = LEFT, fill = X, expand = 1)
+        self.colors[1] =  ColorButton(frame, height = 1,
+                                      color = gradient.EndColor(),
+                                      command = self.set_color, args = 1)
+        self.colors[1].pack(side = LEFT, fill = X, expand = 1)
 
-	self.var_border = DoubleVar(self)
-	self.var_border.set(0.0)
-	frame = Frame(self)
-	frame.pack(side = TOP, fill = X, expand = 1)
-	label = Label(frame, text = _("Border"))
-	label.pack(side = LEFT, expand = 1, anchor = E)
-	entry = MyEntry(frame, textvariable = self.var_border, width = 4,
-			justify = RIGHT, command = self.set_border)
-	entry.pack(side = LEFT, expand = 1, fill = X)
-	scroll = MiniScroller(frame, variable = self.var_border,
-			      min = 0.0, max = 100.0, step = 1.0,
-			      command = self.set_border)
-	scroll.pack(side = LEFT, fill = Y)
+        self.var_border = DoubleVar(self)
+        self.var_border.set(0.0)
+        frame = Frame(self)
+        frame.pack(side = TOP, fill = X, expand = 1)
+        label = Label(frame, text = _("Border"))
+        label.pack(side = LEFT, expand = 1, anchor = E)
+        entry = MyEntry(frame, textvariable = self.var_border, width = 4,
+                        justify = RIGHT, command = self.set_border)
+        entry.pack(side = LEFT, expand = 1, fill = X)
+        scroll = MiniScroller(frame, variable = self.var_border,
+                              min = 0.0, max = 100.0, step = 1.0,
+                              command = self.set_border)
+        scroll.pack(side = LEFT, fill = Y)
 
-	button = UpdatedButton(self, text = _("Edit Gradient"),
-			       command = self.edit_gradient)
-	button.pack(side = TOP, fill = X)
+        button = UpdatedButton(self, text = _("Edit Gradient"),
+                               command = self.edit_gradient)
+        button.pack(side = TOP, fill = X)
 
-	pattern = LinearGradient(gradient)
-	self.SetPattern(pattern)
+        pattern = LinearGradient(gradient)
+        self.SetPattern(pattern)
 
 
     def set_color(self, idx):
-	self.gradient = self.gradient.Duplicate()
-	self.gradient.SetStartColor(self.__get_color(0))
-	self.gradient.SetEndColor(self.__get_color(1))
-	self.pattern = self.pattern.Duplicate()
-	self.pattern.SetGradient(self.gradient)
-	self.issue(CHANGED)
+        self.gradient = self.gradient.Duplicate()
+        self.gradient.SetStartColor(self.__get_color(0))
+        self.gradient.SetEndColor(self.__get_color(1))
+        self.pattern = self.pattern.Duplicate()
+        self.pattern.SetGradient(self.gradient)
+        self.issue(CHANGED)
 
     def __get_color(self, idx):
-	return self.colors[idx].Color()
+        return self.colors[idx].Color()
 
     def choose_type(self):
-	type = gradient_types[self.var_gradient_type.get()]
-	self.pattern = type(duplicate = self.pattern)
-	self.issue(CHANGED)
+        type = gradient_types[self.var_gradient_type.get()]
+        self.pattern = type(duplicate = self.pattern)
+        self.issue(CHANGED)
 
     def set_border(self, *rest):
-	border = self.var_border.get() / 100.0
-	if hasattr(self.pattern, 'SetBorder'):
-	    self.pattern = self.pattern.Duplicate()
-	    self.pattern.SetBorder(border)
-	    self.issue(CHANGED)
+        border = self.var_border.get() / 100.0
+        if hasattr(self.pattern, 'SetBorder'):
+            self.pattern = self.pattern.Duplicate()
+            self.pattern.SetBorder(border)
+            self.issue(CHANGED)
 
     def SetPattern(self, pattern):
-	PatternFrame.SetPattern(self, pattern)
-	self.gradient = gradient = pattern.Gradient().Duplicate()
-	self.var_gradient_type.set(gradient_types.index(pattern.__class__))
-	self.colors[0].SetColor(gradient.StartColor())
-	self.colors[1].SetColor(gradient.EndColor())
-	if hasattr(pattern, 'Border'):
-	    self.var_border.set(pattern.Border() * 100.0)
+        PatternFrame.SetPattern(self, pattern)
+        self.gradient = gradient = pattern.Gradient().Duplicate()
+        self.var_gradient_type.set(gradient_types.index(pattern.__class__))
+        self.colors[0].SetColor(gradient.StartColor())
+        self.colors[1].SetColor(gradient.EndColor())
+        if hasattr(pattern, 'Border'):
+            self.var_border.set(pattern.Border() * 100.0)
 
     def Center(self):
-	if self.pattern.__class__ == LinearGradient:
-	    return (0.5, 0.5)
-	return tuple(self.pattern.Center())
+        if self.pattern.__class__ == LinearGradient:
+            return (0.5, 0.5)
+        return tuple(self.pattern.Center())
 
     def SetCenter(self, center):
-	if self.pattern.__class__ == LinearGradient:
-	    return
-	p = apply(Point, center)
-	self.pattern = self.pattern.Duplicate()
-	self.pattern.SetCenter(p)
-	self.issue(CHANGED)
+        if self.pattern.__class__ == LinearGradient:
+            return
+        p = apply(Point, center)
+        self.pattern = self.pattern.Duplicate()
+        self.pattern.SetCenter(p)
+        self.issue(CHANGED)
 
     def SetDirection(self, dir):
-	if self.pattern.__class__ == RadialGradient:
-	    return
-	dir = apply(Point, dir)
-	self.pattern = self.pattern.Duplicate()
-	self.pattern.SetDirection(dir)
-	self.issue(CHANGED)
+        if self.pattern.__class__ == RadialGradient:
+            return
+        dir = apply(Point, dir)
+        self.pattern = self.pattern.Duplicate()
+        self.pattern.SetDirection(dir)
+        self.issue(CHANGED)
 
     def EditModes(self):
-	if self.pattern.__class__ == LinearGradient:
-	    return (0, 1)
-	elif self.pattern.__class__ == RadialGradient:
-	    return (1, 0)
-	else:
-	    return (1, 1)
+        if self.pattern.__class__ == LinearGradient:
+            return (0, 1)
+        elif self.pattern.__class__ == RadialGradient:
+            return (1, 0)
+        else:
+            return (1, 1)
 
     def edit_gradient(self):
-	gradient = gradientedit.EditGradient(self, self.gradient)
-	if gradient is not None:
-	    pattern = self.pattern.Duplicate()
-	    pattern.SetGradient(gradient)
-	    self.SetPattern(pattern)
-	    self.issue(CHANGED)
+        gradient = gradientedit.EditGradient(self, self.gradient)
+        if gradient is not None:
+            pattern = self.pattern.Duplicate()
+            pattern.SetGradient(gradient)
+            self.SetPattern(pattern)
+            self.issue(CHANGED)
 
 
 
 class HatchingPatternFrame(PatternFrame):
 
     def __init__(self, master=None, **kw):
-	apply(PatternFrame.__init__, (self, master), kw)
+        apply(PatternFrame.__init__, (self, master), kw)
 
-	frame = Frame(self)
-	frame.pack(side = TOP, fill = X, expand = 1)
-	self.colors = [None, None]
-	self.colors[0] = ColorButton(frame, height = 1,
-				     command = self.set_color, args = 0)
-	self.colors[0].pack(side = LEFT, fill = X, expand = 1)
-	self.colors[1] = ColorButton(frame, height = 1,
-				     command = self.set_color, args = 1)
-	self.colors[1].pack(side = LEFT, fill = X, expand = 1)
+        frame = Frame(self)
+        frame.pack(side = TOP, fill = X, expand = 1)
+        self.colors = [None, None]
+        self.colors[0] = ColorButton(frame, height = 1,
+                                     command = self.set_color, args = 0)
+        self.colors[0].pack(side = LEFT, fill = X, expand = 1)
+        self.colors[1] = ColorButton(frame, height = 1,
+                                     command = self.set_color, args = 1)
+        self.colors[1].pack(side = LEFT, fill = X, expand = 1)
 
-	var_spacing_number = DoubleVar(self)
-	var_unit = StringVar(self)
-	self.var_spacing = LengthVar(1.0, config.preferences.default_unit,
+        var_spacing_number = DoubleVar(self)
+        var_unit = StringVar(self)
+        self.var_spacing = LengthVar(1.0, config.preferences.default_unit,
                                      var_spacing_number, var_unit,
                                      command = self.set_spacing)
-	width_frame = Frame(self)
-	width_frame.pack(side = TOP, fill = X, expand = 1)
-	#label = Label(width_frame, text = 'Spacing')
-	#label.pack(side = LEFT, expand = 1, anchor = E)
-	entry = MyEntry(width_frame, textvariable = var_spacing_number,
-			justify = RIGHT, width = 6,
-			command = self.var_spacing.UpdateNumber)
-	entry.pack(side = LEFT, expand = 1, fill = X)
-	scroll = MiniScroller(width_frame, variable = var_spacing_number,
-			      min = 0.0, max = None, step = 1.0,
-			      command = self.var_spacing.UpdateNumber)
-	scroll.pack(side = LEFT, fill = Y)
-	optmenu = create_unit_menu(width_frame, self.var_spacing.UpdateUnit,
-				   variable = var_unit,
-				   indicatoron = 0, width = 3)
-	optmenu.pack(side = LEFT, expand = 1, fill = X, anchor = W)
+        width_frame = Frame(self)
+        width_frame.pack(side = TOP, fill = X, expand = 1)
+        #label = Label(width_frame, text = 'Spacing')
+        #label.pack(side = LEFT, expand = 1, anchor = E)
+        entry = MyEntry(width_frame, textvariable = var_spacing_number,
+                        justify = RIGHT, width = 6,
+                        command = self.var_spacing.UpdateNumber)
+        entry.pack(side = LEFT, expand = 1, fill = X)
+        scroll = MiniScroller(width_frame, variable = var_spacing_number,
+                              min = 0.0, max = None, step = 1.0,
+                              command = self.var_spacing.UpdateNumber)
+        scroll.pack(side = LEFT, fill = Y)
+        optmenu = create_unit_menu(width_frame, self.var_spacing.UpdateUnit,
+                                   variable = var_unit,
+                                   indicatoron = 0, width = 3)
+        optmenu.pack(side = LEFT, expand = 1, fill = X, anchor = W)
 
-	self.SetPattern(HatchingPattern(StandardColors.red))
+        self.SetPattern(HatchingPattern(StandardColors.red))
 
     def set_color(self, idx):
-	self.pattern = self.pattern.Duplicate()
-	self.pattern.SetForeground(self.__get_color(0))
-	self.pattern.SetBackground(self.__get_color(1))
-	self.issue(CHANGED)
+        self.pattern = self.pattern.Duplicate()
+        self.pattern.SetForeground(self.__get_color(0))
+        self.pattern.SetBackground(self.__get_color(1))
+        self.issue(CHANGED)
 
     def __get_color(self, idx):
-	return self.colors[idx].Color()
+        return self.colors[idx].Color()
 
     def set_spacing(self, *rest):
-	spacing = self.var_spacing.get()
-	self.pattern = self.pattern.Duplicate()
-	self.pattern.SetSpacing(spacing)
-	self.issue(CHANGED)
+        spacing = self.var_spacing.get()
+        self.pattern = self.pattern.Duplicate()
+        self.pattern.SetSpacing(spacing)
+        self.issue(CHANGED)
 
     def SetPattern(self, pattern):
-	PatternFrame.SetPattern(self, pattern)
-	self.colors[0].SetColor(pattern.Foreground())
-	self.colors[1].SetColor(pattern.Background())
-	self.var_spacing.set(pattern.Spacing())
+        PatternFrame.SetPattern(self, pattern)
+        self.colors[0].SetColor(pattern.Foreground())
+        self.colors[1].SetColor(pattern.Background())
+        self.var_spacing.set(pattern.Spacing())
 
     def SetDirection(self, dir):
-	dir = apply(Point, dir)
-	self.pattern = self.pattern.Duplicate()
-	self.pattern.SetDirection(dir)
-	self.issue(CHANGED)
+        dir = apply(Point, dir)
+        self.pattern = self.pattern.Duplicate()
+        self.pattern.SetDirection(dir)
+        self.issue(CHANGED)
 
     def EditModes(self):
-	return (0, 1)
+        return (0, 1)
 
 
 class ImageTilePatternFrame(PatternFrame):
 
     def __init__(self, master, main_window, **kw):
-	apply(PatternFrame.__init__, (self, master), kw)
-	self.main_window = main_window
-	button = UpdatedButton(self, text = _("Load Image..."),
-			       command = self.load_image)
-	button.pack(side = TOP, fill = X)
-	button = UpdatedButton(self, text = _("Pick Image..."),
-			       command = self.pick_image)
-	button.pack(side = TOP, fill = X)
+        apply(PatternFrame.__init__, (self, master), kw)
+        self.main_window = main_window
+        button = UpdatedButton(self, text = _("Load Image..."),
+                               command = self.load_image)
+        button.pack(side = TOP, fill = X)
+        button = UpdatedButton(self, text = _("Pick Image..."),
+                               command = self.pick_image)
+        button.pack(side = TOP, fill = X)
 
-	file = os.path.join(config.std_res_dir, config.preferences.pattern)
-	try:
-	    file = open(file)
-	    tile = load_image(file)
-	except:
-	    warn_tb(INTERNAL, "Cannot load %s", file)
-	    return
-	self.SetPattern(ImageTilePattern(tile))
+        file = os.path.join(config.std_res_dir, config.preferences.pattern)
+        try:
+            file = open(file)
+            tile = load_image(file)
+        except:
+            warn_tb(INTERNAL, "Cannot load %s", file)
+            return
+        self.SetPattern(ImageTilePattern(tile))
 
     def load_image(self):
-	dir = config.preferences.pattern_dir
-	filename = self.main_window.GetOpenImageFilename(no_eps = 1,
-							 initialdir = dir)
-	if not filename:
-	    return
-	try:
-	    tile = load_image(filename)
-	except IOError, value:
-	    if type(value) == type(()):
-		value = value[1]
-	    basename = os.path.split(filename)[1]
-	    self.main_window.application.MessageBox(title = _("Load Image"),
-					message=_("Cannot load %(filename)s:\n"
-						  "%(message)s") \
-						    % {'filename':`basename`,
-						       'message':value},
-						    icon = 'warning')
-	else:
-	    self.SetPattern(ImageTilePattern(tile))
-	    self.issue(CHANGED)
-	    config.preferences.pattern_dir = os.path.split(filename)[0]
+        dir = config.preferences.pattern_dir
+        filename = self.main_window.GetOpenImageFilename(no_eps = 1,
+                                                         initialdir = dir)
+        if not filename:
+            return
+        try:
+            tile = load_image(filename)
+        except IOError, value:
+            if type(value) == type(()):
+                value = value[1]
+            basename = os.path.split(filename)[1]
+            self.main_window.application.MessageBox(title = _("Load Image"),
+                                                    message=_("Cannot load %(filename)s:\n"
+                                                              "%(message)s") \
+                                                    % {'filename':`basename`,
+                                                       'message':value},
+                                                    icon = 'warning')
+        else:
+            self.SetPattern(ImageTilePattern(tile))
+            self.issue(CHANGED)
+            config.preferences.pattern_dir = os.path.split(filename)[0]
 
     def pick_image(self):
-	self.main_window.canvas.PickObject(self.update_from_image)
+        self.main_window.canvas.PickObject(self.update_from_image)
 
     def update_from_image(self, obj):
-	if obj is not None:
-	    if obj.is_Image:
-		# XXX data is no public attribute
-		self.SetPattern(ImageTilePattern(obj.data))
-		self.issue(CHANGED)
-	    elif obj.has_properties:
-		pattern = obj.Properties().fill_pattern
-		if pattern.__class__ == ImageTilePattern:
-		    # XXX data is no public attribute
-		    self.SetPattern(ImageTilePattern(pattern.data))
-		    self.issue(CHANGED)
+        if obj is not None:
+            if obj.is_Image:
+                # XXX data is no public attribute
+                self.SetPattern(ImageTilePattern(obj.data))
+                self.issue(CHANGED)
+            elif obj.has_properties:
+                pattern = obj.Properties().fill_pattern
+                if pattern.__class__ == ImageTilePattern:
+                    # XXX data is no public attribute
+                    self.SetPattern(ImageTilePattern(pattern.data))
+                    self.issue(CHANGED)
 
 
 class FillPanel(StylePropertyPanel):
@@ -559,96 +559,96 @@
     title = _("Fill Style")
 
     def __init__(self, master, main_window, doc):
-	StylePropertyPanel.__init__(self, master, main_window, doc,
-			       name = 'filldlg')
+        StylePropertyPanel.__init__(self, master, main_window, doc,
+                                    name = 'filldlg')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	# a bit of a hack to accept drops...
-	top.accept_drop = (DROP_COLOR,)
-	top.DropAt = self.DropAt
+        # a bit of a hack to accept drops...
+        top.accept_drop = (DROP_COLOR,)
+        top.DropAt = self.DropAt
 
-	# the standard buttons (apply, cancel, update...)
-	button_frame = self.create_std_buttons(top)
-	button_frame.pack(side = BOTTOM, fill = X, expand = 0)
+        # the standard buttons (apply, cancel, update...)
+        button_frame = self.create_std_buttons(top)
+        button_frame.pack(side = BOTTOM, fill = X, expand = 0)
 
-	#
-	self.var_transform = IntVar(top)
-	self.var_transform.set(1)
-	button = UpdatedCheckbutton(top, text = _("Transform Pattern"),
-				    variable = self.var_transform,
-				    command = self.set_fill_transform)
-	button.pack(side = BOTTOM, fill = X)
+        #
+        self.var_transform = IntVar(top)
+        self.var_transform.set(1)
+        button = UpdatedCheckbutton(top, text = _("Transform Pattern"),
+                                    variable = self.var_transform,
+                                    command = self.set_fill_transform)
+        button.pack(side = BOTTOM, fill = X)
 
-	# type frame
-	type_frame = Frame(top)
-	type_frame.pack(side = LEFT, fill = Y, expand = 0)
+        # type frame
+        type_frame = Frame(top)
+        type_frame.pack(side = LEFT, fill = Y, expand = 0)
 
-	# sample
-	self.sample = InteractiveSample(top, width = 60, height = 60,
-					background = 'white')
-	self.sample.pack(side = TOP, fill = X, anchor = N)
-	self.sample.SetPattern(EmptyPattern)
-	self.sample.Subscribe(CENTER, self.center_changed)
-	self.sample.Subscribe(DIRECTION, self.direction_changed)
+        # sample
+        self.sample = InteractiveSample(top, width = 60, height = 60,
+                                        background = 'white')
+        self.sample.pack(side = TOP, fill = X, anchor = N)
+        self.sample.SetPattern(EmptyPattern)
+        self.sample.Subscribe(CENTER, self.center_changed)
+        self.sample.Subscribe(DIRECTION, self.direction_changed)
 
-	# pattern frames
-	self.frames = [None, None, None, None, None]
-	self.frames[0] = PatternFrame(top)
-	self.frames[1] = SolidPatternFrame(top)
-	self.frames[2] = GradientPatternFrame(top)
-	self.frames[3] = HatchingPatternFrame(top)
-	self.frames[4] = ImageTilePatternFrame(top,
-					       main_window = self.main_window)
+        # pattern frames
+        self.frames = [None, None, None, None, None]
+        self.frames[0] = PatternFrame(top)
+        self.frames[1] = SolidPatternFrame(top)
+        self.frames[2] = GradientPatternFrame(top)
+        self.frames[3] = HatchingPatternFrame(top)
+        self.frames[4] = ImageTilePatternFrame(top,
+                                               main_window = self.main_window)
 
-	width = 0
-	for frame in self.frames:
-	    frame.Subscribe(CHANGED, self.pattern_changed, 1)
-	    frame.update()
-	    w = frame.winfo_reqwidth()
-	    if w > width:
-		width = w
+        width = 0
+        for frame in self.frames:
+            frame.Subscribe(CHANGED, self.pattern_changed, 1)
+            frame.update()
+            w = frame.winfo_reqwidth()
+            if w > width:
+                width = w
 
-	self.sample.config(width = width)
+        self.sample.config(width = width)
 
-	self.var_pattern_type = IntVar(top)
-	types = ((0, pixmaps.fill_none), (1, pixmaps.fill_solid),
-		 (2, pixmaps.fill_gradient), (3, pixmaps.fill_hatch),
-		 (4, pixmaps.fill_tile))
-	for value, bitmap in types:
-	    button = make_button(type_frame, bitmap = bitmap, value = value,
-				 variable = self.var_pattern_type,
-				 command = self.choose_pattern)
-	    button.pack(side = TOP)
+        self.var_pattern_type = IntVar(top)
+        types = ((0, pixmaps.fill_none), (1, pixmaps.fill_solid),
+                 (2, pixmaps.fill_gradient), (3, pixmaps.fill_hatch),
+                 (4, pixmaps.fill_tile))
+        for value, bitmap in types:
+            button = make_button(type_frame, bitmap = bitmap, value = value,
+                                 variable = self.var_pattern_type,
+                                 command = self.choose_pattern)
+            button.pack(side = TOP)
 
-	# unknown
-	self.frame_unknown = PatternFrame(top)
+        # unknown
+        self.frame_unknown = PatternFrame(top)
 
-	self.active_frame = None
+        self.active_frame = None
 
     def close_dlg(self):
-	StylePropertyPanel.close_dlg(self)
-	self.top.DropAt = None
+        StylePropertyPanel.close_dlg(self)
+        self.top.DropAt = None
 
     def activate_frame(self, frame):
-	if self.active_frame != frame:
-	    if self.active_frame:
-		self.active_frame.forget()
-	    if frame:
-		frame.pack(side = TOP, fill = X)
-	    self.active_frame = frame
-	    self.update_sample()
+        if self.active_frame != frame:
+            if self.active_frame:
+                self.active_frame.forget()
+            if frame:
+                frame.pack(side = TOP, fill = X)
+            self.active_frame = frame
+            self.update_sample()
 
     def choose_pattern(self, idx = None, pattern = None):
-	if idx is None:
-	    idx = self.var_pattern_type.get()
-	else:
-	    self.var_pattern_type.set(idx)
-	self.activate_frame(self.frames[idx])
-	if pattern is not None:
-	    self.active_frame.SetPattern(pattern)
-	self.update_sample()
+        if idx is None:
+            idx = self.var_pattern_type.get()
+        else:
+            self.var_pattern_type.set(idx)
+        self.activate_frame(self.frames[idx])
+        if pattern is not None:
+            self.active_frame.SetPattern(pattern)
+        self.update_sample()
 
     def init_from_pattern(self, pattern, transform = 1):
         if pattern.__class__ == SolidPattern:
@@ -665,52 +665,52 @@
         self.var_transform.set(transform)
 
     def init_from_properties(self, properties):
-	if properties.HasFill():
+        if properties.HasFill():
             self.init_from_pattern(properties.fill_pattern,
                                    properties.fill_transform)
-	else:
-	    self.choose_pattern(0)
+        else:
+            self.choose_pattern(0)
 
     def pattern_changed(self, *args):
-	self.update_sample()
+        self.update_sample()
 
     def update_sample(self):
-	if self.active_frame:
-	    self.sample.SetPattern(self.active_frame.Pattern())
-	    self.sample.SetCenter(self.active_frame.Center())
-	    apply(self.sample.SetEditMode, self.active_frame.EditModes())
+        if self.active_frame:
+            self.sample.SetPattern(self.active_frame.Pattern())
+            self.sample.SetCenter(self.active_frame.Center())
+            apply(self.sample.SetEditMode, self.active_frame.EditModes())
 
     def center_changed(self, center):
-	if self.active_frame:
-	    self.active_frame.SetCenter(center)
+        if self.active_frame:
+            self.active_frame.SetCenter(center)
 
     def direction_changed(self, dir):
-	if self.active_frame:
-	    self.active_frame.SetDirection(dir)
+        if self.active_frame:
+            self.active_frame.SetDirection(dir)
 
     def init_from_doc(self):
-	self.Update()
+        self.Update()
 
     def Update(self):
-	if self.document.HasSelection():
+        if self.document.HasSelection():
             self.init_from_properties(self.document.CurrentProperties())
 
     def do_apply(self):
         kw = {}
-	if self.active_frame:
-	    kw['fill_pattern'] = self.active_frame.Pattern().Duplicate()
-	    kw['fill_transform'] = self.var_transform.get()
-	else:
-	    kw['fill_pattern'] = EmptyFillStyle
+        if self.active_frame:
+            kw['fill_pattern'] = self.active_frame.Pattern().Duplicate()
+            kw['fill_transform'] = self.var_transform.get()
+        else:
+            kw['fill_pattern'] = EmptyFillStyle
         self.set_properties(_("Set Fill"), 'fill', kw)
 
     def set_fill_transform(self):
-	self.document.SetProperties(fill_transform = self.var_transform.get())
+        self.document.SetProperties(fill_transform = self.var_transform.get())
 
     def update_from_object_cb(self, obj):
-	if obj is not None:
-	    self.init_from_properties(obj.Properties())
+        if obj is not None:
+            self.init_from_properties(obj.Properties())
 
     def DropAt(self, x, y, what, data):
-	if what == DROP_COLOR:
-	    self.init_from_pattern(SolidPattern(data))
+        if what == DROP_COLOR:
+            self.init_from_pattern(SolidPattern(data))

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/fontdlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/fontdlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/fontdlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -39,7 +39,7 @@
     # If item in list, return item, else try to find some standard items in
     # list. If that also fails return list[0]
     if item in list:
-	return item
+        return item
     return list[0]
 
 class FontPanel(StylePropertyPanel):
@@ -47,81 +47,81 @@
     title = _("Fonts")
 
     def __init__(self, master, main_window, doc):
-	self.family_to_fonts = font.make_family_to_fonts()
-	self.families = self.family_to_fonts.keys()
-	self.families.sort()
-	StylePropertyPanel.__init__(self, master, main_window, doc,
+        self.family_to_fonts = font.make_family_to_fonts()
+        self.families = self.family_to_fonts.keys()
+        self.families.sort()
+        StylePropertyPanel.__init__(self, master, main_window, doc,
                                     name = 'fontdlg')
-	self.family_list.SetList(self.families)
-	index = self.families.index(self.font_family)
-	self.family_list.select_set(index)
-	self.family_list.yview(index)
+        self.family_list.SetList(self.families)
+        index = self.families.index(self.font_family)
+        self.family_list.select_set(index)
+        self.family_list.yview(index)
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	buttons = self.create_std_buttons(top)
-	buttons.grid(row = 3, column = 4, columnspan = 2, sticky = "news")
+        buttons = self.create_std_buttons(top)
+        buttons.grid(row = 3, column = 4, columnspan = 2, sticky = "news")
 
-	self.sample_text = StringVar(top)
-	self.sample_text.set(config.preferences.sample_text)
-	self.sample = Entry(top, textvariable = self.sample_text,
-			    relief = FLAT, bg = top['bg'],
-			    width = len(config.preferences.sample_text))
-	self.sample.grid(column = 0, row = 3, columnspan = 4, sticky = "news")
-	# XXX: the background color of the sample text should be
-	# configurable
+        self.sample_text = StringVar(top)
+        self.sample_text.set(config.preferences.sample_text)
+        self.sample = Entry(top, textvariable = self.sample_text,
+                            relief = FLAT, bg = top['bg'],
+                            width = len(config.preferences.sample_text))
+        self.sample.grid(column = 0, row = 3, columnspan = 4, sticky = "news")
+        # XXX: the background color of the sample text should be
+        # configurable
 
-	label = Label(top, text = _("Font Family:"), anchor = W)
-	label.grid(column = 0, row = 0, columnspan = 2, sticky = "ew")
-	sb_vert = Scrollbar(top, takefocus = 0)
-	sb_vert.grid(column = 1, row = 1, rowspan = 2, sticky = "news")
-	family_list = UpdatedListbox(top, name = 'families', height = 8)
-	family_list.grid(column = 0, row = 1, rowspan = 2, sticky = "news")
-	family_list.Subscribe(SELECTION, self.family_selected)
-	sb_vert['command'] = (family_list, 'yview')
-	family_list['yscrollcommand'] = (sb_vert, 'set')
-	self.family_list = family_list
+        label = Label(top, text = _("Font Family:"), anchor = W)
+        label.grid(column = 0, row = 0, columnspan = 2, sticky = "ew")
+        sb_vert = Scrollbar(top, takefocus = 0)
+        sb_vert.grid(column = 1, row = 1, rowspan = 2, sticky = "news")
+        family_list = UpdatedListbox(top, name = 'families', height = 8)
+        family_list.grid(column = 0, row = 1, rowspan = 2, sticky = "news")
+        family_list.Subscribe(SELECTION, self.family_selected)
+        sb_vert['command'] = (family_list, 'yview')
+        family_list['yscrollcommand'] = (sb_vert, 'set')
+        self.family_list = family_list
 
-	label = Label(top, text = _("Font Style:"), anchor = W)
-	label.grid(column = 2, row = 0, sticky = "ew")
-	sb_vert = Scrollbar(top, takefocus = 0)
-	sb_vert.grid(column = 3, row = 1, rowspan = 2, sticky = "news")
-	self.font_attr_list = UpdatedListbox(top, name = 'weights', height = 4,
-					     width = 15)
-	self.font_attr_list.grid(column = 2, row = 1, rowspan = 2,
-				 sticky = "news")
-	self.font_attr_list.Subscribe(SELECTION, self.attr_selected)
-	sb_vert['command'] = (self.font_attr_list, 'yview')
-	self.font_attr_list['yscrollcommand'] = (sb_vert, 'set')
+        label = Label(top, text = _("Font Style:"), anchor = W)
+        label.grid(column = 2, row = 0, sticky = "ew")
+        sb_vert = Scrollbar(top, takefocus = 0)
+        sb_vert.grid(column = 3, row = 1, rowspan = 2, sticky = "news")
+        self.font_attr_list = UpdatedListbox(top, name = 'weights', height = 4,
+                                             width = 15)
+        self.font_attr_list.grid(column = 2, row = 1, rowspan = 2,
+                                 sticky = "news")
+        self.font_attr_list.Subscribe(SELECTION, self.attr_selected)
+        sb_vert['command'] = (self.font_attr_list, 'yview')
+        self.font_attr_list['yscrollcommand'] = (sb_vert, 'set')
 
-	label = Label(top, text = _("Size:"), anchor = W)
-	label.grid(column = 4, row = 0, columnspan = 2, sticky = "ew")
+        label = Label(top, text = _("Size:"), anchor = W)
+        label.grid(column = 4, row = 0, columnspan = 2, sticky = "ew")
 
-	frame = Frame(top)
-	frame.grid(column = 4, row = 1, columnspan = 2, sticky = 'ew')
-	self.var_size = DoubleVar(top)
-	scroll = MiniScroller(frame, variable = self.var_size,
-			      min = 0.0, max = None, step = 1)
-	scroll.pack(side = RIGHT, fill = Y)
-	self.size_entry = MyEntry(frame, textvariable = self.var_size,
-				  width = 4, command = self.apply_size,
-				  justify = RIGHT)
-	self.size_entry.pack(side = LEFT, expand = 1, fill = BOTH)
+        frame = Frame(top)
+        frame.grid(column = 4, row = 1, columnspan = 2, sticky = 'ew')
+        self.var_size = DoubleVar(top)
+        scroll = MiniScroller(frame, variable = self.var_size,
+                              min = 0.0, max = None, step = 1)
+        scroll.pack(side = RIGHT, fill = Y)
+        self.size_entry = MyEntry(frame, textvariable = self.var_size,
+                                  width = 4, command = self.apply_size,
+                                  justify = RIGHT)
+        self.size_entry.pack(side = LEFT, expand = 1, fill = BOTH)
 
-	sb_vert = Scrollbar(top, takefocus = 0)
-	sb_vert.grid(column = 5, row = 2, sticky = "news")
-	self.size_list = UpdatedListbox(top, name = 'sizes', width = 4,
-					height = 5)
-	self.size_list.grid(column = 4, row = 2, sticky = "news")
-	self.size_list.Subscribe(SELECTION, self.size_selected)
-	self.size_list.SetList(std_sizes)
-	sb_vert['command'] = (self.size_list, 'yview')
-	self.size_list['yscrollcommand'] = (sb_vert, 'set')
+        sb_vert = Scrollbar(top, takefocus = 0)
+        sb_vert.grid(column = 5, row = 2, sticky = "news")
+        self.size_list = UpdatedListbox(top, name = 'sizes', width = 4,
+                                        height = 5)
+        self.size_list.grid(column = 4, row = 2, sticky = "news")
+        self.size_list.Subscribe(SELECTION, self.size_selected)
+        self.size_list.SetList(std_sizes)
+        sb_vert['command'] = (self.size_list, 'yview')
+        self.size_list['yscrollcommand'] = (sb_vert, 'set')
 
-	top.columnconfigure(0, weight = 1000)
-	top.columnconfigure(4, weight = 1)
-	top.rowconfigure(2, weight = 1)
+        top.columnconfigure(0, weight = 1000)
+        top.columnconfigure(4, weight = 1)
+        top.rowconfigure(2, weight = 1)
 
     def init_from_doc(self):
         object = self.document.CurrentObject()
@@ -133,17 +133,17 @@
             self.font_attr = default.font_attrs
             self.update_from_family()
             self.update_size(properties.default_text_style.font_size)
-        
+
     def Update(self):
         self.update_from_object_cb(self.document.CurrentObject())
 
     def update_from_object_cb(self, obj):
-	if obj is not None and obj.is_Text:
-	    font = obj.Font()
+        if obj is not None and obj.is_Text:
+            font = obj.Font()
             self.font_family = font.family
-	    self.font_attr = font.font_attrs
+            self.font_attr = font.font_attrs
             self.update_size(obj.FontSize())
-	    self.update_from_family()
+            self.update_from_family()
 
     def do_apply(self):
         name = self.current_font_ps()
@@ -161,16 +161,16 @@
         self.set_properties(_("Set Font `%s'") % name, 'font', kw)
 
     def update_from_family(self, set_view = 1):
-	index = self.families.index(self.font_family)
-	self.family_list.Select(index, set_view)
-	fonts = self.family_to_fonts[self.font_family]
-	attrs = []
-	for name in fonts:
-	    attrs.append(font.fontmap[name][1])
+        index = self.families.index(self.font_family)
+        self.family_list.Select(index, set_view)
+        fonts = self.family_to_fonts[self.font_family]
+        attrs = []
+        for name in fonts:
+            attrs.append(font.fontmap[name][1])
 
-	attrs.sort()
-	self.set_font_attrs(attrs)
-	self.update_sample()
+        attrs.sort()
+        self.set_font_attrs(attrs)
+        self.update_sample()
 
     def update_size(self, size):
         self.var_size.set(size)
@@ -180,59 +180,59 @@
             self.size_list.SelectNone()
 
     def update_sample(self):
-	xlfd = self.current_font_xlfd()
-	if not xlfd:
-	    xlfd = 'fixed'
-	self.sample['font'] = xlfd
+        xlfd = self.current_font_xlfd()
+        if not xlfd:
+            xlfd = 'fixed'
+        self.sample['font'] = xlfd
 
     def set_font_attrs(self, attrs):
-	self.font_attrs = attrs
-	self.font_attr_list.SetList(attrs)
-	self.font_attr = get_from_list(self.font_attr, attrs)
-	self.font_attr_list.Select(attrs.index(self.font_attr), 1)
+        self.font_attrs = attrs
+        self.font_attr_list.SetList(attrs)
+        self.font_attr = get_from_list(self.font_attr, attrs)
+        self.font_attr_list.Select(attrs.index(self.font_attr), 1)
 
     def current_font_xlfd(self):
-	fonts = self.family_to_fonts[self.font_family]
-	for name in fonts:
-	    family, attrs, xlfd_start, encoding = font.fontmap[name]
-	    if attrs == self.font_attr:
-		return font.xlfd_template % (xlfd_start, 24, encoding)
-	return ''
+        fonts = self.family_to_fonts[self.font_family]
+        for name in fonts:
+            family, attrs, xlfd_start, encoding = font.fontmap[name]
+            if attrs == self.font_attr:
+                return font.xlfd_template % (xlfd_start, 24, encoding)
+        return ''
 
     def current_font_ps(self):
-	fonts = self.family_to_fonts[self.font_family]
-	for name in fonts:
-	    family, attrs, xlfd_start, encoding = font.fontmap[name]
-	    if attrs == self.font_attr:
-		return name
-	return ''
+        fonts = self.family_to_fonts[self.font_family]
+        for name in fonts:
+            family, attrs, xlfd_start, encoding = font.fontmap[name]
+            if attrs == self.font_attr:
+                return name
+        return ''
 
     def family_selected(self):
-	sel = self.family_list.curselection()
-	if sel:
-	    index = string.atoi(sel[0])
-	    self.font_family = self.families[index]
-	    self.update_from_family(set_view = 0)
+        sel = self.family_list.curselection()
+        if sel:
+            index = string.atoi(sel[0])
+            self.font_family = self.families[index]
+            self.update_from_family(set_view = 0)
 
     def attr_selected(self):
-	sel = self.font_attr_list.curselection()
-	if sel:
-	    index = string.atoi(sel[0])
-	    self.font_attr = self.font_attrs[index]
-	    self.update_sample()
+        sel = self.font_attr_list.curselection()
+        if sel:
+            index = string.atoi(sel[0])
+            self.font_attr = self.font_attrs[index]
+            self.update_sample()
 
     def size_selected(self):
-	sel = self.size_list.curselection()
-	if sel:
-	    self.var_size.set(self.size_list.get(sel[0]))
+        sel = self.size_list.curselection()
+        if sel:
+            self.var_size.set(self.size_list.get(sel[0]))
 
     def apply_size(self, *args):
-	if self.can_apply():
-	    size = self.var_size.get()
-	    self.document.CallObjectMethod(text.CommonText,
-					   _("Set Font Size %.1f") % size,
-					   'SetFontSize', size)
+        if self.can_apply():
+            size = self.var_size.get()
+            self.document.CallObjectMethod(text.CommonText,
+                                           _("Set Font Size %.1f") % size,
+                                           'SetFontSize', size)
 
     def save_prefs(self):
-	StylePropertyPanel.save_prefs(self)
-	config.preferences.sample_text = self.sample_text.get()
+        StylePropertyPanel.save_prefs(self)
+        config.preferences.sample_text = self.sample_text.get()

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/gradientedit.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/gradientedit.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/gradientedit.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -44,244 +44,244 @@
     accept_drop = (DROP_COLOR,)
 
     def __init__(self, master, width, height, gradient, **kw):
-	image = PIL.Image.new('RGB', (width, height))
-	self.orig_x = handle_height / 2
-	if not kw.has_key('width'):
-	    kw["width"] = width + handle_height
-	if not kw.has_key('height'):
-	    kw["height"] = height + handle_height
-	apply(PyWidget.__init__, (self, master), kw)
-	self.set_gradient(gradient)
-	self.update_pending = 0
-	self.dragging = 0
-	self.drag_idx = 0
-	self.drag_start = 0
-	self.drag_min = self.drag_max = 0.0
-	self.gc_initialized = 0
-	self.image = image
-	self.ximage = None
-	self.context_menu = None
-	self.bind('<ButtonPress-3>', self.PopupContextMenu)
-	self.bind('<ButtonPress>', self.ButtonPressEvent)
-	self.bind('<Motion>', self.PointerMotionEvent)
-	self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
+        image = PIL.Image.new('RGB', (width, height))
+        self.orig_x = handle_height / 2
+        if not kw.has_key('width'):
+            kw["width"] = width + handle_height
+        if not kw.has_key('height'):
+            kw["height"] = height + handle_height
+        apply(PyWidget.__init__, (self, master), kw)
+        self.set_gradient(gradient)
+        self.update_pending = 0
+        self.dragging = 0
+        self.drag_idx = 0
+        self.drag_start = 0
+        self.drag_min = self.drag_max = 0.0
+        self.gc_initialized = 0
+        self.image = image
+        self.ximage = None
+        self.context_menu = None
+        self.bind('<ButtonPress-3>', self.PopupContextMenu)
+        self.bind('<ButtonPress>', self.ButtonPressEvent)
+        self.bind('<Motion>', self.PointerMotionEvent)
+        self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
 
     def __del__(self):
-	pdebug('__del__', '__del__', self)
+        pdebug('__del__', '__del__', self)
 
     def MapMethod(self):
-	if not self.gc_initialized:
-	    self.init_gc()
-	    self.tk.call(self._w, 'motionhints')
-	    self.gc_initialized = 1
+        if not self.gc_initialized:
+            self.init_gc()
+            self.tk.call(self._w, 'motionhints')
+            self.gc_initialized = 1
 
     def DestroyMethod(self):
-	if self.context_menu is not None:
-	    self.context_menu.clean_up()
-	self.context_menu = None
-	PyWidget.DestroyMethod(self)
+        if self.context_menu is not None:
+            self.context_menu.clean_up()
+        self.context_menu = None
+        PyWidget.DestroyMethod(self)
 
     def init_gc(self):
-	self.gc = self.tkwin.GetGC()
-	self.visual = color.skvisual
-	w = self.tkwin
-	width, height = self.image.size
-	depth = self.visual.depth
-	if depth > 16:
-	    bpl = 4 * width
-	elif depth > 8:
-	    bpl = ((2 * width + 3) / 4) * 4
-	elif depth == 8:
-	    bpl = ((width + 3) / 4) * 4
-	else:
-	    raise SketchError('unsupported depth for images')
-	self.ximage = w.CreateImage(depth, X.ZPixmap, 0, None, width, height,
-				    32, bpl)
-	self.set_image(self.image)
+        self.gc = self.tkwin.GetGC()
+        self.visual = color.skvisual
+        w = self.tkwin
+        width, height = self.image.size
+        depth = self.visual.depth
+        if depth > 16:
+            bpl = 4 * width
+        elif depth > 8:
+            bpl = ((2 * width + 3) / 4) * 4
+        elif depth == 8:
+            bpl = ((width + 3) / 4) * 4
+        else:
+            raise SketchError('unsupported depth for images')
+        self.ximage = w.CreateImage(depth, X.ZPixmap, 0, None, width, height,
+                                    32, bpl)
+        self.set_image(self.image)
 
     def set_image(self, image):
-	self.image = image
-	if self.ximage:
-	    ximage = self.ximage
-	    _sketch.copy_image_to_ximage(self.visual, image.im, ximage,
-					 0, 0, ximage.width, ximage.height)
-	    self.UpdateWhenIdle()
+        self.image = image
+        if self.ximage:
+            ximage = self.ximage
+            _sketch.copy_image_to_ximage(self.visual, image.im, ximage,
+                                         0, 0, ximage.width, ximage.height)
+            self.UpdateWhenIdle()
 
     def ResizedMethod(self, width, height):
-	pass
+        pass
 
     def set_gradient(self, gradient):
-	gradient = gradient.Colors()
-	self.gradient = []
-	for pos, color in gradient:
-	    self.gradient.append((pos, tuple(color)))
+        gradient = gradient.Colors()
+        self.gradient = []
+        for pos, color in gradient:
+            self.gradient.append((pos, tuple(color)))
 
     def reverse(self):
-	for i in range(len(self.gradient)):
-	    self.gradient[i]=(1 - self.gradient[i][0], self.gradient[i][1])
-	self.gradient.reverse()
-	self.UpdateWhenIdle()
+        for i in range(len(self.gradient)):
+            self.gradient[i]=(1 - self.gradient[i][0], self.gradient[i][1])
+        self.gradient.reverse()
+        self.UpdateWhenIdle()
 
     def x_to_idx(self, x):
-	width = self.ximage.width
-	w2 = handle_height / 2
-	orig_x = self.orig_x
-	for i in range(len(self.gradient)):
-	    if abs(x - orig_x - self.gradient[i][0] * width) < w2:
-		return i
-	return -1
+        width = self.ximage.width
+        w2 = handle_height / 2
+        orig_x = self.orig_x
+        for i in range(len(self.gradient)):
+            if abs(x - orig_x - self.gradient[i][0] * width) < w2:
+                return i
+        return -1
 
     def ButtonPressEvent(self, event):
-	if not self.dragging:
-	    self.drag_idx = self.x_to_idx(event.x)
-	    if self.drag_idx < 0:
-		return
-	    if self.drag_idx == 0:
-		self.gradient.insert(0, self.gradient[0])
-		self.drag_idx = self.drag_idx + 1
-	    if self.drag_idx == len(self.gradient) - 1:
-		self.gradient.append(self.gradient[-1])
-	    self.drag_start = event.x, self.gradient[self.drag_idx][0]
-	    if self.drag_idx > 0:
-		self.drag_min = self.gradient[self.drag_idx - 1][0]
-	    else:
-		self.drag_min = 0.0
-	    if self.drag_idx < len(self.gradient) - 1:
-		self.drag_max = self.gradient[self.drag_idx + 1][0]
-	    else:
-		self.drag_max = 1.0
+        if not self.dragging:
+            self.drag_idx = self.x_to_idx(event.x)
+            if self.drag_idx < 0:
+                return
+            if self.drag_idx == 0:
+                self.gradient.insert(0, self.gradient[0])
+                self.drag_idx = self.drag_idx + 1
+            if self.drag_idx == len(self.gradient) - 1:
+                self.gradient.append(self.gradient[-1])
+            self.drag_start = event.x, self.gradient[self.drag_idx][0]
+            if self.drag_idx > 0:
+                self.drag_min = self.gradient[self.drag_idx - 1][0]
+            else:
+                self.drag_min = 0.0
+            if self.drag_idx < len(self.gradient) - 1:
+                self.drag_max = self.gradient[self.drag_idx + 1][0]
+            else:
+                self.drag_max = 1.0
 
-	self.dragging = self.dragging + 1
+        self.dragging = self.dragging + 1
 
     def ButtonReleaseEvent(self, event):
-	if self.dragging:
-	    self.dragging = self.dragging - 1
-	    self.move_to(event.x)
-	    if self.drag_idx == 1 and \
-	       self.gradient[0][0] == self.gradient[1][0]:
-		    del self.gradient[0]
-	    elif self.drag_idx == len(self.gradient) - 2 and \
-		 self.gradient[-1][0] == self.gradient[-2][0]:
-		    del self.gradient[-1]
+        if self.dragging:
+            self.dragging = self.dragging - 1
+            self.move_to(event.x)
+            if self.drag_idx == 1 and \
+               self.gradient[0][0] == self.gradient[1][0]:
+                del self.gradient[0]
+            elif self.drag_idx == len(self.gradient) - 2 and \
+                 self.gradient[-1][0] == self.gradient[-2][0]:
+                del self.gradient[-1]
 
     def PointerMotionEvent(self, event):
-	if self.dragging:
-	    x = self.tkwin.QueryPointer()[4]
-	    self.move_to(x)
+        if self.dragging:
+            x = self.tkwin.QueryPointer()[4]
+            self.move_to(x)
 
     def move_to(self, x):
-	start_x, start_pos = self.drag_start
-	pos = x - start_x + start_pos * self.ximage.width
-	pos = float(pos) / self.ximage.width
-	if pos < self.drag_min:
-	    pos = self.drag_min
-	if pos > self.drag_max:
-	    pos = self.drag_max
-	color = self.gradient[self.drag_idx][-1]
-	self.gradient[self.drag_idx] = (pos, color)
-	self.UpdateWhenIdle()
+        start_x, start_pos = self.drag_start
+        pos = x - start_x + start_pos * self.ximage.width
+        pos = float(pos) / self.ximage.width
+        if pos < self.drag_min:
+            pos = self.drag_min
+        if pos > self.drag_max:
+            pos = self.drag_max
+        color = self.gradient[self.drag_idx][-1]
+        self.gradient[self.drag_idx] = (pos, color)
+        self.UpdateWhenIdle()
 
     def PopupContextMenu(self, event):
-	self.context_idx = self.x_to_idx(event.x)
-	self.context_pos = (event.x - self.orig_x) / float(self.ximage.width)
-	if self.context_menu is None:
-	    items = [MenuCommand(_("Set Handle Color"), self.set_handle_color,
-				 sensitivecb = self.can_set_handle_color),
-		     MenuCommand(_("Delete Handle"), self.delete_handle,
-				 sensitivecb = self.can_delete_handle),
-		     MenuCommand(_("Insert Handle"), self.insert_handle,
-				 sensitivecb = self.can_insert_handle)]
-	    self.context_menu = UpdatedMenu(self, items)
-	self.context_menu.Popup(event.x_root, event.y_root)
+        self.context_idx = self.x_to_idx(event.x)
+        self.context_pos = (event.x - self.orig_x) / float(self.ximage.width)
+        if self.context_menu is None:
+            items = [MenuCommand(_("Set Handle Color"), self.set_handle_color,
+                                 sensitivecb = self.can_set_handle_color),
+                     MenuCommand(_("Delete Handle"), self.delete_handle,
+                                 sensitivecb = self.can_delete_handle),
+                     MenuCommand(_("Insert Handle"), self.insert_handle,
+                                 sensitivecb = self.can_insert_handle)]
+            self.context_menu = UpdatedMenu(self, items)
+        self.context_menu.Popup(event.x_root, event.y_root)
 
     def delete_handle(self):
-	if 0 < self.context_idx < len(self.gradient) - 1:
-	    del self.gradient[self.context_idx]
-	    self.UpdateWhenIdle()
+        if 0 < self.context_idx < len(self.gradient) - 1:
+            del self.gradient[self.context_idx]
+            self.UpdateWhenIdle()
 
     def can_delete_handle(self):
-	return 0 < self.context_idx < len(self.gradient) - 1
+        return 0 < self.context_idx < len(self.gradient) - 1
 
     def insert_handle(self):
-	gradient = self.gradient
-	pos = self.context_pos
-	if 0.0 <= pos <= 1.0:
-	    for i in range(len(gradient) - 1):
-		if gradient[i][0] < pos < gradient[i + 1][0]:
-		    p1, c1 = gradient[i]
-		    p2, c2 = gradient[i + 1]
-		    color = Blend(apply(CreateRGBColor, c2),
-				  apply(CreateRGBColor, c1),
-				  (pos - p1) / (p2 - p1))
-		    gradient.insert(i + 1, (pos, tuple(color)))
-		    self.UpdateWhenIdle()
-		    break
+        gradient = self.gradient
+        pos = self.context_pos
+        if 0.0 <= pos <= 1.0:
+            for i in range(len(gradient) - 1):
+                if gradient[i][0] < pos < gradient[i + 1][0]:
+                    p1, c1 = gradient[i]
+                    p2, c2 = gradient[i + 1]
+                    color = Blend(apply(CreateRGBColor, c2),
+                                  apply(CreateRGBColor, c1),
+                                  (pos - p1) / (p2 - p1))
+                    gradient.insert(i + 1, (pos, tuple(color)))
+                    self.UpdateWhenIdle()
+                    break
 
     def can_insert_handle(self):
-	return self.context_idx < 0 and 0.0 <= self.context_pos <= 1.0
+        return self.context_idx < 0 and 0.0 <= self.context_pos <= 1.0
 
     def set_handle_color(self):
-	if self.context_idx >= 0:
-	    pos, color = self.gradient[self.context_idx]
+        if self.context_idx >= 0:
+            pos, color = self.gradient[self.context_idx]
             color = GetColor(self, apply(CreateRGBColor, color))
             if color is not None:
                 self.gradient[self.context_idx] = (pos, tuple(color))
                 self.UpdateWhenIdle()
 
     def can_set_handle_color(self):
-	return self.context_idx >= 0
+        return self.context_idx >= 0
 
     def update_gradient(self):
-	_sketch.fill_axial_gradient(self.image.im, self.gradient,
-				    0, 0, self.image.size[0] - 1, 0)
-	self.set_image(self.image)
+        _sketch.fill_axial_gradient(self.image.im, self.gradient,
+                                    0, 0, self.image.size[0] - 1, 0)
+        self.set_image(self.image)
 
     def UpdateWhenIdle(self):
-	if not self.update_pending:
-	    self.update_pending = 1
-	    PyWidget.UpdateWhenIdle(self)
+        if not self.update_pending:
+            self.update_pending = 1
+            PyWidget.UpdateWhenIdle(self)
 
     def RedrawMethod(self, region = None):
-	if self.update_pending:
-	    self.update_gradient()
-	    self.update_pending = 0
-	pixmap = self.tkwin.CreatePixmap()
-	width = self.ximage.width
-	height = self.ximage.height
-	startx = handle_height / 2
-	self.gc.SetDrawable(pixmap)
-	self.tkborder.Fill3DRectangle(pixmap, 0, 0,
-				      self.tkwin.width, self.tkwin.height,
-				      0, pax.TK_RELIEF_FLAT)
-	self.gc.PutImage(self.ximage, 0, 0, startx, 0, width, height)
+        if self.update_pending:
+            self.update_gradient()
+            self.update_pending = 0
+        pixmap = self.tkwin.CreatePixmap()
+        width = self.ximage.width
+        height = self.ximage.height
+        startx = handle_height / 2
+        self.gc.SetDrawable(pixmap)
+        self.tkborder.Fill3DRectangle(pixmap, 0, 0,
+                                      self.tkwin.width, self.tkwin.height,
+                                      0, pax.TK_RELIEF_FLAT)
+        self.gc.PutImage(self.ximage, 0, 0, startx, 0, width, height)
 
-	border = self.tkborder
-	win = self.tkwin
-	w2 = handle_height / 2
-	bot = handle_height + height
-	for pos in self.gradient:
-	    pos = pos[0]
-	    x = int(pos * width) + startx
-	    poly = [(x - w2, bot), (x, height), (x + w2, bot)]
-	    border.Draw3DPolygon(pixmap, poly, -2, pax.TK_RELIEF_SUNKEN)
+        border = self.tkborder
+        win = self.tkwin
+        w2 = handle_height / 2
+        bot = handle_height + height
+        for pos in self.gradient:
+            pos = pos[0]
+            x = int(pos * width) + startx
+            poly = [(x - w2, bot), (x, height), (x + w2, bot)]
+            border.Draw3DPolygon(pixmap, poly, -2, pax.TK_RELIEF_SUNKEN)
 
-	self.gc.SetDrawable(self.tkwin)
-	pixmap.CopyArea(self.tkwin, self.gc, 0, 0,
-			self.tkwin.width, self.tkwin.height, 0, 0)
+        self.gc.SetDrawable(self.tkwin)
+        pixmap.CopyArea(self.tkwin, self.gc, 0, 0,
+                        self.tkwin.width, self.tkwin.height, 0, 0)
 
     def DropAt(self, x, y, what, data):
-	if what == DROP_COLOR:
-	    idx = self.x_to_idx(x)
-	    if idx >= 0:
-		pos, color = self.gradient[idx]
-		self.gradient[idx] = (pos, tuple(data))
-		self.UpdateWhenIdle()
+        if what == DROP_COLOR:
+            idx = self.x_to_idx(x)
+            if idx >= 0:
+                pos, color = self.gradient[idx]
+                self.gradient[idx] = (pos, tuple(data))
+                self.UpdateWhenIdle()
 
     def GetGradient(self):
-	result = []
-	for pos, color in self.gradient:
-	    result.append((pos, apply(CreateRGBColor, color)))
-	return MultiGradient(result)
+        result = []
+        for pos, color in self.gradient:
+            result.append((pos, apply(CreateRGBColor, color)))
+        return MultiGradient(result)
 
 
 
@@ -293,31 +293,31 @@
     title = _("Edit Gradient")
 
     def __init__(self, master, gradient, **kw):
-	self.gradient = gradient
-	apply(SKModal.__init__, (self, master), kw)
+        self.gradient = gradient
+        apply(SKModal.__init__, (self, master), kw)
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	frame = Frame(top)
-	frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
-	button = Button(frame, text = _("Reverse"), command = self.reverse)
-	button.pack(side = LEFT, expand = 1)
-	button = Button(frame, text = _("OK"), command = self.ok)
-	button.pack(side = LEFT, expand = 1)
-	button = Button(frame, text = _("Cancel"), command = self.cancel)
-	button.pack(side = RIGHT, expand = 1)
+        frame = Frame(top)
+        frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
+        button = Button(frame, text = _("Reverse"), command = self.reverse)
+        button.pack(side = LEFT, expand = 1)
+        button = Button(frame, text = _("OK"), command = self.ok)
+        button.pack(side = LEFT, expand = 1)
+        button = Button(frame, text = _("Cancel"), command = self.cancel)
+        button.pack(side = RIGHT, expand = 1)
 
-	view = GradientView(top, gradient_size[0], gradient_size[1],
-			    self.gradient)
-	view.pack(side = LEFT)
-	self.gradient_view = view
+        view = GradientView(top, gradient_size[0], gradient_size[1],
+                            self.gradient)
+        view.pack(side = LEFT)
+        self.gradient_view = view
 
     def reverse(self, *args):
-	self.gradient_view.reverse()
+        self.gradient_view.reverse()
 
     def ok(self, *args):
-	self.close_dlg(self.gradient_view.GetGradient())
+        self.close_dlg(self.gradient_view.GetGradient())
 
 
 def EditGradient(master, gradient):

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/griddlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/griddlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/griddlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -35,54 +35,54 @@
     receivers = SketchPanel.receivers[:]
 
     def __init__(self, master, canvas, doc):
-	SketchPanel.__init__(self, master, canvas, doc)
+        SketchPanel.__init__(self, master, canvas, doc)
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	button_frame = self.create_std_buttons(top)
-	button_frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
+        button_frame = self.create_std_buttons(top)
+        button_frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
 
-	do_apply = self.do_apply
+        do_apply = self.do_apply
 
-	frame = Frame(top)
-	frame.pack(side = TOP, fill = X, expand = 1, ipady = 2)
+        frame = Frame(top)
+        frame.pack(side = TOP, fill = X, expand = 1, ipady = 2)
 
-	label = Label(frame, text = _("Origin:"), anchor = E)
-	label.grid(row = 0, column = 0, sticky = 'E')
-	f = Frame(frame)
-	self.var_xorig = create_length_entry(top, f, do_apply)
-	f.grid(row = 0, column = 1)
-	label = Label(frame, text = ',', width = 1)
-	label.grid(row = 0, column = 2)
-	f = Frame(frame)
-	self.var_yorig = create_length_entry(top, f, do_apply)
-	f.grid(row = 0, column = 3)
+        label = Label(frame, text = _("Origin:"), anchor = E)
+        label.grid(row = 0, column = 0, sticky = 'E')
+        f = Frame(frame)
+        self.var_xorig = create_length_entry(top, f, do_apply)
+        f.grid(row = 0, column = 1)
+        label = Label(frame, text = ',', width = 1)
+        label.grid(row = 0, column = 2)
+        f = Frame(frame)
+        self.var_yorig = create_length_entry(top, f, do_apply)
+        f.grid(row = 0, column = 3)
 
-	label = Label(frame, text = _("Widths:"), anchor = E)
-	label.grid(row = 1, column = 0, sticky = 'E')
-	f = Frame(frame)
-	self.var_xwidth = create_length_entry(top, f, do_apply)
-	f.grid(row = 1, column = 1)
-	label = Label(frame, text = 'x', width = 1)
-	label.grid(row = 1, column = 2)
-	f = Frame(frame)
-	self.var_ywidth = create_length_entry(top, f, do_apply)
-	f.grid(row = 1, column = 3)
+        label = Label(frame, text = _("Widths:"), anchor = E)
+        label.grid(row = 1, column = 0, sticky = 'E')
+        f = Frame(frame)
+        self.var_xwidth = create_length_entry(top, f, do_apply)
+        f.grid(row = 1, column = 1)
+        label = Label(frame, text = 'x', width = 1)
+        label.grid(row = 1, column = 2)
+        f = Frame(frame)
+        self.var_ywidth = create_length_entry(top, f, do_apply)
+        f.grid(row = 1, column = 3)
 
     def init_from_doc(self):
-	xorig, yorig, xwidth, ywidth = self.document.Grid().Geometry()
-	self.var_xorig.set(xorig)
-	self.var_yorig.set(yorig)
-	self.var_xwidth.set(xwidth)
-	self.var_ywidth.set(ywidth)
+        xorig, yorig, xwidth, ywidth = self.document.Grid().Geometry()
+        self.var_xorig.set(xorig)
+        self.var_yorig.set(yorig)
+        self.var_xwidth.set(xwidth)
+        self.var_ywidth.set(ywidth)
 
     receivers.append((GRID, 'init_from_doc'))
 
     def do_apply(self, *rest):
-	self.document.SetGridGeometry((self.var_xorig.get(),
-				       self.var_yorig.get(),
-				       self.var_xwidth.get(),
-				       self.var_ywidth.get()))
+        self.document.SetGridGeometry((self.var_xorig.get(),
+                                       self.var_yorig.get(),
+                                       self.var_xwidth.get(),
+                                       self.var_ywidth.get()))
 
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/guidedlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/guidedlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/guidedlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -40,120 +40,120 @@
     receivers = SketchPanel.receivers[:]
 
     def __init__(self, master, canvas, doc):
-	SketchPanel.__init__(self, master, canvas, doc, name = 'guidedlg')
+        SketchPanel.__init__(self, master, canvas, doc, name = 'guidedlg')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	var_number = DoubleVar(top)
-	var_unit = StringVar(top)
-	self.var_pos = LengthVar(1.0, config.preferences.default_unit,
+        var_number = DoubleVar(top)
+        var_unit = StringVar(top)
+        self.var_pos = LengthVar(1.0, config.preferences.default_unit,
                                  var_number, var_unit, command = self.set_pos)
-	pos_frame = Frame(top)
-	pos_frame.pack(side = TOP, fill = X, expand = 0)
-	self.var_label = StringVar(top)
-	self.var_label.set('X:')
-	label = Label(pos_frame, textvariable = self.var_label)
-	label.pack(side = LEFT, expand = 1, anchor = E)
-	entry = MyEntry(pos_frame, textvariable = var_number,
-			justify = RIGHT, width = 4,
-			command = self.var_pos.UpdateNumber)
-	entry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
-	scroll = MiniScroller(pos_frame, variable = var_number,
-			      min = 0, max = None, step = 1)
-	scroll.pack(side = LEFT, fill = Y)
-	optmenu = create_unit_menu(pos_frame, self.set_unit,
-				   variable = var_unit,
-				   indicatoron = 0, width = 3)
-	optmenu.pack(side = LEFT, expand = 1, fill = X, anchor = W)
+        pos_frame = Frame(top)
+        pos_frame.pack(side = TOP, fill = X, expand = 0)
+        self.var_label = StringVar(top)
+        self.var_label.set('X:')
+        label = Label(pos_frame, textvariable = self.var_label)
+        label.pack(side = LEFT, expand = 1, anchor = E)
+        entry = MyEntry(pos_frame, textvariable = var_number,
+                        justify = RIGHT, width = 4,
+                        command = self.var_pos.UpdateNumber)
+        entry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
+        scroll = MiniScroller(pos_frame, variable = var_number,
+                              min = 0, max = None, step = 1)
+        scroll.pack(side = LEFT, fill = Y)
+        optmenu = create_unit_menu(pos_frame, self.set_unit,
+                                   variable = var_unit,
+                                   indicatoron = 0, width = 3)
+        optmenu.pack(side = LEFT, expand = 1, fill = X, anchor = W)
 
-	list_frame = Frame(top)
-	list_frame.pack(side = TOP, expand = 1, fill = BOTH)
+        list_frame = Frame(top)
+        list_frame.pack(side = TOP, expand = 1, fill = BOTH)
 
-	sb_vert = Scrollbar(list_frame, takefocus = 0)
-	sb_vert.pack(side = RIGHT, fill = Y)
-	guides = UpdatedListbox(list_frame, name = 'list')
-	guides.pack(expand = 1, fill = BOTH)
-	guides.Subscribe(SELECTION, self.select_guide)
-	sb_vert['command'] = (guides, 'yview')
-	guides['yscrollcommand'] = (sb_vert, 'set')
-	self.guides = guides
-	self.selected = None
+        sb_vert = Scrollbar(list_frame, takefocus = 0)
+        sb_vert.pack(side = RIGHT, fill = Y)
+        guides = UpdatedListbox(list_frame, name = 'list')
+        guides.pack(expand = 1, fill = BOTH)
+        guides.Subscribe(SELECTION, self.select_guide)
+        sb_vert['command'] = (guides, 'yview')
+        guides['yscrollcommand'] = (sb_vert, 'set')
+        self.guides = guides
+        self.selected = None
 
-	frame = Frame(top)
-	frame.pack(side = BOTTOM, fill = X)
-	button = UpdatedButton(frame, text = _("Add H"),
-			       command = self.add_guide, args = 1)
-	button.pack(side = LEFT)
-	button = UpdatedButton(frame, text = _("Add V"),
-			       command = self.add_guide, args = 0)
-	button.pack(side = LEFT)
-	button = UpdatedButton(frame, text = _("Delete"),
-			       command = self.del_guide)
-	button.pack(side = LEFT)
-	button = UpdatedButton(frame, text = _("Close"),
-			       command = self.close_dlg)
-	button.pack(side = RIGHT)
+        frame = Frame(top)
+        frame.pack(side = BOTTOM, fill = X)
+        button = UpdatedButton(frame, text = _("Add H"),
+                               command = self.add_guide, args = 1)
+        button.pack(side = LEFT)
+        button = UpdatedButton(frame, text = _("Add V"),
+                               command = self.add_guide, args = 0)
+        button.pack(side = LEFT)
+        button = UpdatedButton(frame, text = _("Delete"),
+                               command = self.del_guide)
+        button.pack(side = LEFT)
+        button = UpdatedButton(frame, text = _("Close"),
+                               command = self.close_dlg)
+        button.pack(side = RIGHT)
 
     def set_unit(self, *rest):
-	apply(self.var_pos.UpdateUnit, rest)
-	self.update_list()
+        apply(self.var_pos.UpdateUnit, rest)
+        self.update_list()
 
     receivers.append((GUIDE_LINES, 'init_from_doc'))
     def init_from_doc(self, *rest):
-	self.guide_lines = self.document.GuideLines()
-	self.guide_lines.reverse()
-	self.update_list()
+        self.guide_lines = self.document.GuideLines()
+        self.guide_lines.reverse()
+        self.update_list()
 
     def update_list(self):
-	strings = []
-	factor = self.var_pos.Factor()
-	unit = self.var_pos.UnitName()
-	if unit in ('in', 'cm'):
-	    prec = 2
-	else:
-	    prec = 1
-	for line in self.guide_lines:
-	    pos, horizontal = line.Coordinates()
-	    if horizontal:
-		format = _("% 6.*f %s    horizontal")
-	    else:
-		format = _("% 6.*f %s    vertical")
-	    strings.append(format % (prec, pos / factor, unit))
-	self.guides.SetList(strings)
-	self.select_index(self.selected)
+        strings = []
+        factor = self.var_pos.Factor()
+        unit = self.var_pos.UnitName()
+        if unit in ('in', 'cm'):
+            prec = 2
+        else:
+            prec = 1
+        for line in self.guide_lines:
+            pos, horizontal = line.Coordinates()
+            if horizontal:
+                format = _("% 6.*f %s    horizontal")
+            else:
+                format = _("% 6.*f %s    vertical")
+            strings.append(format % (prec, pos / factor, unit))
+        self.guides.SetList(strings)
+        self.select_index(self.selected)
 
     def select_index(self, index):
-	if index is not None and index < len(self.guide_lines):
-	    self.guides.Select(index)
-	    self.select_guide()
-	else:
-	    self.selected = None
+        if index is not None and index < len(self.guide_lines):
+            self.guides.Select(index)
+            self.select_guide()
+        else:
+            self.selected = None
 
     def set_pos(self, *rest):
-	if self.selected is not None:
-	    self.document.MoveGuideLine(self.guide_lines[self.selected],
-					self.var_pos.get())
+        if self.selected is not None:
+            self.document.MoveGuideLine(self.guide_lines[self.selected],
+                                        self.var_pos.get())
 
     def select_guide(self, *rest):
-	sel = self.guides.curselection()
-	if sel:
-	    self.selected = atoi(sel[0])
-	    pos, horizontal = self.guide_lines[self.selected].Coordinates()
-	    self.var_pos.set(pos)
-	    if horizontal:
-		self.var_label.set(_("Y:"))
-	    else:
-		self.var_label.set(_("X:"))
-	else:
-	    self.selected = None
+        sel = self.guides.curselection()
+        if sel:
+            self.selected = atoi(sel[0])
+            pos, horizontal = self.guide_lines[self.selected].Coordinates()
+            self.var_pos.set(pos)
+            if horizontal:
+                self.var_label.set(_("Y:"))
+            else:
+                self.var_label.set(_("X:"))
+        else:
+            self.selected = None
 
     def del_guide(self, *rest):
-	if self.selected is not None:
-	    line = self.guide_lines[self.selected]
-	    self.document.RemoveGuideLine(line)
+        if self.selected is not None:
+            line = self.guide_lines[self.selected]
+            self.document.RemoveGuideLine(line)
 
     def add_guide(self, horizontal):
-	length = len(self.guide_lines)
-	self.document.AddGuideLine(Point(0, 0), horizontal)
-	self.select_index(length)
+        length = len(self.guide_lines)
+        self.document.AddGuideLine(Point(0, 0), horizontal)
+        self.select_index(length)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/layerdlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/layerdlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/layerdlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -35,95 +35,95 @@
 class MutableNumber:
 
     def __init__(self, value = 0):
-	self.value = value
+        self.value = value
 
     def SetValue(self, value):
-	self.value = value
+        self.value = value
 
     def __int__(self):
-	return int(self.value)
+        return int(self.value)
 
     def __str__(self):
-	return str(self.value)
+        return str(self.value)
 
     def __repr__(self):
-	return `self.value`
+        return `self.value`
 
 class LayerInfo:
 
     def __init__(self, frame, idx, info, active_var, rename, set_active_layer,
-		 set_layer_state, set_color, context_menu):
-	self.index = MutableNumber()
-	self.active_var = active_var
-	self.create_widgets(frame, idx, set_active_layer, rename,
-			    set_layer_state, set_color, context_menu)
-	if info:
-	    self.SetInfo(info)
+                 set_layer_state, set_color, context_menu):
+        self.index = MutableNumber()
+        self.active_var = active_var
+        self.create_widgets(frame, idx, set_active_layer, rename,
+                            set_layer_state, set_color, context_menu)
+        if info:
+            self.SetInfo(info)
 
     def create_widgets(self, frame, idx, set_active_layer, rename,
-		       set_layer_state, set_color, context_menu):
-	self.index.SetValue(idx)
-	idx = (self.index,)
-	self.button = UpdatedRadiobutton(frame, anchor = W, value = idx,
-					 width = 10,
-					 variable = self.active_var,
-					 command = set_active_layer)
-	self.button.bind('<ButtonPress-3>', context_menu)
-	self.button.bind('<ButtonPress-2>', rename)
-	self.button.bind('<Double-Button-1>', rename)
-	self.var_visible = IntVar(frame)
-	self.visible = UpdatedCheckbutton(frame, variable = self.var_visible,
-					  indicatoron = 0, selectcolor = '',
-					  command = set_layer_state,
-					  args = idx)
-	self.var_printable = IntVar(frame)
-	self.printable = UpdatedCheckbutton(frame,
-					    variable = self.var_printable,
-					    indicatoron = 0, selectcolor = '',
-					    command = set_layer_state,
-					    args = idx)
-	self.var_locked = IntVar(frame)
-	self.locked = UpdatedCheckbutton(frame, variable = self.var_locked,
-					 indicatoron = 0, selectcolor = '',
-					 command = set_layer_state, args = idx)
-	self.var_outlined = IntVar(frame)
-	self.outlined = UpdatedCheckbutton(frame, variable = self.var_outlined,
-					   indicatoron = 0, selectcolor = '',
-					   command = set_layer_state,
-					   args = idx)
-	self.color = ColorButton(frame, command = set_color, args = idx,
-				 width = 2,
-				 dialog_master =
-				 frame.master.master.master.master)
+                       set_layer_state, set_color, context_menu):
+        self.index.SetValue(idx)
+        idx = (self.index,)
+        self.button = UpdatedRadiobutton(frame, anchor = W, value = idx,
+                                         width = 10,
+                                         variable = self.active_var,
+                                         command = set_active_layer)
+        self.button.bind('<ButtonPress-3>', context_menu)
+        self.button.bind('<ButtonPress-2>', rename)
+        self.button.bind('<Double-Button-1>', rename)
+        self.var_visible = IntVar(frame)
+        self.visible = UpdatedCheckbutton(frame, variable = self.var_visible,
+                                          indicatoron = 0, selectcolor = '',
+                                          command = set_layer_state,
+                                          args = idx)
+        self.var_printable = IntVar(frame)
+        self.printable = UpdatedCheckbutton(frame,
+                                            variable = self.var_printable,
+                                            indicatoron = 0, selectcolor = '',
+                                            command = set_layer_state,
+                                            args = idx)
+        self.var_locked = IntVar(frame)
+        self.locked = UpdatedCheckbutton(frame, variable = self.var_locked,
+                                         indicatoron = 0, selectcolor = '',
+                                         command = set_layer_state, args = idx)
+        self.var_outlined = IntVar(frame)
+        self.outlined = UpdatedCheckbutton(frame, variable = self.var_outlined,
+                                           indicatoron = 0, selectcolor = '',
+                                           command = set_layer_state,
+                                           args = idx)
+        self.color = ColorButton(frame, command = set_color, args = idx,
+                                 width = 2,
+                                 dialog_master =
+                                 frame.master.master.master.master)
 
     def SetInfo(self, idx, info):
-	self.index.SetValue(idx)
-	p = pixmaps
-	#name, visible, printable, locked, outlined, color = info
-	self.button['text'] = info.Name()
+        self.index.SetValue(idx)
+        p = pixmaps
+        #name, visible, printable, locked, outlined, color = info
+        self.button['text'] = info.Name()
 
         visible = info.Visible()
-	self.var_visible.set(visible)
-	self.visible['bitmap'] = visible and p.MiniEyeOpen or p.MiniEyeClosed
+        self.var_visible.set(visible)
+        self.visible['bitmap'] = visible and p.MiniEyeOpen or p.MiniEyeClosed
 
         printable = info.Printable()
-	self.var_printable.set(printable)
-	self.printable['bitmap']= printable and p.MiniPrintOn or p.MiniPrintOff
+        self.var_printable.set(printable)
+        self.printable['bitmap']= printable and p.MiniPrintOn or p.MiniPrintOff
 
         locked = info.Locked()
-	self.var_locked.set(locked)
-	self.locked['bitmap'] = locked and p.MiniLockClosed or p.MiniLockOpen
+        self.var_locked.set(locked)
+        self.locked['bitmap'] = locked and p.MiniLockClosed or p.MiniLockOpen
 
         outlined = info.Outlined()
-	self.var_outlined.set(outlined)
-	bm = outlined and p.MiniOutlineOn or p.MiniOutlineOff
-	self.outlined['bitmap'] = bm
+        self.var_outlined.set(outlined)
+        bm = outlined and p.MiniOutlineOn or p.MiniOutlineOff
+        self.outlined['bitmap'] = bm
 
-	self.color.SetColor(info.OutlineColor())
+        self.color.SetColor(info.OutlineColor())
 
         if info.is_GridLayer:
             self.locked['state'] = self.outlined['state'] \
-                                   = self.printable['state'] = DISABLED
+                = self.printable['state'] = DISABLED
         else:
             self.locked['state'] = NORMAL
             if info.is_GuideLayer:
@@ -132,29 +132,29 @@
                 self.printable['state'] = self.outlined['state'] = NORMAL
 
     def PlaceWidgets(self, idx):
-	self.button.grid(row = idx, column = 0, sticky = 'NEWS')
-	self.visible.grid(row = idx, column = 1, sticky = 'NEWS')
-	self.printable.grid(row = idx, column = 2, sticky = 'NEWS')
-	self.locked.grid(row = idx, column = 3, sticky = 'NEWS')
-	self.outlined.grid(row = idx, column = 4, sticky = 'NEWS')
-	self.color.grid(row = idx, column = 5, sticky = 'NEWS')
+        self.button.grid(row = idx, column = 0, sticky = 'NEWS')
+        self.visible.grid(row = idx, column = 1, sticky = 'NEWS')
+        self.printable.grid(row = idx, column = 2, sticky = 'NEWS')
+        self.locked.grid(row = idx, column = 3, sticky = 'NEWS')
+        self.outlined.grid(row = idx, column = 4, sticky = 'NEWS')
+        self.color.grid(row = idx, column = 5, sticky = 'NEWS')
 
     def State(self):
-	return (self.var_visible.get(),
-		self.var_printable.get(),
-		self.var_locked.get(),
-		self.var_outlined.get())
+        return (self.var_visible.get(),
+                self.var_printable.get(),
+                self.var_locked.get(),
+                self.var_outlined.get())
 
     def Color(self):
-	return self.color.Color()
+        return self.color.Color()
 
     def Destroy(self):
-	self.button.destroy()
-	self.visible.destroy()
-	self.printable.destroy()
-	self.locked.destroy()
-	self.outlined.destroy()
-	self.color.destroy()
+        self.button.destroy()
+        self.visible.destroy()
+        self.printable.destroy()
+        self.locked.destroy()
+        self.outlined.destroy()
+        self.color.destroy()
 
 class LayerPanel(SketchPanel):
 
@@ -162,124 +162,124 @@
     receivers = SketchPanel.receivers[:]
 
     def __init__(self, master, main_window, doc):
-	self.info_list = []
-	SketchPanel.__init__(self, master, main_window, doc, name = 'layerdlg')
+        self.info_list = []
+        SketchPanel.__init__(self, master, main_window, doc, name = 'layerdlg')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	frame = Frame(top)
-	frame.pack(side = BOTTOM, fill = X)
-	button = UpdatedButton(frame, bitmap = pixmaps.LayerNew, name = 'new',
-			       command = self.new_layer)
-	button.pack(side = LEFT, fill = BOTH, expand = 1)
-	button = UpdatedButton(frame, bitmap = pixmaps.LayerUp, name = 'up',
-			       command = self.layer_up)
-	button.pack(side = LEFT, fill = BOTH, expand = 1)
-	button = UpdatedButton(frame, bitmap = pixmaps.LayerDown,
-			       name = 'down', command = self.layer_down)
-	button.pack(side = LEFT, fill = BOTH, expand = 1)
-	button = UpdatedButton(frame, text = _("Close"), name = 'close',
-			       command = self.close_dlg)
-	button.pack(side = LEFT, fill = BOTH, expand = 1)
+        frame = Frame(top)
+        frame.pack(side = BOTTOM, fill = X)
+        button = UpdatedButton(frame, bitmap = pixmaps.LayerNew, name = 'new',
+                               command = self.new_layer)
+        button.pack(side = LEFT, fill = BOTH, expand = 1)
+        button = UpdatedButton(frame, bitmap = pixmaps.LayerUp, name = 'up',
+                               command = self.layer_up)
+        button.pack(side = LEFT, fill = BOTH, expand = 1)
+        button = UpdatedButton(frame, bitmap = pixmaps.LayerDown,
+                               name = 'down', command = self.layer_down)
+        button.pack(side = LEFT, fill = BOTH, expand = 1)
+        button = UpdatedButton(frame, text = _("Close"), name = 'close',
+                               command = self.close_dlg)
+        button.pack(side = LEFT, fill = BOTH, expand = 1)
 
-	list_frame = Frame(top)
-	list_frame.pack(side = LEFT, expand = 1, fill = BOTH)
+        list_frame = Frame(top)
+        list_frame.pack(side = LEFT, expand = 1, fill = BOTH)
 
-	sb_vert = Scrollbar(list_frame, takefocus = 0)
-	sb_vert.pack(side = RIGHT, fill = Y)
+        sb_vert = Scrollbar(list_frame, takefocus = 0)
+        sb_vert.pack(side = RIGHT, fill = Y)
 
-	self.canvas = canvas = Canvas(list_frame)
-	canvas.pack(expand = 1, fill = BOTH)
+        self.canvas = canvas = Canvas(list_frame)
+        canvas.pack(expand = 1, fill = BOTH)
 
-	self.frame = frame = Frame(canvas, name = 'list')
-	canvas.create_window(0, 0, window = frame, anchor = NW)
-	sb_vert['command'] = (canvas, 'yview')
-	canvas['yscrollcommand'] = (sb_vert, 'set')
+        self.frame = frame = Frame(canvas, name = 'list')
+        canvas.create_window(0, 0, window = frame, anchor = NW)
+        sb_vert['command'] = (canvas, 'yview')
+        canvas['yscrollcommand'] = (sb_vert, 'set')
 
-	self.active_var = IntVar(top)
+        self.active_var = IntVar(top)
 
     def init_from_doc(self):
-	self.Update(LAYER_ORDER)
+        self.Update(LAYER_ORDER)
 
     receivers.append((LAYER, 'Update'))
     def Update(self, detail = '', *args):
-	if detail != LAYER_ACTIVE:
-	    if detail == LAYER_ORDER:
-		self.create_widget_list()
-	    else:
-		self.update_widgets()
-	self.update_active()
+        if detail != LAYER_ACTIVE:
+            if detail == LAYER_ORDER:
+                self.create_widget_list()
+            else:
+                self.update_widgets()
+        self.update_active()
 
     def create_widget_list(self):
-	frame = self.frame
-	set_active_layer = self.set_active_layer
-	set_layer_state = self.set_layer_state
-	set_color = self.set_color
-	context_menu = self.popup_context_menu
-	rows = self.info_list
-	layers = self.document.NumLayers()
-	if layers > len(rows):
-	    for idx in range(len(rows), layers):
-		row = LayerInfo(frame, idx, (), self.active_var,
-				self.rename_layer, set_active_layer,
-				set_layer_state, set_color, context_menu)
-		row.PlaceWidgets(idx)
-		rows.append(row)
-	elif layers < len(rows):
-	    for row in rows[layers:]:
-		row.Destroy()
-	    del rows[layers:]
-	self.update_widgets()
-	frame.update()
-	self.canvas['scrollregion'] = (0, 0, frame.winfo_reqwidth(),
-				       frame.winfo_reqheight())
-	self.canvas['width'] = frame.winfo_reqwidth()
+        frame = self.frame
+        set_active_layer = self.set_active_layer
+        set_layer_state = self.set_layer_state
+        set_color = self.set_color
+        context_menu = self.popup_context_menu
+        rows = self.info_list
+        layers = self.document.NumLayers()
+        if layers > len(rows):
+            for idx in range(len(rows), layers):
+                row = LayerInfo(frame, idx, (), self.active_var,
+                                self.rename_layer, set_active_layer,
+                                set_layer_state, set_color, context_menu)
+                row.PlaceWidgets(idx)
+                rows.append(row)
+        elif layers < len(rows):
+            for row in rows[layers:]:
+                row.Destroy()
+            del rows[layers:]
+        self.update_widgets()
+        frame.update()
+        self.canvas['scrollregion'] = (0, 0, frame.winfo_reqwidth(),
+                                       frame.winfo_reqheight())
+        self.canvas['width'] = frame.winfo_reqwidth()
 
     def update_widgets(self):
         layers = self.document.layers[:]
         layers.reverse()
-	for idx in range(len(layers)):
-	    self.info_list[idx].SetInfo(idx, layers[idx])
+        for idx in range(len(layers)):
+            self.info_list[idx].SetInfo(idx, layers[idx])
 
     def update_active(self):
-	idx = self.document.ActiveLayerIdx()
+        idx = self.document.ActiveLayerIdx()
         if idx is None:
             idx = -1
-	self.active_var.set(self.document.NumLayers() - 1 - idx)
+        self.active_var.set(self.document.NumLayers() - 1 - idx)
 
     def set_active_layer(self):
         idx = self.document.NumLayers() - self.active_var.get() - 1
-	self.document.SetActiveLayer(idx)
+        self.document.SetActiveLayer(idx)
 
     def set_layer_state(self, idx):
-	idx = int(idx)
-	row = self.info_list[idx]
-	idx = self.document.NumLayers() - idx - 1
-	state = row.State()
-	apply(self.document.SetLayerState, (idx,) + state)
+        idx = int(idx)
+        row = self.info_list[idx]
+        idx = self.document.NumLayers() - idx - 1
+        state = row.State()
+        apply(self.document.SetLayerState, (idx,) + state)
 
     def set_color(self, idx):
-	idx = int(idx)
-	row = self.info_list[idx]
-	idx = self.document.NumLayers() - idx - 1
-	self.document.SetLayerColor(idx, row.Color())
+        idx = int(idx)
+        row = self.info_list[idx]
+        idx = self.document.NumLayers() - idx - 1
+        self.document.SetLayerColor(idx, row.Color())
 
     def set_event_context(self, event):
-	for idx in range(len(self.info_list)):
-	    if self.info_list[idx].button == event.widget:
-		break
-	else:
-	    return
-	self.context_idx = self.document.NumLayers() - 1 - idx
-	self.context_layer = self.document.Layers()[self.context_idx]
+        for idx in range(len(self.info_list)):
+            if self.info_list[idx].button == event.widget:
+                break
+        else:
+            return
+        self.context_idx = self.document.NumLayers() - 1 - idx
+        self.context_layer = self.document.Layers()[self.context_idx]
 
     context_menu = None
     def popup_context_menu(self, event):
-	self.set_event_context(event)
-	if self.context_menu is None:
+        self.set_event_context(event)
+        if self.context_menu is None:
             self.context_menu = UpdatedMenu(self.frame, [], tearoff = 0,
-                                      auto_rebuild = self.build_context_menu)
+                                            auto_rebuild = self.build_context_menu)
         self.context_menu.Popup(event.x_root, event.y_root)
 
     def build_context_menu(self):
@@ -296,7 +296,7 @@
              self.is_not_locked),
             (_("Deselect All Children"), self.select_layer, SelectSubtract,
              self.is_not_locked)
-            ]
+        ]
         if self.context_layer.is_GuideLayer:
             entries.append(None)
             entries.append(self.main_window.commands.CreateGuideDialog)
@@ -306,57 +306,57 @@
         return map(MakeCommand, entries)
 
     def close_dlg(self):
-	SketchPanel.close_dlg(self)
-	if self.context_menu is not None:
-	    self.context_menu.destroy()
+        SketchPanel.close_dlg(self)
+        if self.context_menu is not None:
+            self.context_menu.destroy()
 
     def rename_layer(self, event = None):
-	if event is not None:
-	    self.set_event_context(event)
-	name = GetName(self.top, self.context_layer.Name())
-	if name != None:
-	    self.document.SetLayerName(self.context_idx, name)
+        if event is not None:
+            self.set_event_context(event)
+        name = GetName(self.top, self.context_layer.Name())
+        if name != None:
+            self.document.SetLayerName(self.context_idx, name)
 
     def delete_layer(self):
-	self.document.DeleteLayer(self.context_idx)
+        self.document.DeleteLayer(self.context_idx)
 
     def can_delete_layer(self):
-	return self.document.CanDeleteLayer(self.context_idx)
+        return self.document.CanDeleteLayer(self.context_idx)
 
     def new_layer(self):
-	self.document.NewLayer()
+        self.document.NewLayer()
 
     def layer_up(self, active_layer = 1):
-	if active_layer:
+        if active_layer:
             active_idx = self.active_var.get()
             if active_idx < 0:
                 return
-	    idx = self.document.NumLayers() - 1 - active_idx
-	else:
-	    idx = self.context_idx
-	self.document.MoveLayerUp(idx)
+            idx = self.document.NumLayers() - 1 - active_idx
+        else:
+            idx = self.context_idx
+        self.document.MoveLayerUp(idx)
 
     def layer_down(self, active_layer = 1):
-	if active_layer:
+        if active_layer:
             active_idx = self.active_var.get()
             if active_idx < 0:
                 return
-	    idx = self.document.NumLayers() - 1 - active_idx
-	else:
-	    idx = self.context_idx
-	self.document.MoveLayerDown(idx)
+            idx = self.document.NumLayers() - 1 - active_idx
+        else:
+            idx = self.context_idx
+        self.document.MoveLayerDown(idx)
 
     def move_selection_here(self):
-	self.document.MoveSelectionToLayer(self.context_idx)
+        self.document.MoveSelectionToLayer(self.context_idx)
 
     def can_move_selection(self):
-	return not self.context_layer.Locked() and self.document.HasSelection()
+        return not self.context_layer.Locked() and self.document.HasSelection()
 
     def is_not_locked(self):
-	return not self.context_layer.Locked()
+        return not self.context_layer.Locked()
 
     def select_layer(self, mode):
-	self.document.SelectLayer(self.context_idx, mode)
+        self.document.SelectLayer(self.context_idx, mode)
 
 
 
@@ -365,28 +365,28 @@
     title = _("Name")
 
     def __init__(self, master, name, **kw):
-	self.name = name
-	apply(SKModal.__init__, (self, master), kw)
+        self.name = name
+        apply(SKModal.__init__, (self, master), kw)
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	frame = Frame(top)
-	frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
-	button = Button(frame, text = _("OK"), command = self.ok)
-	button.pack(side = LEFT, expand = 1)
-	button = Button(frame, text = _("Cancel"), command = self.cancel)
-	button.pack(side = RIGHT, expand = 1)
+        frame = Frame(top)
+        frame.pack(side = BOTTOM, fill = BOTH, expand = 1)
+        button = Button(frame, text = _("OK"), command = self.ok)
+        button.pack(side = LEFT, expand = 1)
+        button = Button(frame, text = _("Cancel"), command = self.cancel)
+        button.pack(side = RIGHT, expand = 1)
 
-	self.label = Label(top, text = _("Name"))
-	self.label.pack(side = LEFT)
+        self.label = Label(top, text = _("Name"))
+        self.label.pack(side = LEFT)
 
-	self.entry = MyEntry(top, command = self.ok)
-	self.entry.pack(side = RIGHT, expand = 1, fill = X)
-	self.entry.SetText(self.name)
+        self.entry = MyEntry(top, command = self.ok)
+        self.entry.pack(side = RIGHT, expand = 1, fill = X)
+        self.entry.SetText(self.name)
 
     def ok(self, *args):
-	self.close_dlg(self.entry.get())
+        self.close_dlg(self.entry.get())
 
 def GetName(master, name):
     dlg = GetNameDlg(master, name)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/layoutdlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/layoutdlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/layoutdlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -37,140 +37,140 @@
     receivers = SketchPanel.receivers[:]
 
     def __init__(self, master, main_window, doc):
-	SketchPanel.__init__(self, master, main_window, doc,
-			     name = 'layoutdlg')
+        SketchPanel.__init__(self, master, main_window, doc,
+                             name = 'layoutdlg')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	format_frame = Frame(top)
-	format_frame.pack(side = TOP, expand = 1, fill = X,
-			  padx = 4, pady = 4)
-	format_label = Label(format_frame, text = _("Paper format:"))
-	format_label.pack(side = LEFT, expand = 1, fill = X)
+        format_frame = Frame(top)
+        format_frame.pack(side = TOP, expand = 1, fill = X,
+                          padx = 4, pady = 4)
+        format_label = Label(format_frame, text = _("Paper format:"))
+        format_label.pack(side = LEFT, expand = 1, fill = X)
 
-	format_names = map(lambda t: t[0], PapersizesList)
-	format_names.append(USER_SPECIFIC)
-	self.var_format_name = StringVar(top)
-	format_menu = MyOptionMenu(format_frame, format_names,
-				   variable = self.var_format_name,
-				   command = self.choose_format)
-	format_menu.configure(width = max(map(len, format_names)))
-	format_menu.pack(side = RIGHT, expand = 1, fill = X)
+        format_names = map(lambda t: t[0], PapersizesList)
+        format_names.append(USER_SPECIFIC)
+        self.var_format_name = StringVar(top)
+        format_menu = MyOptionMenu(format_frame, format_names,
+                                   variable = self.var_format_name,
+                                   command = self.choose_format)
+        format_menu.configure(width = max(map(len, format_names)))
+        format_menu.pack(side = RIGHT, expand = 1, fill = X)
 
-	orientation_frame = Frame(top)
-	orientation_frame.pack(side = TOP, expand = 1, fill = X)
-	self.var_orientation = IntVar(top)
-	radio = UpdatedRadiobutton(orientation_frame, text = _("Portrait"),
-				   variable = self.var_orientation,
-				   value = Portrait,
-				   command = self.choose_orientation)
-	radio.pack(side = LEFT, expand = 1, fill = X)
-	radio = UpdatedRadiobutton(orientation_frame, text = _("Landscape"),
-				   variable = self.var_orientation,
-				   value = Landscape,
-				   command = self.choose_orientation)
-	radio.pack(side = RIGHT, expand = 1, fill = X)
+        orientation_frame = Frame(top)
+        orientation_frame.pack(side = TOP, expand = 1, fill = X)
+        self.var_orientation = IntVar(top)
+        radio = UpdatedRadiobutton(orientation_frame, text = _("Portrait"),
+                                   variable = self.var_orientation,
+                                   value = Portrait,
+                                   command = self.choose_orientation)
+        radio.pack(side = LEFT, expand = 1, fill = X)
+        radio = UpdatedRadiobutton(orientation_frame, text = _("Landscape"),
+                                   variable = self.var_orientation,
+                                   value = Landscape,
+                                   command = self.choose_orientation)
+        radio.pack(side = RIGHT, expand = 1, fill = X)
 
-	size_frame = Frame(top)
-	size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4)
-	var_width_number = DoubleVar(top)
-	var_height_number = DoubleVar(top)
-	var_width_unit = StringVar(top)
-	var_height_unit = StringVar(top)
+        size_frame = Frame(top)
+        size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4)
+        var_width_number = DoubleVar(top)
+        var_height_number = DoubleVar(top)
+        var_width_unit = StringVar(top)
+        var_height_unit = StringVar(top)
         unit = config.preferences.default_unit
-	self.var_width = LengthVar(10, unit, var_width_number, var_width_unit)
-	self.var_height = LengthVar(10, unit,var_height_number,var_height_unit)
-	label = Label(size_frame, text = _("Page size:"))
-	label.pack(side = TOP, anchor = W)
-	label = Label(size_frame, text = _("Width"))
-	label.pack(side = LEFT, anchor = E)
-	self.widthentry = MyEntry(size_frame, textvariable = var_width_number,
-				  command = self.var_width.UpdateNumber,
-				  width = 6)
-	self.widthentry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
-	label = Label(size_frame, text = _("Height"))
-	label.pack(side = LEFT, anchor = E)
-	self.heightentry = MyEntry(size_frame, textvariable =var_height_number,
-				   command = self.var_height.UpdateNumber,
-				   width = 6)
-	self.heightentry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
+        self.var_width = LengthVar(10, unit, var_width_number, var_width_unit)
+        self.var_height = LengthVar(10, unit,var_height_number,var_height_unit)
+        label = Label(size_frame, text = _("Page size:"))
+        label.pack(side = TOP, anchor = W)
+        label = Label(size_frame, text = _("Width"))
+        label.pack(side = LEFT, anchor = E)
+        self.widthentry = MyEntry(size_frame, textvariable = var_width_number,
+                                  command = self.var_width.UpdateNumber,
+                                  width = 6)
+        self.widthentry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
+        label = Label(size_frame, text = _("Height"))
+        label.pack(side = LEFT, anchor = E)
+        self.heightentry = MyEntry(size_frame, textvariable =var_height_number,
+                                   command = self.var_height.UpdateNumber,
+                                   width = 6)
+        self.heightentry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
 
-	def CallBoth(arg, x = self.var_width, y = self.var_height):
-	    x.UpdateUnit(arg)
-	    y.UpdateUnit(arg)
+        def CallBoth(arg, x = self.var_width, y = self.var_height):
+            x.UpdateUnit(arg)
+            y.UpdateUnit(arg)
 
-	optmenu = create_unit_menu(size_frame, CallBoth,
-				   variable = var_width_unit,
-				   indicatoron = 0, width = 3)
-	optmenu.pack(side = LEFT, expand = 1, fill = X, anchor = W)
+        optmenu = create_unit_menu(size_frame, CallBoth,
+                                   variable = var_width_unit,
+                                   indicatoron = 0, width = 3)
+        optmenu.pack(side = LEFT, expand = 1, fill = X, anchor = W)
 
 
 
-	button_frame = Frame(top)
-	button_frame.pack(side = BOTTOM, fill = BOTH, expand = 1,
-			  padx = 4, pady = 4)
-	button = UpdatedButton(button_frame, text = _("Apply"),
-			       command = self.apply_settings)
-	button.pack(side = LEFT, expand = 1)
-	button = UpdatedButton(button_frame, text = _("Close"),
-			       command = self.close_dlg)
-	button.pack(side = RIGHT, expand = 1)
+        button_frame = Frame(top)
+        button_frame.pack(side = BOTTOM, fill = BOTH, expand = 1,
+                          padx = 4, pady = 4)
+        button = UpdatedButton(button_frame, text = _("Apply"),
+                               command = self.apply_settings)
+        button.pack(side = LEFT, expand = 1)
+        button = UpdatedButton(button_frame, text = _("Close"),
+                               command = self.close_dlg)
+        button.pack(side = RIGHT, expand = 1)
 
 
     def init_from_doc(self):
-	self.Update()
+        self.Update()
 
     def update_size_from_name(self, formatname):
-	width, height = Papersize[formatname]
-	if self.var_orientation.get() == Landscape:
-	    width, height = height, width
-	self.update_size(width, height)
+        width, height = Papersize[formatname]
+        if self.var_orientation.get() == Landscape:
+            width, height = height, width
+        self.update_size(width, height)
 
     def update_size(self, width, height):
-	self.var_width.set(width)
-	self.var_height.set(height)
+        self.var_width.set(width)
+        self.var_height.set(height)
 
     receivers.append((LAYOUT, 'Update'))
     def Update(self):
-	layout = self.document.Layout()
-	formatname = layout.FormatName()
-	self.var_orientation.set(layout.Orientation())
-	if formatname and formatname != USER_SPECIFIC:
-	    self.update_size_from_name(formatname)
-	else:
-	    formatname = USER_SPECIFIC
-	    self.update_size(layout.Width(), layout.Height())
-	self.var_format_name.set(formatname)
-	self.set_entry_sensitivity()
+        layout = self.document.Layout()
+        formatname = layout.FormatName()
+        self.var_orientation.set(layout.Orientation())
+        if formatname and formatname != USER_SPECIFIC:
+            self.update_size_from_name(formatname)
+        else:
+            formatname = USER_SPECIFIC
+            self.update_size(layout.Width(), layout.Height())
+        self.var_format_name.set(formatname)
+        self.set_entry_sensitivity()
 
     def set_entry_sensitivity(self):
-	formatname = self.var_format_name.get()
-	if formatname != USER_SPECIFIC:
-	    self.widthentry.config(state = DISABLED)
-	    self.heightentry.config(state = DISABLED)
-	else:
-	    self.widthentry.config(state = NORMAL)
-	    self.heightentry.config(state = NORMAL)
+        formatname = self.var_format_name.get()
+        if formatname != USER_SPECIFIC:
+            self.widthentry.config(state = DISABLED)
+            self.heightentry.config(state = DISABLED)
+        else:
+            self.widthentry.config(state = NORMAL)
+            self.heightentry.config(state = NORMAL)
 
     def choose_format(self, formatname):
-	self.var_format_name.set(formatname)
-	if formatname != USER_SPECIFIC:
-	    self.update_size_from_name(formatname)
-	self.set_entry_sensitivity()
+        self.var_format_name.set(formatname)
+        if formatname != USER_SPECIFIC:
+            self.update_size_from_name(formatname)
+        self.set_entry_sensitivity()
 
     def choose_orientation(self):
-	name = self.var_format_name.get()
-	if name != USER_SPECIFIC:
-	    self.update_size_from_name(name)
+        name = self.var_format_name.get()
+        if name != USER_SPECIFIC:
+            self.update_size_from_name(name)
 
     def apply_settings(self):
-	formatname = self.var_format_name.get()
-	if formatname == USER_SPECIFIC:
-	    layout = PageLayout(width = self.var_width.get(),
-				height = self.var_height.get(),
-				orientation = self.var_orientation.get())
-	else:
-	    layout = PageLayout(formatname,
-				orientation = self.var_orientation.get())
-	self.document.SetLayout(layout)
+        formatname = self.var_format_name.get()
+        if formatname == USER_SPECIFIC:
+            layout = PageLayout(width = self.var_width.get(),
+                                height = self.var_height.get(),
+                                orientation = self.var_orientation.get())
+        else:
+            layout = PageLayout(formatname,
+                                orientation = self.var_orientation.get())
+        self.document.SetLayout(layout)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/lengthvar.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/lengthvar.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/lengthvar.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -39,74 +39,74 @@
 class LengthVar:
 
     def __init__(self, length, unit, number_var = None, unit_var = None,
-		 command = None, args = (),
-		 precision = 2):
-	self.length = length
-	self.number_var = number_var
-	self.unit = unit
-	self.precision = 2
-	self.unit_var = unit_var
-	self.callback = command
-	if type(args) != TupleType:
-	    args = (args,)
-	self.args = args
-	self.set_vars()
+                 command = None, args = (),
+                 precision = 2):
+        self.length = length
+        self.number_var = number_var
+        self.unit = unit
+        self.precision = 2
+        self.unit_var = unit_var
+        self.callback = command
+        if type(args) != TupleType:
+            args = (args,)
+        self.args = args
+        self.set_vars()
 
     def __del__(self):
-	pass
+        pass
 
     def set_vars(self):
-	number = self.length / unit_dict[self.unit]
-	if self.number_var:
-	    self.number_var.set(round(number, self.precision))
-	if self.unit_var:
-	    self.unit_var.set(self.unit)
+        number = self.length / unit_dict[self.unit]
+        if self.number_var:
+            self.number_var.set(round(number, self.precision))
+        if self.unit_var:
+            self.unit_var.set(self.unit)
 
     def get(self):
-	try:
-	    number = self.number_var.get()
-	    self.length = number * unit_dict[self.unit]
-	except TclError:
-	    pass
-	return self.length
+        try:
+            number = self.number_var.get()
+            self.length = number * unit_dict[self.unit]
+        except TclError:
+            pass
+        return self.length
 
     def set(self, length):
-	self.length = length
-	self.set_vars()
+        self.length = length
+        self.set_vars()
 
     def UpdateUnit(self, unit = None):
-	if unit is None:
-	    self.unit = self.unit_var.get()
-	else:
-	    self.unit = unit
-	self.set_vars()
+        if unit is None:
+            self.unit = self.unit_var.get()
+        else:
+            self.unit = unit
+        self.set_vars()
 
     def UpdateNumber(self, number = None):
-	try:
-	    number = self.number_var.get()
-	except TclError:
-	    pass
-	self.length = number * unit_dict[self.unit]
-	self.set_vars()
-	self.call_callback()
+        try:
+            number = self.number_var.get()
+        except TclError:
+            pass
+        self.length = number * unit_dict[self.unit]
+        self.set_vars()
+        self.call_callback()
 
     def Factor(self):
-	return unit_dict[self.unit]
+        return unit_dict[self.unit]
 
     def UnitName(self):
-	return self.unit
+        return self.unit
 
     def call_callback(self):
-	if self.callback:
-	    apply(self.callback, (self.length,) + self.args)
+        if self.callback:
+            apply(self.callback, (self.length,) + self.args)
 
 
 
 
 def create_unit_menu(master, command, variable = None,
-		     **options):
+                     **options):
     optmenu = MyOptionMenu(master, unit_names, command = command,
-			   variable = variable)
+                           variable = variable)
     optmenu.configure(options)
     return optmenu
 
@@ -116,11 +116,11 @@
     var_length = LengthVar(1.0, config.preferences.default_unit, var_number,
                            var_unit, command = command)
     entry = MyEntry(master, textvariable = var_number, justify = RIGHT,
-		    width = 6, command = var_length.UpdateNumber)
+                    width = 6, command = var_length.UpdateNumber)
     scroll = MiniScroller(master, variable = var_number, min = 0, max = None,
-			  step = 1)
+                          step = 1)
     optmenu = create_unit_menu(master, var_length.UpdateUnit,
-			       variable = var_unit, indicatoron = 0, width = 3)
+                               variable = var_unit, indicatoron = 0, width = 3)
     return var_length, entry, scroll, optmenu
 
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/mainwindow.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -57,24 +57,24 @@
 def AddCmd(name, menu_name, method_name = None, **kw):
     kw['menu_name'] = menu_name
     if not method_name:
-	method_name = name
+        method_name = name
     cmd = apply(CommandClass, (name, method_name), kw)
     command_list.append(cmd)
 
 def AddDocCmd(name, menu_name, method_name = None, **kw):
     kw['menu_name'] = menu_name
     if not method_name:
-	method_name = name
+        method_name = name
     method_name = ('document', method_name)
     for key in CommandClass.callable_attributes:
-	if kw.has_key(key):
-	    value = kw[key]
-	    if type(value) == type(""):
-		kw[key] = ('document', value)
+        if kw.has_key(key):
+            value = kw[key]
+            if type(value) == type(""):
+                kw[key] = ('document', value)
     if not kw.has_key('subscribe_to'):
-	kw['subscribe_to'] = SELECTION
+        kw['subscribe_to'] = SELECTION
     if not kw.has_key('sensitive_cb'):
-	kw['sensitive_cb'] = ('document', 'HasSelection')
+        kw['sensitive_cb'] = ('document', 'HasSelection')
     cmd = apply(CommandClass, (name, method_name), kw)
     command_list.append(cmd)
 
@@ -85,237 +85,237 @@
     tk_class_name = 'Sketch'
 
     def __init__(self, application, filename, run_script = None):
-	self.application = application
-	self.root = application.root # XXX
-	self.filename = filename
+        self.application = application
+        self.root = application.root # XXX
+        self.filename = filename
         self.run_script = run_script
-	self.canvas = None
-	self.document = None
-	self.commands = None
-	self.NewDocument()
-	self.create_commands()
-	self.build_window()
-	self.build_menu()
-	self.build_toolbar()
-	self.build_status_bar()
-	self.__init_dlgs()
+        self.canvas = None
+        self.document = None
+        self.commands = None
+        self.NewDocument()
+        self.create_commands()
+        self.build_window()
+        self.build_menu()
+        self.build_toolbar()
+        self.build_status_bar()
+        self.__init_dlgs()
 
     def issue_document(self):
-	self.issue(DOCUMENT, self.document)
+        self.issue(DOCUMENT, self.document)
 
     def create_commands(self):
-	cmds = Commands()
-	keymap = Keymap()
-	for cmd_class in command_list:
-	    cmd = cmd_class.InstantiateFor(self)
-	    setattr(cmds, cmd.name, cmd)
-	    keymap.AddCommand(cmd)
-	self.commands = cmds
-	self.commands.Update()
-	self.keymap = keymap
+        cmds = Commands()
+        keymap = Keymap()
+        for cmd_class in command_list:
+            cmd = cmd_class.InstantiateFor(self)
+            setattr(cmds, cmd.name, cmd)
+            keymap.AddCommand(cmd)
+        self.commands = cmds
+        self.commands.Update()
+        self.keymap = keymap
 
     def MapKeystroke(self, stroke):
-	return self.keymap.MapKeystroke(stroke)
+        return self.keymap.MapKeystroke(stroke)
 
     def save_doc_if_edited(self, title = _("Save Document")):
-	if self.document is not None and self.document.WasEdited():
-	    message = _("%s has been changed.\nDo you want to save it?") \
-		      % self.document.meta.filename
-	    result = self.application.MessageBox(title = title,
-						 message = message,
-						 buttons = tkext.YesNoCancel)
-	    if result == tkext.Yes:
-		self.SaveToFileInteractive()
-	    return result
-	return tkext.No
+        if self.document is not None and self.document.WasEdited():
+            message = _("%s has been changed.\nDo you want to save it?") \
+                    % self.document.meta.filename
+            result = self.application.MessageBox(title = title,
+                                                 message = message,
+                                                 buttons = tkext.YesNoCancel)
+            if result == tkext.Yes:
+                self.SaveToFileInteractive()
+            return result
+        return tkext.No
 
     def Document(self):
-	return self.document
+        return self.document
 
     def SetDocument(self, document):
-	channels = (SELECTION, UNDO, MODE)
-	old_doc = self.document
-	if old_doc is not None:
-	    for channel in channels:
-		old_doc.Unsubscribe(channel, self.issue, channel)
-	self.document = document
-	for channel in channels:
-	    self.document.Subscribe(channel, self.issue, channel)
-	if self.canvas is not None:
-	    self.canvas.SetDocument(document)
-	self.issue_document()
-	# issue_document has to be called before old_doc is destroyed,
-	# because destroying it causes all connections to be deleted and
-	# some dialogs (derived from SketchDlg) try to unsubscribe in
-	# response to our DOCUMENT message. The connector currently
-	# raises an exception in this case. Perhaps it should silently
-	# ignore Unsubscribe() calls with methods that are actually not
-	# subscribers (any more)
-	if old_doc is not None:
-	    old_doc.Destroy()
-	self.set_window_title()
-	if self.commands:
-	    self.commands.Update()
+        channels = (SELECTION, UNDO, MODE)
+        old_doc = self.document
+        if old_doc is not None:
+            for channel in channels:
+                old_doc.Unsubscribe(channel, self.issue, channel)
+        self.document = document
+        for channel in channels:
+            self.document.Subscribe(channel, self.issue, channel)
+        if self.canvas is not None:
+            self.canvas.SetDocument(document)
+        self.issue_document()
+        # issue_document has to be called before old_doc is destroyed,
+        # because destroying it causes all connections to be deleted and
+        # some dialogs (derived from SketchDlg) try to unsubscribe in
+        # response to our DOCUMENT message. The connector currently
+        # raises an exception in this case. Perhaps it should silently
+        # ignore Unsubscribe() calls with methods that are actually not
+        # subscribers (any more)
+        if old_doc is not None:
+            old_doc.Destroy()
+        self.set_window_title()
+        if self.commands:
+            self.commands.Update()
 
     AddCmd('NewDocument', _("New"), bitmap = pixmaps.NewDocument)
     def NewDocument(self):
-	if self.save_doc_if_edited(_("New Document")) == tkext.Cancel:
-	    return
-	self.SetDocument(Document(create_layer = 1))
+        if self.save_doc_if_edited(_("New Document")) == tkext.Cancel:
+            return
+        self.SetDocument(Document(create_layer = 1))
 
     AddCmd('LoadFromFile', _("Open..."), bitmap = pixmaps.Open,
-	   key_stroke = 'C-o')
+           key_stroke = 'C-o')
     AddCmd('LoadMRU0', '', 'LoadFromFile', args = 0, key_stroke = 'M-1',
-	   name_cb = lambda: os.path.split(config.preferences.mru_files[0])[1])
+           name_cb = lambda: os.path.split(config.preferences.mru_files[0])[1])
     AddCmd('LoadMRU1', '', 'LoadFromFile', args = 1, key_stroke = 'M-2',
-	   name_cb = lambda: os.path.split(config.preferences.mru_files[1])[1])
+           name_cb = lambda: os.path.split(config.preferences.mru_files[1])[1])
     AddCmd('LoadMRU2', '', 'LoadFromFile', args = 2, key_stroke = 'M-3',
-	   name_cb = lambda: os.path.split(config.preferences.mru_files[2])[1])
+           name_cb = lambda: os.path.split(config.preferences.mru_files[2])[1])
     AddCmd('LoadMRU3', '', 'LoadFromFile', args = 3, key_stroke = 'M-4',
-	   name_cb = lambda: os.path.split(config.preferences.mru_files[3])[1])
+           name_cb = lambda: os.path.split(config.preferences.mru_files[3])[1])
     def LoadFromFile(self, filename = None, directory = None):
-	app = self.application
-	if self.save_doc_if_edited(_("Open Document")) == tkext.Cancel:
-	    return
-	if type(filename) == type(0):
-	    filename = config.preferences.mru_files[filename]
-	if not filename:
+        app = self.application
+        if self.save_doc_if_edited(_("Open Document")) == tkext.Cancel:
+            return
+        if type(filename) == type(0):
+            filename = config.preferences.mru_files[filename]
+        if not filename:
             if not directory:
                 directory = self.document.meta.directory
-	    if not directory:
-		directory = os.getcwd()
-	    name = ''
-	    filename = app.GetOpenFilename(filetypes = skapp.openfiletypes(),
-					   initialdir = directory,
-					   initialfile = name)
-	    if not filename:
-		return
+            if not directory:
+                directory = os.getcwd()
+            name = ''
+            filename = app.GetOpenFilename(filetypes = skapp.openfiletypes(),
+                                           initialdir = directory,
+                                           initialfile = name)
+            if not filename:
+                return
 
-	try:
-	    if not os.path.isabs(filename):
-		filename = os.path.join(os.getcwd(), filename)
-	    doc = load.load_drawing(filename)
-	    self.SetDocument(doc)
-	    self.add_mru_file(filename)
-	except SketchError, value:
-	    app.MessageBox(title = _("Open"),
-			   message = _("An error occurred:\n") + str(value))
-	    #warn_tb(USER, "An error occurred:\n", str(value))
-	    self.remove_mru_file(filename)
-	else:
-	    messages = doc.meta.load_messages
-	    if messages:
-		app.MessageBox(title = _("Open"),
-			       message=_("Warnings from the import filter:\n")
-			       + messages)
-	    doc.meta.load_messages = ''
+        try:
+            if not os.path.isabs(filename):
+                filename = os.path.join(os.getcwd(), filename)
+            doc = load.load_drawing(filename)
+            self.SetDocument(doc)
+            self.add_mru_file(filename)
+        except SketchError, value:
+            app.MessageBox(title = _("Open"),
+                           message = _("An error occurred:\n") + str(value))
+            #warn_tb(USER, "An error occurred:\n", str(value))
+            self.remove_mru_file(filename)
+        else:
+            messages = doc.meta.load_messages
+            if messages:
+                app.MessageBox(title = _("Open"),
+                               message=_("Warnings from the import filter:\n")
+                               + messages)
+            doc.meta.load_messages = ''
 
 
     AddCmd('SaveToFile', _("Save"), 'SaveToFileInteractive',
-	   bitmap = pixmaps.Save, key_stroke = ('C-s', 'F2'))
+           bitmap = pixmaps.Save, key_stroke = ('C-s', 'F2'))
     AddCmd('SaveToFileAs', _("Save As..."), 'SaveToFileInteractive', args = 1,
-	   key_stroke = ('C-w', 'F3'))
+           key_stroke = ('C-w', 'F3'))
     def SaveToFileInteractive(self, use_dialog = 0):
-	filename =  self.document.meta.fullpathname
-	native_format = self.document.meta.native_format
-	compressed_file = self.document.meta.compressed_file
-	compressed = self.document.meta.compressed
-	app = self.application
-	if use_dialog or not filename or not native_format:
-	    dir = self.document.meta.directory
-	    if not dir:
-		dir = os.getcwd()
-	    name = self.document.meta.filename
-	    basename, ext = os.path.splitext(name)
-	    if not native_format:
-		name = basename + '.sk'
-	    filename = app.GetSaveFilename(filetypes = skapp.savefiletypes(),
-					   initialdir = dir,
-					   initialfile = name)
-	    if not filename:
-		return
-	    extension = os.path.splitext(filename)[1]
-	    fileformat = plugins.guess_export_plugin(extension)
-	    if not fileformat:
-		fileformat = plugins.NativeFormat
-	    compressed_file = '' # guess compression from filename
+        filename =  self.document.meta.fullpathname
+        native_format = self.document.meta.native_format
+        compressed_file = self.document.meta.compressed_file
+        compressed = self.document.meta.compressed
+        app = self.application
+        if use_dialog or not filename or not native_format:
+            dir = self.document.meta.directory
+            if not dir:
+                dir = os.getcwd()
+            name = self.document.meta.filename
+            basename, ext = os.path.splitext(name)
+            if not native_format:
+                name = basename + '.sk'
+            filename = app.GetSaveFilename(filetypes = skapp.savefiletypes(),
+                                           initialdir = dir,
+                                           initialfile = name)
+            if not filename:
+                return
+            extension = os.path.splitext(filename)[1]
+            fileformat = plugins.guess_export_plugin(extension)
+            if not fileformat:
+                fileformat = plugins.NativeFormat
+            compressed_file = '' # guess compression from filename
             compressed = ''
-	else:
-	    fileformat = plugins.NativeFormat
-	self.SaveToFile(filename, fileformat, compressed, compressed_file)
+        else:
+            fileformat = plugins.NativeFormat
+        self.SaveToFile(filename, fileformat, compressed, compressed_file)
 
     def SaveToFile(self, filename, fileformat = None, compressed = '',
                    compressed_file = ''):
-	app = self.application
-	try:
-	    if not self.document.meta.backup_created:
-		try:
-		    if compressed_file:
-			util.make_backup(compressed_file)
-		    else:
-			util.make_backup(filename)
-		except util.BackupError, value:
-		    backupfile = value.filename
-		    strerror = value.strerror
-		    msg = (_("Cannot create backup file %(filename)s:\n"
-			     "%(message)s\n"
-			     "Choose `continue' to try saving anyway,\n"
-			     "or `cancel' to cancel.")
-			   % {'filename':`backupfile`, 'message':strerror})
-		    cancel = _("Cancel")
-		    result = app.MessageBox(title = _("Save To File"),
-					    message = msg, icon = 'warning',
-					    buttons = (_("Continue"), cancel))
-		    if result == cancel:
-			return
+        app = self.application
+        try:
+            if not self.document.meta.backup_created:
+                try:
+                    if compressed_file:
+                        util.make_backup(compressed_file)
+                    else:
+                        util.make_backup(filename)
+                except util.BackupError, value:
+                    backupfile = value.filename
+                    strerror = value.strerror
+                    msg = (_("Cannot create backup file %(filename)s:\n"
+                             "%(message)s\n"
+                             "Choose `continue' to try saving anyway,\n"
+                             "or `cancel' to cancel.")
+                           % {'filename':`backupfile`, 'message':strerror})
+                    cancel = _("Cancel")
+                    result = app.MessageBox(title = _("Save To File"),
+                                            message = msg, icon = 'warning',
+                                            buttons = (_("Continue"), cancel))
+                    if result == cancel:
+                        return
 
-		self.document.meta.backup_created = 1
-	    if fileformat is None:
-		fileformat = plugins.NativeFormat
-	    try:
-		saver = plugins.find_export_plugin(fileformat)
-		if compressed:
-		    # XXX there should be a plugin interface for this kind
-		    # of post-processing
+                self.document.meta.backup_created = 1
+            if fileformat is None:
+                fileformat = plugins.NativeFormat
+            try:
+                saver = plugins.find_export_plugin(fileformat)
+                if compressed:
+                    # XXX there should be a plugin interface for this kind
+                    # of post-processing
                     if compressed == "gzip":
                         cmd = 'gzip -c -9 > ' + util.sh_quote(compressed_file)
                     elif compressed == "bzip2":
                         cmd = 'bzip2 > ' + util.sh_quote(compressed_file)
                     file = os.popen(cmd, 'w')
                     saver(self.document, filename, file = file)
-		else:
-		    saver(self.document, filename)
-	    finally:
-		saver.UnloadPlugin()
-	except IOError, value:
-	    if type(value) == type(()):
-		value = value[1]
-	    app.MessageBox(title = _("Save To File"),
-			   message = _("Cannot save %(filename)s:\n"
-				       "%(message)s") \
-			   % {'filename':`os.path.split(filename)[1]`,
-			      'message':value},
-			   icon = 'warning')
-	    self.remove_mru_file(filename)
-	    return
+                else:
+                    saver(self.document, filename)
+            finally:
+                saver.UnloadPlugin()
+        except IOError, value:
+            if type(value) == type(()):
+                value = value[1]
+            app.MessageBox(title = _("Save To File"),
+                           message = _("Cannot save %(filename)s:\n"
+                                       "%(message)s") \
+                           % {'filename':`os.path.split(filename)[1]`,
+                              'message':value},
+                           icon = 'warning')
+            self.remove_mru_file(filename)
+            return
 
-	if fileformat == plugins.NativeFormat:
-	    dir, name = os.path.split(filename)
-	    # XXX should meta.directory be set for non-native formats as well
-	    self.document.meta.directory = dir
-	    self.document.meta.filename = name
-	    self.document.meta.fullpathname = filename
-	    self.document.meta.file_type = plugins.NativeFormat
-	    self.document.meta.native_format = 1
-	if not compressed_file:
-	    self.document.meta.compressed_file = ''
-	    self.document.meta.compressed = ''
-	if compressed_file:
-	    self.add_mru_file(compressed_file)
-	else:
-	    self.add_mru_file(filename)
+        if fileformat == plugins.NativeFormat:
+            dir, name = os.path.split(filename)
+            # XXX should meta.directory be set for non-native formats as well
+            self.document.meta.directory = dir
+            self.document.meta.filename = name
+            self.document.meta.fullpathname = filename
+            self.document.meta.file_type = plugins.NativeFormat
+            self.document.meta.native_format = 1
+        if not compressed_file:
+            self.document.meta.compressed_file = ''
+            self.document.meta.compressed = ''
+        if compressed_file:
+            self.add_mru_file(compressed_file)
+        else:
+            self.add_mru_file(filename)
 
-	self.set_window_title()
+        self.set_window_title()
 
 
 
@@ -329,21 +329,21 @@
                                        "any printable layers."),
                            icon = "warning")
             return
-	if not filename:
-	    dir = self.document.meta.ps_directory
-	    if not dir:
-		dir = self.document.meta.directory
-	    if not dir:
-		dir = os.getcwd()
-	    name = self.document.meta.filename
-	    name, ext = os.path.splitext(name)
-	    name = name + '.ps'
-	    filename = app.GetSaveFilename(title = _("Save As PostScript"),
-					   filetypes = skapp.psfiletypes,
-					   initialdir = dir,
-					   initialfile = name)
-	    if not filename:
-		return
+        if not filename:
+            dir = self.document.meta.ps_directory
+            if not dir:
+                dir = self.document.meta.directory
+            if not dir:
+                dir = os.getcwd()
+            name = self.document.meta.filename
+            name, ext = os.path.splitext(name)
+            name = name + '.ps'
+            filename = app.GetSaveFilename(title = _("Save As PostScript"),
+                                           filetypes = skapp.psfiletypes,
+                                           initialdir = dir,
+                                           initialfile = name)
+            if not filename:
+                return
         try:
             ps_dev = PostScriptDevice(filename, as_eps = 1,
                                       bounding_box = tuple(bbox),
@@ -357,157 +357,157 @@
         except IOError, value:
             app.MessageBox(title = _("Save As PostScript"),
                            message = _("Cannot save %(filename)s:\n"
-                                   "%(message)s") \
+                                       "%(message)s") \
                            % {'filename':`os.path.split(filename)[1]`,
                               'message':value[1]},
                            icon = 'warning')
 
     def add_mru_file(self, filename):
-	if filename:
-	    config.add_mru_file(filename)
-	    self.update_mru_files()
+        if filename:
+            config.add_mru_file(filename)
+            self.update_mru_files()
 
     def remove_mru_file(self, filename):
-	if filename:
-	    config.remove_mru_file(filename)
-	    self.update_mru_files()
+        if filename:
+            config.remove_mru_file(filename)
+            self.update_mru_files()
 
     def update_mru_files(self):
-	self.commands.LoadMRU0.Update()
-	self.commands.LoadMRU1.Update()
-	self.commands.LoadMRU2.Update()
-	self.commands.LoadMRU3.Update()
-	self.file_menu.RebuildMenu()
+        self.commands.LoadMRU0.Update()
+        self.commands.LoadMRU1.Update()
+        self.commands.LoadMRU2.Update()
+        self.commands.LoadMRU3.Update()
+        self.file_menu.RebuildMenu()
 
     AddCmd('InsertFile', _("Insert Document..."))
     def InsertFile(self, filename = None):
-	app = self.application
-	if not filename:
-	    dir = self.document.meta.directory
-	    if not dir:
-		dir = os.getcwd()
-	    name = ''
-	    filename = app.GetOpenFilename(filetypes = skapp.openfiletypes(),
-					   initialdir = dir,
-					   initialfile = name)
-	    if not filename:
-		return
+        app = self.application
+        if not filename:
+            dir = self.document.meta.directory
+            if not dir:
+                dir = os.getcwd()
+            name = ''
+            filename = app.GetOpenFilename(filetypes = skapp.openfiletypes(),
+                                           initialdir = dir,
+                                           initialfile = name)
+            if not filename:
+                return
 
-	try:
-	    if not os.path.isabs(filename):
-		filename = os.path.join(os.getcwd(), filename)
-	    doc = load.load_drawing(filename)
-	    group = doc.as_group()
-	except SketchError, value:
-	    app.MessageBox(title = _("Insert Document"),
-			   message = _("An error occurred:\n") + str(value))
-	    #warn_tb(USER, "An error occurred:\n", str(value))
-	    self.remove_mru_file(filename)
-	else:
-	    messages = doc.meta.load_messages
-	    if messages:
-		app.MessageBox(title = _("Insert Document"),
-			       message=_("Warnings from the import filter:\n")
-			       + messages)
-	    doc.meta.load_messages = ''
-	#
-	if group is not None:
-	    self.canvas.PlaceObject(group)
-	else:
-	    app.MessageBox(title = _("Insert Document"),
-			   message=_("The document is empty"))
+        try:
+            if not os.path.isabs(filename):
+                filename = os.path.join(os.getcwd(), filename)
+            doc = load.load_drawing(filename)
+            group = doc.as_group()
+        except SketchError, value:
+            app.MessageBox(title = _("Insert Document"),
+                           message = _("An error occurred:\n") + str(value))
+            #warn_tb(USER, "An error occurred:\n", str(value))
+            self.remove_mru_file(filename)
+        else:
+            messages = doc.meta.load_messages
+            if messages:
+                app.MessageBox(title = _("Insert Document"),
+                               message=_("Warnings from the import filter:\n")
+                               + messages)
+            doc.meta.load_messages = ''
+        #
+        if group is not None:
+            self.canvas.PlaceObject(group)
+        else:
+            app.MessageBox(title = _("Insert Document"),
+                           message=_("The document is empty"))
 
 
     AddCmd('LoadPalette', _("Load Palette..."))
     def LoadPalette(self, filename = None):
-	if not filename:
-	    dir = config.std_res_dir
-	    if not dir:
-		dir = os.getcwd()
-	    name = ''
-	    filename = self.application.GetOpenFilename(
-		filetypes = palette.file_types,
-		initialdir = dir,
-		initialfile = name)
-	    if not filename:
-		return
+        if not filename:
+            dir = config.std_res_dir
+            if not dir:
+                dir = os.getcwd()
+            name = ''
+            filename = self.application.GetOpenFilename(
+                filetypes = palette.file_types,
+                initialdir = dir,
+                initialfile = name)
+            if not filename:
+                return
 
-	pal = palette.LoadPalette(filename)
-	if not pal:
-	    self.application.MessageBox(title = _("Load Palette"),
-			       message = _("Cannot load palette %(filename)s")
-					% {'filename': filename})
-	else:
-	    self.palette.SetPalette(pal)
-	    # XXX Should we just store the basename if the palette file
-	    # is located in the resource_dir?
-	    config.preferences.palette = filename
+        pal = palette.LoadPalette(filename)
+        if not pal:
+            self.application.MessageBox(title = _("Load Palette"),
+                                        message = _("Cannot load palette %(filename)s")
+                                        % {'filename': filename})
+        else:
+            self.palette.SetPalette(pal)
+            # XXX Should we just store the basename if the palette file
+            # is located in the resource_dir?
+            config.preferences.palette = filename
 
     def __init_dlgs(self):
-	self.dialogs = {}
+        self.dialogs = {}
 
     def CreateDialog(self, module, dlgname):
-	if self.dialogs.has_key(dlgname):
-	    dialog = self.dialogs[dlgname]
-	    dialog.deiconify_and_raise()
-	else:
-	    exec "from %s import %s" % (module, dlgname)
-	    dlgclass = locals()[dlgname]
-	    dialog = dlgclass(self.root, self, self.document)
-	    dialog.Subscribe(CLOSED, self.__dlg_closed, dlgname)
-	    self.dialogs[dlgname] = dialog
+        if self.dialogs.has_key(dlgname):
+            dialog = self.dialogs[dlgname]
+            dialog.deiconify_and_raise()
+        else:
+            exec "from %s import %s" % (module, dlgname)
+            dlgclass = locals()[dlgname]
+            dialog = dlgclass(self.root, self, self.document)
+            dialog.Subscribe(CLOSED, self.__dlg_closed, dlgname)
+            self.dialogs[dlgname] = dialog
 
     def HideDialogs(self):
-	for dialog in self.dialogs.values():
-	    dialog.withdraw()
+        for dialog in self.dialogs.values():
+            dialog.withdraw()
     AddCmd('HideDialogs', _("Hide Dialogs"))
 
     def ShowDialogs(self):
-	for dialog in self.dialogs.values():
-	    dialog.deiconify_and_raise()
+        for dialog in self.dialogs.values():
+            dialog.deiconify_and_raise()
     AddCmd('ShowDialogs', _("Show Dialogs"))
 
     def __dlg_closed(self, dialog, name):
-	try:
-	    del self.dialogs[name]
-	except:
-	    # This might happen if the dialog is buggy...
-	    warn(INTERNAL, 'dialog %s alread removed from dialog list', name)
+        try:
+            del self.dialogs[name]
+        except:
+            # This might happen if the dialog is buggy...
+            warn(INTERNAL, 'dialog %s alread removed from dialog list', name)
 
     AddCmd('CreateLayerDialog', _("Layers..."),
-	   'CreateDialog', args = ('layerdlg', 'LayerPanel'),
-	   key_stroke = 'F5')
+           'CreateDialog', args = ('layerdlg', 'LayerPanel'),
+           key_stroke = 'F5')
     AddCmd('CreateAlignDialog', _("Align..."),
-	   'CreateDialog', args = ('aligndlg', 'AlignPanel'))
+           'CreateDialog', args = ('aligndlg', 'AlignPanel'))
     AddCmd('CreateGridDialog', _("Grid..."),
-	   'CreateDialog', args = ('griddlg', 'GridPanel'))
+           'CreateDialog', args = ('griddlg', 'GridPanel'))
     AddCmd('CreateLineStyleDialog', _("Line..."),
-	   'CreateDialog', args = ('linedlg', 'LinePanel'),
-	   key_stroke = 'F7')
+           'CreateDialog', args = ('linedlg', 'LinePanel'),
+           key_stroke = 'F7')
     AddCmd('CreateFillStyleDialog', _("Fill..."),
-	   'CreateDialog', args = ('filldlg', 'FillPanel'),
-	   key_stroke = 'F6')
+           'CreateDialog', args = ('filldlg', 'FillPanel'),
+           key_stroke = 'F6')
     AddCmd('CreateFontDialog', _("Font..."),
-	   'CreateDialog', args = ('fontdlg', 'FontPanel'))
+           'CreateDialog', args = ('fontdlg', 'FontPanel'))
     AddCmd('CreateStyleDialog', _("Styles..."),
-	   'CreateDialog', args = ('styledlg', 'StylePanel'))
+           'CreateDialog', args = ('styledlg', 'StylePanel'))
     AddCmd('CreateBlendDialog', _("Blend..."),
-	   'CreateDialog', args = ('blenddlg', 'BlendPanel'),
-	   key_stroke = 'C-b')
+           'CreateDialog', args = ('blenddlg', 'BlendPanel'),
+           key_stroke = 'C-b')
     AddCmd('CreateLayoutDialog', _("Page Layout..."),
-	   'CreateDialog', args = ('layoutdlg', 'LayoutPanel'))
+           'CreateDialog', args = ('layoutdlg', 'LayoutPanel'))
     #AddCmd('CreateExportDialog', 'Export...',
 #	   'CreateDialog', args = ('export', 'ExportPanel'))
     AddCmd('CreateCurveDialog', _("Curve Commands..."),
-	   'CreateDialog', args = ('curvedlg', 'CurvePanel'))
+           'CreateDialog', args = ('curvedlg', 'CurvePanel'))
     AddCmd('CreateGuideDialog', _("Guide Lines..."),
-	   'CreateDialog', args = ('guidedlg', 'GuidePanel'))
+           'CreateDialog', args = ('guidedlg', 'GuidePanel'))
     AddCmd('CreatePrintDialog', _("Print..."),
-	   'CreateDialog', args = ('printdlg', 'PrintPanel'),
-	   key_stroke = "C-p")
+           'CreateDialog', args = ('printdlg', 'PrintPanel'),
+           key_stroke = "C-p")
 
     AddCmd('CreateReloadPanel', _("Reload Module..."),
-	   'CreateDialog', args = ('reloaddlg', 'ReloadPanel'))
+           'CreateDialog', args = ('reloaddlg', 'ReloadPanel'))
 
     def CreatePluginDialog(self, info):
         if info.HasCustomDialog():
@@ -520,33 +520,33 @@
 
     AddCmd('SetOptions', _("Options..."))
     def SetOptions(self):
-	import optiondlg
-	optiondlg.OptionDialog(self.root, self.canvas)
+        import optiondlg
+        optiondlg.OptionDialog(self.root, self.canvas)
 
     def set_window_title(self):
-	self.root.client(util.gethostname())
-	if self.document:
-	    appname = config.name
-	    meta = self.document.meta
-	    if meta.compressed:
-		docname = os.path.split(meta.compressed_file)[1]
-		docname = os.path.splitext(docname)[0]
-	    else:
-		docname = self.document.meta.filename
-	    title = config.preferences.window_title_template % locals()
-	    command = (config.sketch_command, self.document.meta.fullpathname)
-	else:
-	    title = config.name
-	    command = (config.sketch_command, )
-	self.root.title(title)
-	self.root.command(command)
+        self.root.client(util.gethostname())
+        if self.document:
+            appname = config.name
+            meta = self.document.meta
+            if meta.compressed:
+                docname = os.path.split(meta.compressed_file)[1]
+                docname = os.path.splitext(docname)[0]
+            else:
+                docname = self.document.meta.filename
+            title = config.preferences.window_title_template % locals()
+            command = (config.sketch_command, self.document.meta.fullpathname)
+        else:
+            title = config.name
+            command = (config.sketch_command, )
+        self.root.title(title)
+        self.root.command(command)
 
     def UpdateCommands(self):
-	self.canvas.UpdateCommands()
+        self.canvas.UpdateCommands()
 
     def Run(self):
-	#self.root.wait_visibility(self.canvas)
-	if self.filename:
+        #self.root.wait_visibility(self.canvas)
+        if self.filename:
             if os.path.isdir(self.filename):
                 filename = ''
                 directory = self.filename
@@ -554,7 +554,7 @@
                 filename = self.filename
                 directory = ''
             self.LoadFromFile(filename, directory = directory)
-	    self.filename = ''
+            self.filename = ''
         if self.run_script:
             from Sketch.Scripting.script import Context
             dict = {'context': Context()}
@@ -562,163 +562,163 @@
                 execfile(self.run_script, dict)
             except:
                 warn_tb(USER, _("Error running script `%s'"), self.run_script)
-	self.application.Mainloop()
+        self.application.Mainloop()
 
     AddCmd('Exit', _("Exit"), key_stroke = ('M-Q', 'M-F4'))
     def Exit(self):
-	if self.save_doc_if_edited(_("Exit")) != tkext.Cancel:
-	    self.commands = None
-	    self.application.Exit()
+        if self.save_doc_if_edited(_("Exit")) != tkext.Cancel:
+            self.commands = None
+            self.application.Exit()
 
     def build_window(self):
-	root = self.application.root
-	self.mbar = Frame(root, name = 'menubar')
-	self.mbar.pack(fill=X)
-	self.tbar = Frame(root, name = 'toolbar')
-	self.tbar.pack(fill=X)
+        root = self.application.root
+        self.mbar = Frame(root, name = 'menubar')
+        self.mbar.pack(fill=X)
+        self.tbar = Frame(root, name = 'toolbar')
+        self.tbar.pack(fill=X)
 
-	self.status_bar = Frame(root, name = 'statusbar')
-	self.status_bar.pack(side = BOTTOM, fill=X)
+        self.status_bar = Frame(root, name = 'statusbar')
+        self.status_bar.pack(side = BOTTOM, fill=X)
 
-	palette_frame = Frame(root, name = 'palette_frame')
-	palette_frame.pack(side = BOTTOM, fill = X)
+        palette_frame = Frame(root, name = 'palette_frame')
+        palette_frame.pack(side = BOTTOM, fill = X)
 
-	frame = Frame(root, name = 'canvas_frame')
-	frame.pack(side = TOP, fill = BOTH, expand = 1)
-	vbar = Scrollbar(frame)
-	vbar.grid(in_ = frame, column = 2, row = 1, sticky = 'ns')
-	hbar = Scrollbar(frame, orient = HORIZONTAL)
-	hbar.grid(in_ = frame, column = 1, row = 2, sticky = 'ew')
-	hrule = ruler.Ruler(root, orient = ruler.HORIZONTAL)
-	hrule.grid(in_ = frame, column = 1, row = 0, sticky = 'ew',
-		   columnspan = 2)
-	vrule = ruler.Ruler(root, orient = ruler.VERTICAL)
-	vrule.grid(in_ = frame, column = 0, row = 1, sticky = 'ns',
-		   rowspan = 2)
-	tmp = Frame(frame, name = 'rulercorner')
-	tmp.grid(column = 0, row = 0, sticky = 'news')
+        frame = Frame(root, name = 'canvas_frame')
+        frame.pack(side = TOP, fill = BOTH, expand = 1)
+        vbar = Scrollbar(frame)
+        vbar.grid(in_ = frame, column = 2, row = 1, sticky = 'ns')
+        hbar = Scrollbar(frame, orient = HORIZONTAL)
+        hbar.grid(in_ = frame, column = 1, row = 2, sticky = 'ew')
+        hrule = ruler.Ruler(root, orient = ruler.HORIZONTAL)
+        hrule.grid(in_ = frame, column = 1, row = 0, sticky = 'ew',
+                   columnspan = 2)
+        vrule = ruler.Ruler(root, orient = ruler.VERTICAL)
+        vrule.grid(in_ = frame, column = 0, row = 1, sticky = 'ns',
+                   rowspan = 2)
+        tmp = Frame(frame, name = 'rulercorner')
+        tmp.grid(column = 0, row = 0, sticky = 'news')
 
-	resolution = config.preferences.screen_resolution
-	self.canvas = SketchCanvas(root, toplevel = root,
-				   background = 'white', name = 'canvas',
-				   resolution = resolution, main_window = self,
-				   document = self.document)
-	self.canvas.grid(in_ = frame, column = 1, row = 1, sticky = 'news')
-	self.canvas.focus()
-	self.canvas.SetScrollbars(hbar, vbar)
-	self.canvas.SetRulers(hrule, vrule)
-	hrule.SetCanvas(self.canvas)
-	vrule.SetCanvas(self.canvas)
-	frame.columnconfigure(0, weight = 0)
-	frame.columnconfigure(1, weight = 1)
-	frame.columnconfigure(2, weight = 0)
-	frame.rowconfigure(0, weight = 0)
-	frame.rowconfigure(1, weight = 1)
-	frame.rowconfigure(2, weight = 0)
-	hbar['command'] = self.canvas._w + ' xview'
-	vbar['command'] = self.canvas._w + ' yview'
+        resolution = config.preferences.screen_resolution
+        self.canvas = SketchCanvas(root, toplevel = root,
+                                   background = 'white', name = 'canvas',
+                                   resolution = resolution, main_window = self,
+                                   document = self.document)
+        self.canvas.grid(in_ = frame, column = 1, row = 1, sticky = 'news')
+        self.canvas.focus()
+        self.canvas.SetScrollbars(hbar, vbar)
+        self.canvas.SetRulers(hrule, vrule)
+        hrule.SetCanvas(self.canvas)
+        vrule.SetCanvas(self.canvas)
+        frame.columnconfigure(0, weight = 0)
+        frame.columnconfigure(1, weight = 1)
+        frame.columnconfigure(2, weight = 0)
+        frame.rowconfigure(0, weight = 0)
+        frame.rowconfigure(1, weight = 1)
+        frame.rowconfigure(2, weight = 0)
+        hbar['command'] = self.canvas._w + ' xview'
+        vbar['command'] = self.canvas._w + ' yview'
 
-	# the palette
+        # the palette
         button = MultiButton(palette_frame, bitmap = pixmaps.NoPattern,
                              command = self.no_pattern, args = 'fill')
         button.pack(side = LEFT)
         button.Subscribe('COMMAND2', self.no_pattern, 'line')
-        
-	pal = palette.GetStandardPalette()
 
-	self.palette = palette.PaletteWidget(palette_frame, pal)
-	ScrollXUnits = self.palette.ScrollXUnits
-	ScrollXPages = self.palette.ScrollXPages
-	CanScrollLeft = self.palette.CanScrollLeft
-	CanScrollRight = self.palette.CanScrollRight
-	for bitmap, command, args, sensitivecb in [
-	    (pixmaps.ArrArrLeft, ScrollXPages, -1, CanScrollLeft),
-	    (pixmaps.ArrLeft, ScrollXUnits, -1, CanScrollLeft),
-	    (pixmaps.ArrRight, ScrollXUnits, +1, CanScrollRight),
-	    (pixmaps.ArrArrRight, ScrollXPages, +1, CanScrollRight)]:
-	    button = UpdatedButton(palette_frame, bitmap = bitmap,
-				   command = command, args = args,
-				   sensitivecb = sensitivecb)
-	    button.pack(side = LEFT)
-	    self.palette.Subscribe(VIEW, button.Update)
-	    if bitmap == pixmaps.ArrLeft:
-		self.palette.pack(side = LEFT, fill = X, expand = 1)
+        pal = palette.GetStandardPalette()
 
-	self.palette.Subscribe(COLOR1, self.canvas.FillSolid)
-	self.palette.Subscribe(COLOR2, self.canvas.LineColor)
-	root.protocol('WM_DELETE_WINDOW', tkext.MakeMethodCommand(self.Exit))
+        self.palette = palette.PaletteWidget(palette_frame, pal)
+        ScrollXUnits = self.palette.ScrollXUnits
+        ScrollXPages = self.palette.ScrollXPages
+        CanScrollLeft = self.palette.CanScrollLeft
+        CanScrollRight = self.palette.CanScrollRight
+        for bitmap, command, args, sensitivecb in [
+            (pixmaps.ArrArrLeft, ScrollXPages, -1, CanScrollLeft),
+            (pixmaps.ArrLeft, ScrollXUnits, -1, CanScrollLeft),
+            (pixmaps.ArrRight, ScrollXUnits, +1, CanScrollRight),
+            (pixmaps.ArrArrRight, ScrollXPages, +1, CanScrollRight)]:
+            button = UpdatedButton(palette_frame, bitmap = bitmap,
+                                   command = command, args = args,
+                                   sensitivecb = sensitivecb)
+            button.pack(side = LEFT)
+            self.palette.Subscribe(VIEW, button.Update)
+            if bitmap == pixmaps.ArrLeft:
+                self.palette.pack(side = LEFT, fill = X, expand = 1)
 
+        self.palette.Subscribe(COLOR1, self.canvas.FillSolid)
+        self.palette.Subscribe(COLOR2, self.canvas.LineColor)
+        root.protocol('WM_DELETE_WINDOW', tkext.MakeMethodCommand(self.Exit))
 
+
     def make_file_menu(self):
-	cmds = self.commands
-	return map(MakeCommand,
-		   [cmds.NewDocument,
-		    cmds.LoadFromFile,
-		    cmds.SaveToFile,
-		    cmds.SaveToFileAs,
-		    cmds.SavePS,
-		    cmds.CreatePrintDialog,
-		    None,
-		    cmds.InsertFile,
-		    #cmds.CreateExportDialog,
-		    None,
-		    cmds.SetOptions,
-		    cmds.AboutBox,
-		    None,
-		    cmds.LoadMRU0,
-		    cmds.LoadMRU1,
-		    cmds.LoadMRU2,
-		    cmds.LoadMRU3,
-		    None,
-		    cmds.Exit])
+        cmds = self.commands
+        return map(MakeCommand,
+                   [cmds.NewDocument,
+                    cmds.LoadFromFile,
+                    cmds.SaveToFile,
+                    cmds.SaveToFileAs,
+                    cmds.SavePS,
+                    cmds.CreatePrintDialog,
+                    None,
+                    cmds.InsertFile,
+                    #cmds.CreateExportDialog,
+                    None,
+                    cmds.SetOptions,
+                    cmds.AboutBox,
+                    None,
+                    cmds.LoadMRU0,
+                    cmds.LoadMRU1,
+                    cmds.LoadMRU2,
+                    cmds.LoadMRU3,
+                    None,
+                    cmds.Exit])
 
     def make_edit_menu(self):
-	cmds = self.canvas.commands
-	return map(MakeCommand,
-		   [self.commands.Undo,
-		    self.commands.Redo,
-		    self.commands.ResetUndo,
-		    None,
-		    self.commands.CopySelected,
-		    self.commands.CutSelected,
-		    self.commands.PasteClipboard,
-		    self.commands.RemoveSelected,
-		    None,
-		    self.commands.SelectAll,
-		    None,
-		    self.commands.DuplicateSelected,
-		    None,
-		    [(_("Create"), {'auto_rebuild':self.creation_entries}),
-		     []],
-		    None,
-		    cmds.SelectionMode, cmds.EditMode,
-		    ])
+        cmds = self.canvas.commands
+        return map(MakeCommand,
+                   [self.commands.Undo,
+                    self.commands.Redo,
+                    self.commands.ResetUndo,
+                    None,
+                    self.commands.CopySelected,
+                    self.commands.CutSelected,
+                    self.commands.PasteClipboard,
+                    self.commands.RemoveSelected,
+                    None,
+                    self.commands.SelectAll,
+                    None,
+                    self.commands.DuplicateSelected,
+                    None,
+                    [(_("Create"), {'auto_rebuild':self.creation_entries}),
+                     []],
+                    None,
+                    cmds.SelectionMode, cmds.EditMode,
+                    ])
 
     def creation_entries(self):
-	cmds = self.canvas.commands
-	entries = [cmds.CreateRectangle,
-		   cmds.CreateEllipse,
-		   cmds.CreatePolyBezier,
-		   cmds.CreatePolyLine,
-		   cmds.CreateSimpleText,
-		   self.commands.CreateImage,
-		   None]
-	items = plugins.object_plugins.items()
-	items.sort()
-	place = self.place_plugin_object
-	dialog = self.CreatePluginDialog
+        cmds = self.canvas.commands
+        entries = [cmds.CreateRectangle,
+                   cmds.CreateEllipse,
+                   cmds.CreatePolyBezier,
+                   cmds.CreatePolyLine,
+                   cmds.CreateSimpleText,
+                   self.commands.CreateImage,
+                   None]
+        items = plugins.object_plugins.items()
+        items.sort()
+        place = self.place_plugin_object
+        dialog = self.CreatePluginDialog
         group = self.create_plugin_group
-	for name, plugin in items:
+        for name, plugin in items:
             if plugin.UsesSelection():
                 entries.append((plugin.menu_text, group, plugin))
-	    elif plugin.HasParameters() or plugin.HasCustomDialog():
-		entries.append((plugin.menu_text + '...', dialog, plugin))
-	    else:
-		entries.append((plugin.menu_text, place, plugin))
-	return map(MakeCommand, entries)
+            elif plugin.HasParameters() or plugin.HasCustomDialog():
+                entries.append((plugin.menu_text + '...', dialog, plugin))
+            else:
+                entries.append((plugin.menu_text, place, plugin))
+        return map(MakeCommand, entries)
 
     def place_plugin_object(self, info):
-	self.canvas.PlaceObject(info())
+        self.canvas.PlaceObject(info())
 
     def create_plugin_group(self, info):
         self.document.group_selected(info.menu_text, info.CallFactory)
@@ -727,91 +727,91 @@
         self.canvas.PlaceObject(object)
 
     def make_effects_menu(self):
-	return map(MakeCommand,
-		   [self.commands.FlipHorizontal,
-		    self.commands.FlipVertical,
-		    None,
-		    self.commands.RemoveTransformation,
-		    None,
-		    self.commands.CreateBlendDialog,
-		    self.commands.CancelBlend,
-		    None,
-		    self.commands.CreateMaskGroup,
-		    self.commands.CreatePathText,
-		    ])
+        return map(MakeCommand,
+                   [self.commands.FlipHorizontal,
+                    self.commands.FlipVertical,
+                    None,
+                    self.commands.RemoveTransformation,
+                    None,
+                    self.commands.CreateBlendDialog,
+                    self.commands.CancelBlend,
+                    None,
+                    self.commands.CreateMaskGroup,
+                    self.commands.CreatePathText,
+                    ])
 
     def make_curve_menu(self):
-	canvas = self.canvas
-	cmds = self.canvas.commands.PolyBezierEditor
-	return map(MakeCommand,
-		   [cmds.ContAngle,
-		    cmds.ContSmooth,
-		    cmds.ContSymmetrical,
-		    cmds.SegmentsToLines,
-		    cmds.SegmentsToCurve,
-		    cmds.SelectAllNodes,
-		    None,
-		    cmds.DeleteNodes,
-		    cmds.InsertNodes,
-		    None,
-		    cmds.CloseNodes,
-		    cmds.OpenNodes,
-		    None,
-		    self.commands.CombineBeziers,
-		    self.commands.SplitBeziers,
-		    None,
-		    self.commands.ConvertToCurve])
+        canvas = self.canvas
+        cmds = self.canvas.commands.PolyBezierEditor
+        return map(MakeCommand,
+                   [cmds.ContAngle,
+                    cmds.ContSmooth,
+                    cmds.ContSymmetrical,
+                    cmds.SegmentsToLines,
+                    cmds.SegmentsToCurve,
+                    cmds.SelectAllNodes,
+                    None,
+                    cmds.DeleteNodes,
+                    cmds.InsertNodes,
+                    None,
+                    cmds.CloseNodes,
+                    cmds.OpenNodes,
+                    None,
+                    self.commands.CombineBeziers,
+                    self.commands.SplitBeziers,
+                    None,
+                    self.commands.ConvertToCurve])
 
     def make_view_menu(self):
-	def MakeEntry(scale, call = self.canvas.SetScale):
-	    percent = int(100 * scale)
-	    return (('%3d%%' % percent), call, scale)
-	cmds = self.canvas.commands
-	scale = map(MakeEntry, [ 0.125, 0.25, 0.5, 1, 2, 4, 8])
-	return map(MakeCommand,
-		   [MakeEntry(1),
-		    [_("Zoom")] + scale,
+        def MakeEntry(scale, call = self.canvas.SetScale):
+            percent = int(100 * scale)
+            return (('%3d%%' % percent), call, scale)
+        cmds = self.canvas.commands
+        scale = map(MakeEntry, [ 0.125, 0.25, 0.5, 1, 2, 4, 8])
+        return map(MakeCommand,
+                   [MakeEntry(1),
+                    [_("Zoom")] + scale,
                     cmds.ZoomIn,
                     cmds.ZoomOut,
-		    cmds.ZoomMode,
-		    None,
-		    cmds.FitToWindow,
-		    cmds.FitSelectedToWindow,
-		    cmds.FitPageToWindow,
-		    cmds.RestoreViewport,
-		    None,
-		    cmds.ForceRedraw,
-		    None,
-		    cmds.ToggleOutlineMode,
-		    cmds.TogglePageOutlineMode,
+                    cmds.ZoomMode,
                     None,
-		    cmds.ToggleCrosshairs,
-		    None,
-		    self.commands.LoadPalette
-		    ])
+                    cmds.FitToWindow,
+                    cmds.FitSelectedToWindow,
+                    cmds.FitPageToWindow,
+                    cmds.RestoreViewport,
+                    None,
+                    cmds.ForceRedraw,
+                    None,
+                    cmds.ToggleOutlineMode,
+                    cmds.TogglePageOutlineMode,
+                    None,
+                    cmds.ToggleCrosshairs,
+                    None,
+                    self.commands.LoadPalette
+                    ])
 
     def make_arrange_menu(self):
         commands = [self.commands.CreateAlignDialog,
-		    None,
-		    self.commands.MoveSelectedToTop,
-		    self.commands.MoveSelectedToBottom,
-		    self.commands.MoveSelectionUp,
-		    self.commands.MoveSelectionDown,
-		    None,
-		    self.commands.AbutHorizontal,
-		    self.commands.AbutVertical,
-		    None,
-		    self.commands.GroupSelected,
-		    self.commands.UngroupSelected,
-		    None,
-		    self.canvas.commands.ToggleSnapToObjects,
-		    self.canvas.commands.ToggleSnapToGrid,
-		    self.commands.CreateGridDialog,
-		    None,
-		    self.canvas.commands.ToggleSnapToGuides,
-		    self.commands.AddHorizGuideLine,
-		    self.commands.AddVertGuideLine,
-		    self.commands.CreateGuideDialog]
+                    None,
+                    self.commands.MoveSelectedToTop,
+                    self.commands.MoveSelectedToBottom,
+                    self.commands.MoveSelectionUp,
+                    self.commands.MoveSelectionDown,
+                    None,
+                    self.commands.AbutHorizontal,
+                    self.commands.AbutVertical,
+                    None,
+                    self.commands.GroupSelected,
+                    self.commands.UngroupSelected,
+                    None,
+                    self.canvas.commands.ToggleSnapToObjects,
+                    self.canvas.commands.ToggleSnapToGrid,
+                    self.commands.CreateGridDialog,
+                    None,
+                    self.canvas.commands.ToggleSnapToGuides,
+                    self.commands.AddHorizGuideLine,
+                    self.commands.AddVertGuideLine,
+                    self.commands.CreateGuideDialog]
         if config.preferences.show_advanced_snap_commands:
             commands.append(None)
             commands.append(self.canvas.commands.ToggleSnapMoveRelative)
@@ -822,58 +822,58 @@
         return map(MakeCommand, commands)
 
     def make_style_menu(self):
-	return map(MakeCommand,
-		   [self.commands.FillNone,
-		    self.commands.CreateFillStyleDialog,
-		    self.canvas.commands.FillSolid,
-		    None,
-		    self.commands.LineNone,
-		    self.commands.CreateLineStyleDialog,
-		    None,
-		    self.commands.CreateStyleFromSelection,
-		    self.commands.CreateStyleDialog,
-		    self.commands.UpdateStyle,
-		    None,
-		    self.commands.CreateFontDialog
-		    ])
+        return map(MakeCommand,
+                   [self.commands.FillNone,
+                    self.commands.CreateFillStyleDialog,
+                    self.canvas.commands.FillSolid,
+                    None,
+                    self.commands.LineNone,
+                    self.commands.CreateLineStyleDialog,
+                    None,
+                    self.commands.CreateStyleFromSelection,
+                    self.commands.CreateStyleDialog,
+                    self.commands.UpdateStyle,
+                    None,
+                    self.commands.CreateFontDialog
+                    ])
 
     def make_window_menu(self):
-	cmds = self.commands
-	return map(MakeCommand,
-		   [cmds.HideDialogs,
-		    cmds.ShowDialogs,
-		    None,
-		    cmds.CreateLayerDialog,
-		    cmds.CreateAlignDialog,
-		    cmds.CreateGridDialog,
-		    None,
-		    cmds.CreateLineStyleDialog,
-		    cmds.CreateFillStyleDialog,
-		    cmds.CreateFontDialog,
-		    cmds.CreateStyleDialog,
-		    None,
-		    cmds.CreateLayoutDialog,
-		    None,
-		    cmds.CreateBlendDialog,
-		    cmds.CreateCurveDialog
-		    ])
+        cmds = self.commands
+        return map(MakeCommand,
+                   [cmds.HideDialogs,
+                    cmds.ShowDialogs,
+                    None,
+                    cmds.CreateLayerDialog,
+                    cmds.CreateAlignDialog,
+                    cmds.CreateGridDialog,
+                    None,
+                    cmds.CreateLineStyleDialog,
+                    cmds.CreateFillStyleDialog,
+                    cmds.CreateFontDialog,
+                    cmds.CreateStyleDialog,
+                    None,
+                    cmds.CreateLayoutDialog,
+                    None,
+                    cmds.CreateBlendDialog,
+                    cmds.CreateCurveDialog
+                    ])
 
     def make_special_menu(self):
-	cmdlist = [self.commands.python_prompt,
-		   self.commands.CreateReloadPanel,
-		   self.commands.DocumentInfo,
-		   None,
-		   self.commands.DumpXImage,
-		   self.commands.CreateClone,
-		   #self.commands.export_bitmap,
-		   ]
-	Sketch.Issue(None, Sketch.const.ADD_TO_SPECIAL_MENU, cmdlist)
-	return map(MakeCommand, cmdlist)
+        cmdlist = [self.commands.python_prompt,
+                   self.commands.CreateReloadPanel,
+                   self.commands.DocumentInfo,
+                   None,
+                   self.commands.DumpXImage,
+                   self.commands.CreateClone,
+                   #self.commands.export_bitmap,
+                   ]
+        Sketch.Issue(None, Sketch.const.ADD_TO_SPECIAL_MENU, cmdlist)
+        return map(MakeCommand, cmdlist)
 
     def make_script_menu(self):
         tree = Sketch.Scripting.Registry.MenuTree()
         cmdlist = self.convert_menu_tree(tree)
-	return map(MakeCommand, cmdlist)
+        return map(MakeCommand, cmdlist)
 
 
     def convert_menu_tree(self, tree):
@@ -886,138 +886,138 @@
         return result
 
     def build_menu(self):
-	mbar = self.mbar
-	self.file_menu = AppendMenu(mbar, _("File"), self.make_file_menu())
-	AppendMenu(mbar, _("Edit"), self.make_edit_menu())
-	AppendMenu(mbar, _("Effects"), self.make_effects_menu())
-	AppendMenu(mbar, _("Curve"), self.make_curve_menu())
-	AppendMenu(mbar, _("Arrange"), self.make_arrange_menu())
-	AppendMenu(mbar, _("Style"), self.make_style_menu())
-	AppendMenu(mbar, _("View"), self.make_view_menu())
-	AppendMenu(mbar, _("Script"), self.make_script_menu())
-	AppendMenu(mbar, _("Windows"), self.make_window_menu())
-	if config.preferences.show_special_menu:
-	    AppendMenu(mbar, _("Special"), self.make_special_menu())
-	self.update_mru_files()
-	self.file_menu.RebuildMenu()
+        mbar = self.mbar
+        self.file_menu = AppendMenu(mbar, _("File"), self.make_file_menu())
+        AppendMenu(mbar, _("Edit"), self.make_edit_menu())
+        AppendMenu(mbar, _("Effects"), self.make_effects_menu())
+        AppendMenu(mbar, _("Curve"), self.make_curve_menu())
+        AppendMenu(mbar, _("Arrange"), self.make_arrange_menu())
+        AppendMenu(mbar, _("Style"), self.make_style_menu())
+        AppendMenu(mbar, _("View"), self.make_view_menu())
+        AppendMenu(mbar, _("Script"), self.make_script_menu())
+        AppendMenu(mbar, _("Windows"), self.make_window_menu())
+        if config.preferences.show_special_menu:
+            AppendMenu(mbar, _("Special"), self.make_special_menu())
+        self.update_mru_files()
+        self.file_menu.RebuildMenu()
 
     def build_toolbar(self):
-	tbar = self.tbar
-	canvas = self.canvas
+        tbar = self.tbar
+        canvas = self.canvas
 
-	cmds = [self.commands.NewDocument,
-		self.commands.LoadFromFile,
-		self.commands.SaveToFile,
-		None,
-		canvas.commands.EditMode,
-		canvas.commands.SelectionMode,
-		None,
-		self.commands.Undo,
-		self.commands.Redo,
-		self.commands.RemoveSelected,
-		None,
-		self.commands.DuplicateSelected,
-		self.commands.FlipHorizontal,
-		self.commands.FlipVertical,
-		None,
-		self.commands.MoveSelectedToTop,
-		self.commands.MoveSelectionUp,
-		self.commands.MoveSelectionDown,
-		self.commands.MoveSelectedToBottom,
-		None,
-		self.commands.GroupSelected,
-		self.commands.UngroupSelected,
-		None,
-		canvas.commands.ZoomMode,
-		canvas.commands.ToggleSnapToGrid,
-		None,
-		canvas.commands.CreateRectangle,
-		canvas.commands.CreateEllipse,
-		canvas.commands.CreatePolyBezier,
-		canvas.commands.CreatePolyLine,
-		canvas.commands.CreateSimpleText,
-		self.commands.CreateImage,
-		]
+        cmds = [self.commands.NewDocument,
+                self.commands.LoadFromFile,
+                self.commands.SaveToFile,
+                None,
+                canvas.commands.EditMode,
+                canvas.commands.SelectionMode,
+                None,
+                self.commands.Undo,
+                self.commands.Redo,
+                self.commands.RemoveSelected,
+                None,
+                self.commands.DuplicateSelected,
+                self.commands.FlipHorizontal,
+                self.commands.FlipVertical,
+                None,
+                self.commands.MoveSelectedToTop,
+                self.commands.MoveSelectionUp,
+                self.commands.MoveSelectionDown,
+                self.commands.MoveSelectedToBottom,
+                None,
+                self.commands.GroupSelected,
+                self.commands.UngroupSelected,
+                None,
+                canvas.commands.ZoomMode,
+                canvas.commands.ToggleSnapToGrid,
+                None,
+                canvas.commands.CreateRectangle,
+                canvas.commands.CreateEllipse,
+                canvas.commands.CreatePolyBezier,
+                canvas.commands.CreatePolyLine,
+                canvas.commands.CreateSimpleText,
+                self.commands.CreateImage,
+                ]
 
-	buttons = []
-	for cmd in cmds:
-	    if cmd is None:
-		b = Frame(tbar, class_ = 'TBSeparator')
-		b.pack(side = LEFT, fill = Y)
-	    else:
-		if cmd.is_check:
-		    b = CommandCheckbutton(tbar, cmd,
-					   highlightthickness = 0,
-					   takefocus = 0)
-		else:
-		    b = CommandButton(tbar, cmd, highlightthickness = 0,
-				      takefocus = 0)
-		tooltips.AddDescription(b, cmd.menu_name)
-		b.pack(side = LEFT, fill = Y)
+        buttons = []
+        for cmd in cmds:
+            if cmd is None:
+                b = Frame(tbar, class_ = 'TBSeparator')
+                b.pack(side = LEFT, fill = Y)
+            else:
+                if cmd.is_check:
+                    b = CommandCheckbutton(tbar, cmd,
+                                           highlightthickness = 0,
+                                           takefocus = 0)
+                else:
+                    b = CommandButton(tbar, cmd, highlightthickness = 0,
+                                      takefocus = 0)
+                tooltips.AddDescription(b, cmd.menu_name)
+                b.pack(side = LEFT, fill = Y)
 
-	def state_changed(buttons = buttons):
-	    for button in buttons:
-		button.Update()
+        def state_changed(buttons = buttons):
+            for button in buttons:
+                button.Update()
 
-	canvas.Subscribe(STATE, state_changed)
+        canvas.Subscribe(STATE, state_changed)
 
     def build_status_bar(self):
-	status_bar = self.status_bar
-	canvas = self.canvas
-	stat_mode = UpdatedLabel(status_bar, name = 'mode', text = '',
-				 updatecb = canvas.ModeInfoText)
-	stat_mode.pack(side = 'left')
-	stat_mode.Update()
-	canvas.Subscribe(MODE, stat_mode.Update)
+        status_bar = self.status_bar
+        canvas = self.canvas
+        stat_mode = UpdatedLabel(status_bar, name = 'mode', text = '',
+                                 updatecb = canvas.ModeInfoText)
+        stat_mode.pack(side = 'left')
+        stat_mode.Update()
+        canvas.Subscribe(MODE, stat_mode.Update)
 
-	stat_edited = UpdatedLabel(status_bar, name = 'edited', text = '',
-				   updatecb = self.EditedInfoText)
-	stat_edited.pack(side = 'left')
-	stat_edited.Update()
-	self.Subscribe(UNDO, stat_edited.Update)
+        stat_edited = UpdatedLabel(status_bar, name = 'edited', text = '',
+                                   updatecb = self.EditedInfoText)
+        stat_edited.pack(side = 'left')
+        stat_edited.Update()
+        self.Subscribe(UNDO, stat_edited.Update)
 
-	stat_zoom = UpdatedLabel(status_bar, name = 'zoom', text = '',
-				 updatecb = canvas.ZoomInfoText)
-	stat_zoom.pack(side = 'left')
-	stat_zoom.Update()
-	canvas.Subscribe(VIEW, stat_zoom.Update)
+        stat_zoom = UpdatedLabel(status_bar, name = 'zoom', text = '',
+                                 updatecb = canvas.ZoomInfoText)
+        stat_zoom.pack(side = 'left')
+        stat_zoom.Update()
+        canvas.Subscribe(VIEW, stat_zoom.Update)
 
-	stat_pos = PositionLabel(status_bar, name = 'position', text = '',
-				 updatecb = canvas.GetCurrentPos)
-	stat_pos.pack(side = 'left')
-	stat_pos.Update()
-	canvas.Subscribe(POSITION, stat_pos.Update)
+        stat_pos = PositionLabel(status_bar, name = 'position', text = '',
+                                 updatecb = canvas.GetCurrentPos)
+        stat_pos.pack(side = 'left')
+        stat_pos.Update()
+        canvas.Subscribe(POSITION, stat_pos.Update)
 
-	stat_sel = UpdatedLabel(status_bar, name = 'selection', text = '',
-				updatecb = canvas.CurrentInfoText)
-	stat_sel.pack(side = 'left', fill = X, expand = 1)
-	stat_sel.Update()
-	update = stat_sel.Update
-	canvas.Subscribe(SELECTION, update)
-	canvas.Subscribe(CURRENTINFO, update)
-	canvas.Subscribe(EDITED, update)
+        stat_sel = UpdatedLabel(status_bar, name = 'selection', text = '',
+                                updatecb = canvas.CurrentInfoText)
+        stat_sel.pack(side = 'left', fill = X, expand = 1)
+        stat_sel.Update()
+        update = stat_sel.Update
+        canvas.Subscribe(SELECTION, update)
+        canvas.Subscribe(CURRENTINFO, update)
+        canvas.Subscribe(EDITED, update)
 
     def EditedInfoText(self):
-	if self.document.WasEdited():
-	    return _("modified")
-	return _("unmodified")
+        if self.document.WasEdited():
+            return _("modified")
+        return _("unmodified")
 
 
     AddCmd('AboutBox', _("About..."))
     def AboutBox(self):
-	abouttext = _("Skencil (%(version)s)\n"
-		      "(c) 1996-2007 by Bernhard Herzog\n\n"
-		      "Versions:\n"
-		      "Python:\t%(py)s\tTcl:\t%(tcl)s\n"
-		      "Tkinter:\t%(tkinter)s\tTk:\t%(tk)s") \
-		    % {'version':SketchVersion,
-		       'py':string.split(sys.version)[0],
-		       'tcl':TclVersion,
-		       'tkinter':string.split(Tkinter.__version__)[1],
-		       'tk':TkVersion}
+        abouttext = _("Skencil (%(version)s)\n"
+                      "(c) 1996-2007 by Bernhard Herzog\n\n"
+                      "Versions:\n"
+                      "Python:\t%(py)s\tTcl:\t%(tcl)s\n"
+                      "Tkinter:\t%(tkinter)s\tTk:\t%(tk)s") \
+                  % {'version':SketchVersion,
+                     'py':string.split(sys.version)[0],
+                     'tcl':TclVersion,
+                     'tkinter':string.split(Tkinter.__version__)[1],
+                     'tk':TkVersion}
 
-	self.application.MessageBox(title = _("About Skencil"),
-				    message = abouttext,
+        self.application.MessageBox(title = _("About Skencil"),
+                                    message = abouttext,
                                     icon = pixmaps.IconLarge)
 
 
@@ -1026,29 +1026,29 @@
     #
     AddCmd('DocumentInfo', "Document Info...", key_stroke = 'F12')
     def DocumentInfo(self):
-	text = self.document.DocumentInfo()
+        text = self.document.DocumentInfo()
 
-	from Sketch import _sketch
-	meminfo = 'Memory:\n'\
-		  '# Bezier Paths:\t%d\n'\
-		  '# RGBColors:\t%d\n' \
-		  '# Rects:\t\t%d\n'\
-		  '# Trafos:\t\t%d\n'\
-		  '# Points:\t\t%d' % (_sketch.num_allocated(),
-				       _sketch.colors_allocated(),
-				       _sketch.rects_allocated(),
-				       _sketch.trafos_allocted(),
-				       _sketch.points_allocated())
-	text = text + '\n\n' + meminfo
+        from Sketch import _sketch
+        meminfo = 'Memory:\n'\
+                '# Bezier Paths:\t%d\n'\
+                '# RGBColors:\t%d\n' \
+                '# Rects:\t\t%d\n'\
+                '# Trafos:\t\t%d\n'\
+                '# Points:\t\t%d' % (_sketch.num_allocated(),
+                                     _sketch.colors_allocated(),
+                                     _sketch.rects_allocated(),
+                                     _sketch.trafos_allocted(),
+                                     _sketch.points_allocated())
+        text = text + '\n\n' + meminfo
 
-	self.application.MessageBox(title = 'Document Info', message = text,
-				    icon = 'info')
+        self.application.MessageBox(title = 'Document Info', message = text,
+                                    icon = 'info')
 
     AddCmd('DumpXImage', 'Dump XImage')
     def DumpXImage(self):
-	gc = self.canvas.gc
-	if gc.ximage:
-	    gc.ximage.dump_data("/tmp/ximage.dat")
+        gc = self.canvas.gc
+        if gc.ximage:
+            gc.ximage.dump_data("/tmp/ximage.dat")
 
 
 #     AddCmd('export_bitmap', 'Export Bitmap')
@@ -1072,72 +1072,72 @@
     #
 
     def GetOpenImageFilename(self, title = None, initialdir = '',
-			     initialfile = '', no_eps = 0):
-	if title is None:
-	    title = _("Load Image")
-	if no_eps:
-	    filetypes = skapp.bitmapfiletypes
-	else:
-	    filetypes = skapp.imagefiletypes
-	filename = self.application.GetOpenFilename(title = title,
-						    filetypes = filetypes,
-						    initialdir = initialdir,
-						    initialfile = initialfile)
-	return filename
+                             initialfile = '', no_eps = 0):
+        if title is None:
+            title = _("Load Image")
+        if no_eps:
+            filetypes = skapp.bitmapfiletypes
+        else:
+            filetypes = skapp.imagefiletypes
+        filename = self.application.GetOpenFilename(title = title,
+                                                    filetypes = filetypes,
+                                                    initialdir = initialdir,
+                                                    initialfile = initialfile)
+        return filename
 
     AddCmd('CreateImage', _("Load Raster/EPS Image..."),
            bitmap = pixmaps.Image, subscribe_to = None)
     def CreateImage(self, filename = None):
-	if not filename:
-	    filename = self.GetOpenImageFilename(title = _("Load Image"),
-				     initialdir = config.preferences.image_dir,
-						 initialfile = '')
-	if filename:
-	    try:
-		file = open(filename, 'r')
-		is_eps = eps.IsEpsFileStart(file.read(256))
-		file.close()
-		dir, name = os.path.split(filename)
-		config.preferences.image_dir = dir
-		if is_eps:
-		    imageobj = eps.EpsImage(filename = filename)
-		else:
-		    imageobj = image.Image(imagefile = filename)
-		self.canvas.PlaceObject(imageobj)
-	    except IOError, value:
-		if type(value) == TupleType:
-		    value = value[1]
-		self.application.MessageBox(title = _("Load Image"),
-				message = _("Cannot load %(filename)s:\n"
-					    "%(message)s") \
-				% {'filename':`os.path.split(filename)[1]`,
-				   'message':value},
-				icon = 'warning')
+        if not filename:
+            filename = self.GetOpenImageFilename(title = _("Load Image"),
+                                                 initialdir = config.preferences.image_dir,
+                                                 initialfile = '')
+        if filename:
+            try:
+                file = open(filename, 'r')
+                is_eps = eps.IsEpsFileStart(file.read(256))
+                file.close()
+                dir, name = os.path.split(filename)
+                config.preferences.image_dir = dir
+                if is_eps:
+                    imageobj = eps.EpsImage(filename = filename)
+                else:
+                    imageobj = image.Image(imagefile = filename)
+                self.canvas.PlaceObject(imageobj)
+            except IOError, value:
+                if type(value) == TupleType:
+                    value = value[1]
+                self.application.MessageBox(title = _("Load Image"),
+                                            message = _("Cannot load %(filename)s:\n"
+                                                        "%(message)s") \
+                                            % {'filename':`os.path.split(filename)[1]`,
+                                               'message':value},
+                                            icon = 'warning')
 
     AddCmd('AddHorizGuideLine', _("Add Horizontal Guide Line"), 'AddGuideLine',
-	   args = 1)
+           args = 1)
     AddCmd('AddVertGuideLine', _("Add Vertical Guide Line"), 'AddGuideLine',
-	   args = 0)
+           args = 0)
     def AddGuideLine(self, horizontal = 1):
-	self.canvas.PlaceObject(GuideLine(Point(0, 0), horizontal))
+        self.canvas.PlaceObject(GuideLine(Point(0, 0), horizontal))
 
     #
     #
     #
 
     AddCmd('CreateStyleFromSelection', _("Name Style..."),
-	   sensitive_cb = ('document', 'CanCreateStyle'),
-	   subscribe_to = SELECTION)
+           sensitive_cb = ('document', 'CanCreateStyle'),
+           subscribe_to = SELECTION)
     def CreateStyleFromSelection(self):
-	import styledlg
-	doc = self.document
-	object = doc.CurrentObject()
-	style_names = doc.GetStyleNames()
-	if object:
-	    name = styledlg.GetStyleName(self.root, object, style_names)
-	    if name:
-		name, which_properties = name
-		doc.CreateStyleFromSelection(name, which_properties)
+        import styledlg
+        doc = self.document
+        object = doc.CurrentObject()
+        style_names = doc.GetStyleNames()
+        if object:
+            name = styledlg.GetStyleName(self.root, object, style_names)
+            if name:
+                name, which_properties = name
+                doc.CreateStyleFromSelection(name, which_properties)
 
     def no_pattern(self, category):
         import styledlg
@@ -1156,52 +1156,52 @@
     #
 
     AddDocCmd('SelectAll', _("Select All"), sensitive_cb = 'IsSelectionMode',
-	      subscribe_to = MODE)
+              subscribe_to = MODE)
     AddDocCmd('SelectNextObject', _("Select Next"), key_stroke = 'M-Right')
     AddDocCmd('SelectPreviousObject', _("Select Previous"),
-	      key_stroke = 'M-Left')
+              key_stroke = 'M-Left')
     AddDocCmd('SelectFirstChild', _("Select First Child"),
-	      key_stroke = 'M-Down')
+              key_stroke = 'M-Down')
     AddDocCmd('SelectParent', _("Select Parent"), key_stroke = 'M-Up')
 
     # rearrange object
 
     AddDocCmd('RemoveSelected', _("Delete"), key_stroke = 'Delete',
-	      bitmap = pixmaps.Delete)
+              bitmap = pixmaps.Delete)
 
     AddDocCmd('MoveSelectedToTop', _("Move to Top"),
-	      bitmap = pixmaps.MoveToTop, key_stroke = 'Home')
+              bitmap = pixmaps.MoveToTop, key_stroke = 'Home')
 
     AddDocCmd('MoveSelectedToBottom', _("Move to Bottom"),
-	      bitmap = pixmaps.MoveToBottom, key_stroke = 'End')
+              bitmap = pixmaps.MoveToBottom, key_stroke = 'End')
 
     AddDocCmd('MoveSelectionUp', _("Move One Up"), bitmap = pixmaps.MoveOneUp,
-	      key_stroke = 'S-Prior')
+              key_stroke = 'S-Prior')
 
     AddDocCmd('MoveSelectionDown', _("Move One Down"),
-	      bitmap = pixmaps.MoveOneDown, key_stroke = 'S-Next')
+              bitmap = pixmaps.MoveOneDown, key_stroke = 'S-Next')
 
     AddDocCmd('DuplicateSelected', _("Duplicate"), bitmap = pixmaps.Duplicate,
-	      key_stroke = 'C-d')
+              key_stroke = 'C-d')
     #
 
     AddDocCmd('GroupSelected', _("Group"), sensitive_cb = 'CanGroup',
-	      key_stroke = 'C-g', bitmap = pixmaps.Group)
+              key_stroke = 'C-g', bitmap = pixmaps.Group)
 
 
     AddDocCmd('UngroupSelected', _("Ungroup"), sensitive_cb = 'CanUngroup',
-	      key_stroke = 'C-u', bitmap = pixmaps.Ungroup)
+              key_stroke = 'C-u', bitmap = pixmaps.Ungroup)
 
     #
 
     AddDocCmd('ConvertToCurve', _("Convert To Curve"),
-	      sensitive_cb = 'CanConvertToCurve')
+              sensitive_cb = 'CanConvertToCurve')
 
     AddDocCmd('CombineBeziers', _("Combine Beziers"),
-	      sensitive_cb = 'CanCombineBeziers')
+              sensitive_cb = 'CanCombineBeziers')
 
     AddDocCmd('SplitBeziers', _("Split Beziers"),
-	      sensitive_cb = 'CanSplitBeziers')
+              sensitive_cb = 'CanSplitBeziers')
 
     #
     #	Align
@@ -1210,24 +1210,24 @@
     AddDocCmd('AbutVertical', _("Abut Vertical"))
 
     AddDocCmd('FlipHorizontal', _("Flip Horizontal"), 'FlipSelected',
-	      args = (1, 0), bitmap = pixmaps.FlipHorizontal)
+              args = (1, 0), bitmap = pixmaps.FlipHorizontal)
 
     AddDocCmd('FlipVertical', _("Flip Vertical"), 'FlipSelected',
-	      args = (0, 1), bitmap = pixmaps.FlipVertical)
+              args = (0, 1), bitmap = pixmaps.FlipVertical)
 
 
     # effects
     AddDocCmd('CancelBlend', _("Cancel Blend"),
-	      sensitive_cb = 'CanCancelBlend')
+              sensitive_cb = 'CanCancelBlend')
 
     AddDocCmd('RemoveTransformation', _("Remove Transformation"))
 
     AddDocCmd('CreateMaskGroup', _("Create Mask Group"),
-	      sensitive_cb = 'CanCreateMaskGroup')
+              sensitive_cb = 'CanCreateMaskGroup')
     AddDocCmd('CreatePathText', _("Create Path Text"),
-	      sensitive_cb = 'CanCreatePathText')
+              sensitive_cb = 'CanCreatePathText')
     AddDocCmd('CreateClone', _("Create Clone"),
-	      sensitive_cb = 'CanCreateClone')
+              sensitive_cb = 'CanCreateClone')
 
 
     #
@@ -1235,38 +1235,38 @@
     #
 
     def CutCopySelected(self, method):
-	objects = getattr(self.document, method)()
-	if objects is not None:
-	    self.application.SetClipboard(objects)
+        objects = getattr(self.document, method)()
+        if objects is not None:
+            self.application.SetClipboard(objects)
 
     AddCmd('CopySelected', _("Copy"), 'CutCopySelected',
-	   args= ('CopyForClipboard',), subscribe_to = SELECTION,
-	   sensitive_cb = ('document', 'HasSelection'))
+           args= ('CopyForClipboard',), subscribe_to = SELECTION,
+           sensitive_cb = ('document', 'HasSelection'))
     AddCmd('CutSelected', _("Cut"), 'CutCopySelected',
-	   args= ('CutForClipboard',), subscribe_to = SELECTION,
-	   sensitive_cb = ('document', 'HasSelection'))
+           args= ('CutForClipboard',), subscribe_to = SELECTION,
+           sensitive_cb = ('document', 'HasSelection'))
     AddCmd('PasteClipboard', _("Paste"),
-	   subscribe_to = ('application', CLIPBOARD),
-	   sensitive_cb = ('application', 'ClipboardContainsData'))
+           subscribe_to = ('application', CLIPBOARD),
+           sensitive_cb = ('application', 'ClipboardContainsData'))
     def PasteClipboard(self):
-	if self.application.ClipboardContainsData():
-	    obj = self.application.GetClipboard().Object()
-	    obj = obj.Duplicate()
-	    self.canvas.PlaceObject(obj)
+        if self.application.ClipboardContainsData():
+            obj = self.application.GetClipboard().Object()
+            obj = obj.Duplicate()
+            self.canvas.PlaceObject(obj)
     #
     #	Undo/Redo
     #
 
     AddDocCmd('Undo', _("Undo"), subscribe_to = UNDO,
-	      sensitive_cb = 'CanUndo', name_cb = 'UndoMenuText',
-	      key_stroke = 'C-z', bitmap = pixmaps.Undo)
+              sensitive_cb = 'CanUndo', name_cb = 'UndoMenuText',
+              key_stroke = 'C-z', bitmap = pixmaps.Undo)
 
     AddDocCmd('Redo', _("Redo"), subscribe_to = UNDO,
-	      sensitive_cb = 'CanRedo', name_cb = 'RedoMenuText',
-	      key_stroke = 'C-r', bitmap = pixmaps.Redo)
+              sensitive_cb = 'CanRedo', name_cb = 'RedoMenuText',
+              key_stroke = 'C-r', bitmap = pixmaps.Redo)
 
     AddDocCmd('ResetUndo', _("Discard Undo History"), subscribe_to = None,
-	      sensitive_cb = None)
+              sensitive_cb = None)
 
 
 
@@ -1277,4 +1277,4 @@
     AddDocCmd('LineNone', _("No Line"), 'AddStyle', args = EmptyLineStyle)
     AddDocCmd('UpdateStyle', _("Update Style"), 'UpdateDynamicStyleSel')
 
-    
+

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/miniscroll.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/miniscroll.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/miniscroll.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -30,105 +30,105 @@
 class MiniScroller(PyWidget, Publisher):
 
     def __init__(self, master=None, min = None, max = None, step = 1,
-		 variable = None, command = None, args = (), **kw):
-	if not kw.has_key('width'):
-	    kw['width'] = 8
-	apply(PyWidget.__init__, (self, master), kw)
-	self.SetRange(min, max, step)
-	self.variable = variable
-	self.state = 0		# 1: up; 2: drag; 3: down
-	self.rect_y = 0
-	self.start = 0
-	self.start_number = min
-	if command:
-	    self.set_command(command, args)
-	self.bind('<Motion>', self.MotionEvent)
-	self.bind('<ButtonPress-1>', self.ButtonPressEvent)
-	self.bind('<ButtonRelease-1>', self.ButtonReleaseEvent)
+                 variable = None, command = None, args = (), **kw):
+        if not kw.has_key('width'):
+            kw['width'] = 8
+        apply(PyWidget.__init__, (self, master), kw)
+        self.SetRange(min, max, step)
+        self.variable = variable
+        self.state = 0		# 1: up; 2: drag; 3: down
+        self.rect_y = 0
+        self.start = 0
+        self.start_number = min
+        if command:
+            self.set_command(command, args)
+        self.bind('<Motion>', self.MotionEvent)
+        self.bind('<ButtonPress-1>', self.ButtonPressEvent)
+        self.bind('<ButtonRelease-1>', self.ButtonReleaseEvent)
 
     def ResizedMethod(self, width, height):
-	button_height = 4
-	rect_y = (height - button_height) / 2
-	self.top_poly = [(-1, rect_y), (width / 2, -1), (width, rect_y)]
-	y = button_height + rect_y
-	self.bot_poly = [(-1, y), (width, y), (width / 2, height)]
-	self.rect_y = rect_y
+        button_height = 4
+        rect_y = (height - button_height) / 2
+        self.top_poly = [(-1, rect_y), (width / 2, -1), (width, rect_y)]
+        y = button_height + rect_y
+        self.bot_poly = [(-1, y), (width, y), (width / 2, height)]
+        self.rect_y = rect_y
 
     def SetRange(self, min, max, step = 1):
-	self.min = min
-	self.max = max
-	self.step = step
+        self.min = min
+        self.max = max
+        self.step = step
 
     def set_command(self, command, args):
-	if type(args) != TupleType:
-	    args = (args,)
-	apply(self.Subscribe, (COMMAND, command,) + args)
+        if type(args) != TupleType:
+            args = (args,)
+        apply(self.Subscribe, (COMMAND, command,) + args)
 
     def invoke(self):
-	self.issue(COMMAND)
+        self.issue(COMMAND)
 
     def RedrawMethod(self, region):
-	button_height = 4
-	win = self.tkwin
-	width = win.width
-	border = self.tkborder
+        button_height = 4
+        win = self.tkwin
+        width = win.width
+        border = self.tkborder
 
-	border.Draw3DRectangle(win, 0, self.rect_y, width, button_height, 2,
-			       pax.TK_RELIEF_RAISED)
-	border.Draw3DPolygon(win, self.top_poly, -2, pax.TK_RELIEF_SUNKEN)
-	border.Draw3DPolygon(win, self.bot_poly, -2, pax.TK_RELIEF_SUNKEN)
+        border.Draw3DRectangle(win, 0, self.rect_y, width, button_height, 2,
+                               pax.TK_RELIEF_RAISED)
+        border.Draw3DPolygon(win, self.top_poly, -2, pax.TK_RELIEF_SUNKEN)
+        border.Draw3DPolygon(win, self.bot_poly, -2, pax.TK_RELIEF_SUNKEN)
 
     def y_to_state(self, y):
-	if y < self.rect_y:
-	    return 1
-	elif y < self.rect_y + 4:
-	    return 2
-	else:
-	    return 3
+        if y < self.rect_y:
+            return 1
+        elif y < self.rect_y + 4:
+            return 2
+        else:
+            return 3
 
     def set_variable(self, y):
-	if self.variable:
-	    number = self.start_number + self.step * (self.start - y)
-	    if self.min is not None and number < self.min:
-		number = self.min
-	    if self.max is not None and number > self.max:
-		number = self.max
-	    self.variable.set(number)
+        if self.variable:
+            number = self.start_number + self.step * (self.start - y)
+            if self.min is not None and number < self.min:
+                number = self.min
+            if self.max is not None and number > self.max:
+                number = self.max
+            self.variable.set(number)
 
     def MotionEvent(self, event):
-	if self.state == 0:
-	    self['cursor'] = cursors[self.y_to_state(event.y) - 1]
-	elif self.state == 2:
-	    self.set_variable(event.y)
+        if self.state == 0:
+            self['cursor'] = cursors[self.y_to_state(event.y) - 1]
+        elif self.state == 2:
+            self.set_variable(event.y)
 
     def ButtonPressEvent(self, event):
-	self.state = self.y_to_state(event.y)
-	self.start = event.y
-	if self.variable:
-	    self.start_number = self.variable.get()
+        self.state = self.y_to_state(event.y)
+        self.start = event.y
+        if self.variable:
+            self.start_number = self.variable.get()
 
     def ButtonReleaseEvent(self, event):
-	state = self.state
-	if state == 1:
-	    self.set_variable(self.start - 1)
-	elif state == 2:
-	    self.set_variable(event.y)
-	elif state == 3:
-	    self.set_variable(self.start + 1)
-	if state != 0:
-	    self.invoke()
-	self.state = 0
+        state = self.state
+        if state == 1:
+            self.set_variable(self.start - 1)
+        elif state == 2:
+            self.set_variable(event.y)
+        elif state == 3:
+            self.set_variable(self.start + 1)
+        if state != 0:
+            self.invoke()
+        self.state = 0
 
 
 
 def create_mini_entry(top, master, command, vartype = IntVar,
-		      min = 0, max = None, step = 1, scroll_pad = 2):
+                      min = 0, max = None, step = 1, scroll_pad = 2):
     var_number = vartype(top)
     entry = MyEntry(master, textvariable = var_number, justify = RIGHT,
-		    width = 6, command = command)
+                    width = 6, command = command)
     entry.pack(side = LEFT, expand = 1, fill = X, anchor = E)
     scroll = MiniScroller(master, variable = var_number, min = min, max = max,
-			  step = step)
+                          step = step)
     scroll.pack(side = LEFT, fill = Y, pady = scroll_pad)
     scroll.Subscribe(COMMAND, command)
     return var_number

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/modes.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/modes.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/modes.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -69,15 +69,15 @@
     isTemporaryMode = 0
 
     def __init__(self, enter, button_down, mouse_move, button_up,
-		 exit = noop, cancel = noop,	 **rest):
-	self.enter = enter
-	self.button_down = button_down
-	self.mouse_move = mouse_move
-	self.button_up = button_up
-	self.exit = exit
-	self.cancel = cancel
-	for key, value in rest.items():
-	    setattr(self, key, value)
+                 exit = noop, cancel = noop,	 **rest):
+        self.enter = enter
+        self.button_down = button_down
+        self.mouse_move = mouse_move
+        self.button_up = button_up
+        self.exit = exit
+        self.cancel = cancel
+        for key, value in rest.items():
+            setattr(self, key, value)
 
 
 class MajorMode(Mode):
@@ -97,41 +97,41 @@
 class WidgetWithModes:
 
     def __init__(self):
-	self.mode_stack = ()
-	self.mode = MajorMode(noop, noop, noop, noop, noop)
+        self.mode_stack = ()
+        self.mode = MajorMode(noop, noop, noop, noop, noop)
 
     def push_mode(self, mode):
-	self.mode_stack = (self.mode, self.mode_stack)
-	self.mode = mode
+        self.mode_stack = (self.mode, self.mode_stack)
+        self.mode = mode
 
     def pop_mode(self):
-	try:
-	    self.mode, self.mode_stack = self.mode_stack
-	except ValueError:
-	    raise SketchModeError('mode stack empty')
+        try:
+            self.mode, self.mode_stack = self.mode_stack
+        except ValueError:
+            raise SketchModeError('mode stack empty')
 
     def exit_temporary_mode(self, cancel = 0):
-	if self.mode.isTemporaryMode:
-	    if cancel:
-		self.mode.cancel()
-	    self.pop_mode()
+        if self.mode.isTemporaryMode:
+            if cancel:
+                self.mode.cancel()
+            self.pop_mode()
 
     def cancel_temporary_mode(self):
-	self.exit_temporary_mode(1)
+        self.exit_temporary_mode(1)
 
     def enter_mode(self, mode, *args):
-	if mode.isMajorMode:
-	    # cancel all currently active temporary modes
-	    while self.mode.isTemporaryMode:
-		self.cancel_temporary_mode()
-	    if not self.mode.isMajorMode or self.mode_stack != ():
-		raise SketchModeError('mode stack corrupted')
+        if mode.isMajorMode:
+            # cancel all currently active temporary modes
+            while self.mode.isTemporaryMode:
+                self.cancel_temporary_mode()
+            if not self.mode.isMajorMode or self.mode_stack != ():
+                raise SketchModeError('mode stack corrupted')
 
-	    self.mode.exit()
-	    self.mode = mode
-	    apply(self.mode.enter, args)
+            self.mode.exit()
+            self.mode = mode
+            apply(self.mode.enter, args)
 
-	else:
-	    self.push_mode(mode)
-	    apply(self.mode.enter, args)
+        else:
+            self.push_mode(mode)
+            apply(self.mode.enter, args)
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/optiondlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/optiondlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/optiondlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -33,91 +33,91 @@
 class OptionDialog:
 
     def __init__(self, master, main_window):
-	self.master = master
-	self.main_window = main_window
+        self.master = master
+        self.main_window = main_window
 
-	top = Toplevel(master)
-	top.title(_("Global Options"))
-	top.transient(master)
-	top.protocol('WM_DELETE_WINDOW', self.close_dlg)
+        top = Toplevel(master)
+        top.title(_("Global Options"))
+        top.transient(master)
+        top.protocol('WM_DELETE_WINDOW', self.close_dlg)
 
-	top.geometry('%+d%+d' % (master.winfo_rootx() + 100,
-				 master.winfo_rooty() + 100))
+        top.geometry('%+d%+d' % (master.winfo_rootx() + 100,
+                                 master.winfo_rooty() + 100))
 
-	self.top = top
-	self.build_dlg()
+        self.top = top
+        self.build_dlg()
 
     def make_frame(self):
-	frame = Frame(self.top, relief = GROOVE, bd = 2)
-	frame.pack(side = TOP, expand = 1, fill = X, padx = 4, pady = 4)
-	return frame
+        frame = Frame(self.top, relief = GROOVE, bd = 2)
+        frame.pack(side = TOP, expand = 1, fill = X, padx = 4, pady = 4)
+        return frame
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	#
-	#	Undo
-	#
+        #
+        #	Undo
+        #
 
-	undo_frame = self.make_frame()
-	label = Label(undo_frame, text = _("# Undo Levels:"), anchor = E)
-	label.pack(side = LEFT, expand = 1, fill = X)
+        undo_frame = self.make_frame()
+        label = Label(undo_frame, text = _("# Undo Levels:"), anchor = E)
+        label.pack(side = LEFT, expand = 1, fill = X)
 
-	self.var_undo = IntVar(top)
-	self.undo_entry = Entry(undo_frame, textvariable = self.var_undo,
-				width = 4)
-	self.undo_entry.pack(side = LEFT)
-	self.var_unlimited = IntVar(top)
-	check = UpdatedCheckbutton(undo_frame,
-				   text = _("unlimited"),
-				   variable = self.var_unlimited,
-				   command = self.unlimited_undo)
-	check.pack(side = RIGHT, expand = 1, anchor = W)
-	limit = preferences.undo_limit
-	if limit == None:
-	    self.var_undo.set(10)
-	    self.var_unlimited.set(1)
-	else:
-	    if limit < 0:
-		limit = 0
-	    self.var_undo.set(limit)
-	    self.var_unlimited.set(0)
+        self.var_undo = IntVar(top)
+        self.undo_entry = Entry(undo_frame, textvariable = self.var_undo,
+                                width = 4)
+        self.undo_entry.pack(side = LEFT)
+        self.var_unlimited = IntVar(top)
+        check = UpdatedCheckbutton(undo_frame,
+                                   text = _("unlimited"),
+                                   variable = self.var_unlimited,
+                                   command = self.unlimited_undo)
+        check.pack(side = RIGHT, expand = 1, anchor = W)
+        limit = preferences.undo_limit
+        if limit == None:
+            self.var_undo.set(10)
+            self.var_unlimited.set(1)
+        else:
+            if limit < 0:
+                limit = 0
+            self.var_undo.set(limit)
+            self.var_unlimited.set(0)
 
 
-	#
-	#	Duplication
-	#
+        #
+        #	Duplication
+        #
 
-	off_frame = self.make_frame()
-	var_off_x_number = DoubleVar(top)
-	var_off_y_number = DoubleVar(top)
-	var_off_x_unit = StringVar(top)
-	var_off_y_unit = StringVar(top)
-	x, y = preferences.duplicate_offset
+        off_frame = self.make_frame()
+        var_off_x_number = DoubleVar(top)
+        var_off_y_number = DoubleVar(top)
+        var_off_x_unit = StringVar(top)
+        var_off_y_unit = StringVar(top)
+        x, y = preferences.duplicate_offset
         unit = config.preferences.default_unit
-	self.var_off_x = LengthVar(x, unit, var_off_x_number, var_off_x_unit)
-	self.var_off_y = LengthVar(y, unit, var_off_y_number, var_off_y_unit)
-	label = Label(off_frame, text = _("Duplication Offset"))
-	label.pack(side = TOP, anchor = W)
-	label = Label(off_frame, text = _("Hor."))
-	label.pack(side = LEFT, expand = 1, anchor = E)
-	entry = MyEntry(off_frame, textvariable = var_off_x_number,
-			width = 6, command = self.var_off_x.UpdateNumber)
-	entry.pack(side = LEFT, fill = X, anchor = E)
-	label = Label(off_frame, text = _("Vert."))
-	label.pack(side = LEFT, anchor = E)
-	entry = MyEntry(off_frame, textvariable = var_off_y_number,
-			width = 6, command = self.var_off_y.UpdateNumber)
-	entry.pack(side = LEFT, fill = X, anchor = E)
+        self.var_off_x = LengthVar(x, unit, var_off_x_number, var_off_x_unit)
+        self.var_off_y = LengthVar(y, unit, var_off_y_number, var_off_y_unit)
+        label = Label(off_frame, text = _("Duplication Offset"))
+        label.pack(side = TOP, anchor = W)
+        label = Label(off_frame, text = _("Hor."))
+        label.pack(side = LEFT, expand = 1, anchor = E)
+        entry = MyEntry(off_frame, textvariable = var_off_x_number,
+                        width = 6, command = self.var_off_x.UpdateNumber)
+        entry.pack(side = LEFT, fill = X, anchor = E)
+        label = Label(off_frame, text = _("Vert."))
+        label.pack(side = LEFT, anchor = E)
+        entry = MyEntry(off_frame, textvariable = var_off_y_number,
+                        width = 6, command = self.var_off_y.UpdateNumber)
+        entry.pack(side = LEFT, fill = X, anchor = E)
 
-	def CallBoth(arg, x = self.var_off_x, y = self.var_off_y):
-	    x.UpdateUnit(arg)
-	    y.UpdateUnit(arg)
+        def CallBoth(arg, x = self.var_off_x, y = self.var_off_y):
+            x.UpdateUnit(arg)
+            y.UpdateUnit(arg)
 
-	optmenu = create_unit_menu(off_frame, CallBoth,
-				   variable = var_off_x_unit,
-				   indicatoron = 0, width = 3)
-	optmenu.pack(side = LEFT, expand = 1, anchor = W)
+        optmenu = create_unit_menu(off_frame, CallBoth,
+                                   variable = var_off_x_unit,
+                                   indicatoron = 0, width = 3)
+        optmenu.pack(side = LEFT, expand = 1, anchor = W)
 
         #
         #       Default Unit
@@ -132,63 +132,63 @@
         menu.pack(side = RIGHT, expand = 1)
 
 
-	#
-	#	Gradient Patterns
-	#
+        #
+        #	Gradient Patterns
+        #
 
-	#self.var_steps = IntVar(top)
-	#self.var_steps.set(preferences.gradient_steps)
-	#frame = self.make_frame()
-	#label = Label(frame, text = 'Gradient Steps')
+        #self.var_steps = IntVar(top)
+        #self.var_steps.set(preferences.gradient_steps)
+        #frame = self.make_frame()
+        #label = Label(frame, text = 'Gradient Steps')
 
 
-	#
-	#	Standard Buttons (OK, Cancel)
-	#
+        #
+        #	Standard Buttons (OK, Cancel)
+        #
 
-	but_frame = Frame(top)
-	but_frame.pack(side = BOTTOM, fill = BOTH, expand = 1,
-		       padx = 4, pady = 4)
-	button = UpdatedButton(but_frame, text = _("OK"), command = self.ok)
-	button.pack(side = LEFT, expand = 1)
-	button = UpdatedButton(but_frame, text = _("Cancel"),
-			       command = self.close_dlg)
-	button.pack(side = RIGHT, expand = 1)
+        but_frame = Frame(top)
+        but_frame.pack(side = BOTTOM, fill = BOTH, expand = 1,
+                       padx = 4, pady = 4)
+        button = UpdatedButton(but_frame, text = _("OK"), command = self.ok)
+        button.pack(side = LEFT, expand = 1)
+        button = UpdatedButton(but_frame, text = _("Cancel"),
+                               command = self.close_dlg)
+        button.pack(side = RIGHT, expand = 1)
 
 
     def unlimited_undo(self):
-	unlimited = self.var_unlimited.get()
-	if unlimited:
-	    self.undo_entry['state'] = DISABLED
-	else:
-	    self.undo_entry['state'] = NORMAL
+        unlimited = self.var_unlimited.get()
+        if unlimited:
+            self.undo_entry['state'] = DISABLED
+        else:
+            self.undo_entry['state'] = NORMAL
 
     def set_unit(self, unit):
         self.default_unit = unit
 
     def ok(self):
-	# undo
-	unlimited = self.var_unlimited.get()
-	if unlimited:
-	    preferences.undo_limit = None
-	else:
-	    preferences.undo_limit = self.var_undo.get()
+        # undo
+        unlimited = self.var_unlimited.get()
+        if unlimited:
+            preferences.undo_limit = None
+        else:
+            preferences.undo_limit = self.var_undo.get()
 
-	# offset
-	x = self.var_off_x.get()
-	y = self.var_off_y.get()
-	preferences.duplicate_offset = (x, y)
+        # offset
+        x = self.var_off_x.get()
+        y = self.var_off_y.get()
+        preferences.duplicate_offset = (x, y)
 
         # default unit
         preferences.default_unit = self.default_unit
 
         #
-	self.close_dlg()
+        self.close_dlg()
 
     def close_dlg(self):
-	self.main_window = None
-	self.top.destroy()
+        self.main_window = None
+        self.top.destroy()
 
     def deiconify_and_raise(self):
-	self.top.deiconify()
-	self.top.tkraise()
+        self.top.deiconify()
+        self.top.tkraise()

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/palette.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/palette.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/palette.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -41,66 +41,66 @@
     ignore_issue = 1
 
     def __init__(self):
-	self.entries = []
-	self.name_to_entry = {}
-	self.rgb_to_entry = {}
+        self.entries = []
+        self.name_to_entry = {}
+        self.rgb_to_entry = {}
 
     def Subscribe(self, channel, func, *args):
-	apply(Publisher.Subscribe, (self, channel, func) + args)
-	self.ignore_issue = 0
+        apply(Publisher.Subscribe, (self, channel, func) + args)
+        self.ignore_issue = 0
 
     def update_dicts(self):
-	self.name_to_entry = {}
-	self.rgb_to_entry = {}
-	for entry in self.entries:
-	    rgb, name = entry
-	    self.name_to_entry[name] = entry
-	    self.rgb_to_entry[rgb] = entry
+        self.name_to_entry = {}
+        self.rgb_to_entry = {}
+        for entry in self.entries:
+            rgb, name = entry
+            self.name_to_entry[name] = entry
+            self.rgb_to_entry[rgb] = entry
 
     def AddEntry(self, rgb, name = None, rename = 0):
-	if name:
-	    if self.name_to_entry.has_key(name):
-		if self.name_to_entry[name] != (rgb, name):
-		    raise NameInUse
-	if self.rgb_to_entry.has_key(rgb):
-	    if self.rgb_to_entry[rgb] != (rgb, name) and not rename:
-		raise RGBAlreadyStored
-	if not name:
-	    i = 0
-	    base = 'Color '
-	    name = base + `i`
-	    known = self.name_to_entry.has_key
-	    while known(name):
-		i = i + 1
-		name = base + `i`
-	entry = (rgb, name)
-	self.entries.append(entry)
-	self.name_to_entry[name] = entry
-	self.rgb_to_entry[rgb] = entry
-	self.issue(CHANGED)
+        if name:
+            if self.name_to_entry.has_key(name):
+                if self.name_to_entry[name] != (rgb, name):
+                    raise NameInUse
+        if self.rgb_to_entry.has_key(rgb):
+            if self.rgb_to_entry[rgb] != (rgb, name) and not rename:
+                raise RGBAlreadyStored
+        if not name:
+            i = 0
+            base = 'Color '
+            name = base + `i`
+            known = self.name_to_entry.has_key
+            while known(name):
+                i = i + 1
+                name = base + `i`
+        entry = (rgb, name)
+        self.entries.append(entry)
+        self.name_to_entry[name] = entry
+        self.rgb_to_entry[rgb] = entry
+        self.issue(CHANGED)
 
     def __getitem__(self, idx):
-	if type(idx) == StringType:
-	    return self.name_to_entry[idx]
-	if type(idx) == TupleType:
-	    return self.rgb_to_entry[idx]
-	if type(idx) == IntType:
-	    return self.entries[idx]
+        if type(idx) == StringType:
+            return self.name_to_entry[idx]
+        if type(idx) == TupleType:
+            return self.rgb_to_entry[idx]
+        if type(idx) == IntType:
+            return self.entries[idx]
 
 
     def GetRGB(self, idx):
-	return self[idx][0]
+        return self[idx][0]
 
     def Colors(self):
-	return map(operator.getitem, self.entries, [0] * len(self.entries))
+        return map(operator.getitem, self.entries, [0] * len(self.entries))
 
     def WriteFile(self, file):
-	for entry in self.entries:
-	    (r, g, b), name = entry
-	    file.write('%g %g %g\t%s\n' % (r, g, b, name))
+        for entry in self.entries:
+            (r, g, b), name = entry
+            file.write('%g %g %g\t%s\n' % (r, g, b, name))
 
     def __len__(self):
-	return len(self.entries)
+        return len(self.entries)
 
 
 
@@ -114,20 +114,20 @@
 
 #minimalistic fallback:
 _mini_pal = [(0, 0, 0, 'Black'),
-	     (1, 1, 1, 'White')]
+             (1, 1, 1, 'White')]
 
 def GetStandardPalette():
     palette = read_standard_palette(config.preferences.palette)
     if not palette:
-	warn(USER, _("Could not load palette %s; trying mini.spl..."),
-	     config.preferences.palette)
-	palette = read_standard_palette('mini.spl')
-	if not palette:
-	    warn(USER,
-		_("Could not load palette mini.spl; reverting to black&white"))
-	    palette = RGBPalette()
-	    for r, g, b, name in _mini_pal:
-		palette.AddEntry((r, g, b), name)
+        warn(USER, _("Could not load palette %s; trying mini.spl..."),
+             config.preferences.palette)
+        palette = read_standard_palette('mini.spl')
+        if not palette:
+            warn(USER,
+                 _("Could not load palette mini.spl; reverting to black&white"))
+            palette = RGBPalette()
+            for r, g, b, name in _mini_pal:
+                palette.AddEntry((r, g, b), name)
     return palette
 
 
@@ -135,7 +135,7 @@
     return read_palette_file(filename)
 
 file_types = ((_("Skencil/Sketch Palette"), '.spl'),
-	      (_("All Files"),	 '*'))
+              (_("All Files"),	 '*'))
 
 
 magic_rgb_palette = '##Sketch RGBPalette 0'
@@ -153,7 +153,7 @@
         elif line == magic_gimp_palette:
             palette = Read_X_RGB_TXT(filename)
     except:
-	warn_tb(USER)
+        warn_tb(USER)
     return palette
 
 
@@ -162,45 +162,45 @@
 
     line = file.readline()
     if line != magic_rgb_palette + '\n':
-	file.close()
-	raise ValueError, 'Invalid file type'
+        file.close()
+        raise ValueError, 'Invalid file type'
 
     palette = RGBPalette()
 
     linenr = 1
     for line in file.readlines():
-	line = strip(line)
-	linenr = linenr + 1
-	if not line or line[0] == '#':
-	    continue
+        line = strip(line)
+        linenr = linenr + 1
+        if not line or line[0] == '#':
+            continue
 
-	line = split(line, None, 3)
-               
-	if len(line) != 4:
-	    warn(INTERNAL, '%s:%d: wrong number of fields', filename, linenr)
-	    continue
-	try:
-	    rgb = tuple(map(atof, line[:3]))
-	except:
-	    warn(INTERNAL, '%s:%d: cannot parse rgb values', filename, linenr)
-	    continue
+        line = split(line, None, 3)
 
-	for value in rgb:
-	    if value < 0 or value > 1.0:
-		warn(INTERNAL, '%s:%d: value out of range', filename, linenr)
-		continue
+        if len(line) != 4:
+            warn(INTERNAL, '%s:%d: wrong number of fields', filename, linenr)
+            continue
+        try:
+            rgb = tuple(map(atof, line[:3]))
+        except:
+            warn(INTERNAL, '%s:%d: cannot parse rgb values', filename, linenr)
+            continue
 
-	name = strip(line[-1])
+        for value in rgb:
+            if value < 0 or value > 1.0:
+                warn(INTERNAL, '%s:%d: value out of range', filename, linenr)
+                continue
 
-	try:
-	    palette.AddEntry(rgb, name)
-	except NameInUse:
-	    warn(INTERNAL, '%s:%d: color name already used', filename, linenr)
-	    continue
-	except RGBAlreadyStored:
-	    warn(INTERNAL, '%s:%d: color already stored', filename, linenr)
-	    continue
+        name = strip(line[-1])
 
+        try:
+            palette.AddEntry(rgb, name)
+        except NameInUse:
+            warn(INTERNAL, '%s:%d: color name already used', filename, linenr)
+            continue
+        except RGBAlreadyStored:
+            warn(INTERNAL, '%s:%d: color already stored', filename, linenr)
+            continue
+
     file.close()
 
     return palette
@@ -215,14 +215,14 @@
     linenr = 0
     color_num = 0
     for line in file.readlines():
-	line = strip(line)
-	linenr = linenr + 1
-	if not line or line[0] in ('#', '!'):
-	    # an empty line or an X-style comment (!) or a GIMP comment (#)
-	    # GIMP's palette files have practically the same format as rgb.txt
-	    continue
+        line = strip(line)
+        linenr = linenr + 1
+        if not line or line[0] in ('#', '!'):
+            # an empty line or an X-style comment (!) or a GIMP comment (#)
+            # GIMP's palette files have practically the same format as rgb.txt
+            continue
 
-	line = split(line, None, 3)
+        line = split(line, None, 3)
         if len(line) == 3:
             # the name is missing
             while 1:
@@ -236,35 +236,35 @@
                     line.append(name)
                     break
                 color_num = color_num + 1
-	if len(line) != 4:
-	    warn(INTERNAL, '%s:%d: wrong number of fields', filename, linenr)
-	    continue
-	try:
-	    values = map(atoi, line[:3])
-	except:
-	    warn(INTERNAL, '%s:%d: cannot parse rgb values', filename, linenr)
-	    continue
+        if len(line) != 4:
+            warn(INTERNAL, '%s:%d: wrong number of fields', filename, linenr)
+            continue
+        try:
+            values = map(atoi, line[:3])
+        except:
+            warn(INTERNAL, '%s:%d: cannot parse rgb values', filename, linenr)
+            continue
 
-	rgb = []
-	for value in values:
-	    value = round(value / 255.0, 3)
-	    if value < 0:
-		value = 0.0
-	    elif value > 1.0:
-		value = 1.0
-	    rgb.append(value)
-	rgb = tuple(rgb)
+        rgb = []
+        for value in values:
+            value = round(value / 255.0, 3)
+            if value < 0:
+                value = 0.0
+            elif value > 1.0:
+                value = 1.0
+            rgb.append(value)
+        rgb = tuple(rgb)
 
-	name = strip(line[-1])
+        name = strip(line[-1])
 
-	try:
-	    palette.AddEntry(rgb, name)
-	except NameInUse:
-	    warn(INTERNAL, '%s:%d: color name already used', filename, linenr)
-	    continue
-	except RGBAlreadyStored:
-	    warn(INTERNAL, '%s:%d: color already stored', filename, linenr)
-	    continue
+        try:
+            palette.AddEntry(rgb, name)
+        except NameInUse:
+            warn(INTERNAL, '%s:%d: color name already used', filename, linenr)
+            continue
+        except RGBAlreadyStored:
+            warn(INTERNAL, '%s:%d: color already stored', filename, linenr)
+            continue
 
     file.close()
 
@@ -275,173 +275,173 @@
 class PaletteWidget(PyWidget, Publisher):
 
     def __init__(self, master=None, palette = None, cell_size = 16, **kw):
-	if not kw.has_key('height'):
-	    kw['height'] = cell_size
-	apply(PyWidget.__init__, (self, master), kw)
+        if not kw.has_key('height'):
+            kw['height'] = cell_size
+        apply(PyWidget.__init__, (self, master), kw)
 
-	self.cell_size = cell_size
-	self.num_cells = 0
-	self.gc_initialized = 0
-	self.gc = GraphicsDevice()
-	self.gc.SetViewportTransform(1.0, Identity, Identity)
-	self.start_idx = 0
-	self.palette = None
-	if palette is None:
-	    palette = RGBPalette()
-	self.SetPalette(palette)
-	self.dragging = 0
-	self.bind('<ButtonPress-1>', self.press_1)
-	self.bind('<Motion>', self.move_1)
-	self.bind('<ButtonRelease-1>', self.release_1)
-	self.bind('<ButtonRelease-2>', self.apply_color_2)
+        self.cell_size = cell_size
+        self.num_cells = 0
+        self.gc_initialized = 0
+        self.gc = GraphicsDevice()
+        self.gc.SetViewportTransform(1.0, Identity, Identity)
+        self.start_idx = 0
+        self.palette = None
+        if palette is None:
+            palette = RGBPalette()
+        self.SetPalette(palette)
+        self.dragging = 0
+        self.bind('<ButtonPress-1>', self.press_1)
+        self.bind('<Motion>', self.move_1)
+        self.bind('<ButtonRelease-1>', self.release_1)
+        self.bind('<ButtonRelease-2>', self.apply_color_2)
 
     def DestroyMethod(self):
-	self.palette.Unsubscribe(CHANGED, self.palette_changed)
-	Publisher.Destroy(self)
+        self.palette.Unsubscribe(CHANGED, self.palette_changed)
+        Publisher.Destroy(self)
 
     def compute_num_cells(self):
-	self.num_cells = self.tkwin.width / self.cell_size
+        self.num_cells = self.tkwin.width / self.cell_size
 
     def MapMethod(self):
-	self.compute_num_cells()
-	self.issue(VIEW)
-	if not self.gc_initialized:
-	    self.init_gc()
-	    self.gc_initialized = 1
+        self.compute_num_cells()
+        self.issue(VIEW)
+        if not self.gc_initialized:
+            self.init_gc()
+            self.gc_initialized = 1
 
     def init_gc(self):
-	self.gc.init_gc(self.tkwin)
+        self.gc.init_gc(self.tkwin)
 
     def get_color(self, x, y):
-	if 0 <= x < self.tkwin.width and 0 <= y < self.tkwin.height:
-	    i = self.start_idx + x / self.cell_size
-	    if i < len(self.palette):
-		return apply(CreateRGBColor, self.palette.GetRGB(i))
+        if 0 <= x < self.tkwin.width and 0 <= y < self.tkwin.height:
+            i = self.start_idx + x / self.cell_size
+            if i < len(self.palette):
+                return apply(CreateRGBColor, self.palette.GetRGB(i))
 
     def release_1(self, event):
-	try:
-	    if self.dragging:
-		self.drop_color(event)
-	    else:
-		self.apply_color_1(event)
-	finally:
-	    self.dragging = 0
+        try:
+            if self.dragging:
+                self.drop_color(event)
+            else:
+                self.apply_color_1(event)
+        finally:
+            self.dragging = 0
 
     def drop_color(self, event):
-	self['cursor'] = self.drag_old_cursor
-	w = self.winfo_containing(event.x_root, event.y_root)
-	while w and w != self:
-	    if __debug__:
-		pdebug('DND', 'trying to drop on', w)
-	    try:
-		accepts = w.accept_drop
-	    except AttributeError:
-		accepts = ()
-	    if DROP_COLOR in accepts:
-		x = event.x_root - w.winfo_rootx()
-		y = event.y_root - w.winfo_rooty()
-		w.DropAt(x, y, DROP_COLOR, self.drag_start)
-		break
-	    if w != w.winfo_toplevel():
-		parent = self.tk.call('winfo', 'parent', w._w)
-		w = self.nametowidget(parent)
-	    else:
-		break
+        self['cursor'] = self.drag_old_cursor
+        w = self.winfo_containing(event.x_root, event.y_root)
+        while w and w != self:
+            if __debug__:
+                pdebug('DND', 'trying to drop on', w)
+            try:
+                accepts = w.accept_drop
+            except AttributeError:
+                accepts = ()
+            if DROP_COLOR in accepts:
+                x = event.x_root - w.winfo_rootx()
+                y = event.y_root - w.winfo_rooty()
+                w.DropAt(x, y, DROP_COLOR, self.drag_start)
+                break
+            if w != w.winfo_toplevel():
+                parent = self.tk.call('winfo', 'parent', w._w)
+                w = self.nametowidget(parent)
+            else:
+                break
 
 
     def apply_color_1(self, event):
-	c = self.get_color(event.x, event.y)
-	if c:
-	    self.issue(COLOR1, c)
+        c = self.get_color(event.x, event.y)
+        if c:
+            self.issue(COLOR1, c)
 
     def apply_color_2(self, event):
-	c = self.get_color(event.x, event.y)
-	if c:
-	    self.issue(COLOR2, c)
+        c = self.get_color(event.x, event.y)
+        if c:
+            self.issue(COLOR2, c)
 
     drag_start = (0, 0, 0)
     def press_1(self, event):
-	self.drag_start = self.get_color(event.x, event.y)
+        self.drag_start = self.get_color(event.x, event.y)
 
     def move_1(self, event):
-	if event.state & X.Button1Mask:
-	    if not self.dragging:
-		self.dragging = 1
-		self.drag_old_cursor = self['cursor']
-		self['cursor'] = CurDragColor
-	    w = self.winfo_containing(event.x_root, event.y_root)
+        if event.state & X.Button1Mask:
+            if not self.dragging:
+                self.dragging = 1
+                self.drag_old_cursor = self['cursor']
+                self['cursor'] = CurDragColor
+            w = self.winfo_containing(event.x_root, event.y_root)
 
     def Palette(self):
-	return self.palette
+        return self.palette
 
     def SetPalette(self, palette):
-	if self.palette is not None:
-	    self.palette.Unsubscribe(CHANGED, self.palette_changed)
-	self.palette = palette
-	self.palette.Subscribe(CHANGED, self.palette_changed)
-	self.palette_changed()
+        if self.palette is not None:
+            self.palette.Unsubscribe(CHANGED, self.palette_changed)
+        self.palette = palette
+        self.palette.Subscribe(CHANGED, self.palette_changed)
+        self.palette_changed()
 
     def palette_changed(self):
-	self.compute_num_cells()
-	self.normalize_start()
-	self.issue(VIEW)
-	self.UpdateWhenIdle()
+        self.compute_num_cells()
+        self.normalize_start()
+        self.issue(VIEW)
+        self.UpdateWhenIdle()
 
     def RedrawMethod(self, region = None):
-	win = self.tkwin
-	width = win.width
-	height = win.height
-	self.gc.StartDblBuffer()
-	self.gc.SetFillColor(StandardColors.white)
-	self.gc.FillRectangle(0, 0, width, height)
+        win = self.tkwin
+        width = win.width
+        height = win.height
+        self.gc.StartDblBuffer()
+        self.gc.SetFillColor(StandardColors.white)
+        self.gc.FillRectangle(0, 0, width, height)
 
-	x = 0
-	FillRectangle = self.gc.FillRectangle
-	SetFillColor = self.gc.SetFillColor
-	create_color = CreateRGBColor
-	rgbs = self.palette.Colors()
-	rgbs = rgbs[self.start_idx:self.start_idx + self.num_cells]
-	for rgb in rgbs:
-	    SetFillColor(apply(create_color, rgb))
-	    FillRectangle(x, 0, x + height, height)
-	    x = x + height
-	self.gc.EndDblBuffer()
+        x = 0
+        FillRectangle = self.gc.FillRectangle
+        SetFillColor = self.gc.SetFillColor
+        create_color = CreateRGBColor
+        rgbs = self.palette.Colors()
+        rgbs = rgbs[self.start_idx:self.start_idx + self.num_cells]
+        for rgb in rgbs:
+            SetFillColor(apply(create_color, rgb))
+            FillRectangle(x, 0, x + height, height)
+            x = x + height
+        self.gc.EndDblBuffer()
 
     def ResizedMethod(self, width, height):
-	self.compute_num_cells()
-	self.gc.WindowResized(width, height)
-	self.normalize_start()
-	self.UpdateWhenIdle()
+        self.compute_num_cells()
+        self.gc.WindowResized(width, height)
+        self.normalize_start()
+        self.UpdateWhenIdle()
 
     def normalize_start(self):
-	length = len(self.palette)
-	if self.start_idx < 0:
-	    self.start_idx = 0
-	if length < self.num_cells:
-	    self.start_idx = 0
-	elif length - self.start_idx < self.num_cells:
-	    self.start_idx = length - self.num_cells
+        length = len(self.palette)
+        if self.start_idx < 0:
+            self.start_idx = 0
+        if length < self.num_cells:
+            self.start_idx = 0
+        elif length - self.start_idx < self.num_cells:
+            self.start_idx = length - self.num_cells
 
     def CanScrollLeft(self):
-	return self.start_idx > 0
+        return self.start_idx > 0
 
     def CanScrollRight(self):
-	return len(self.palette) - self.start_idx > self.num_cells
+        return len(self.palette) - self.start_idx > self.num_cells
 
     def ScrollXPages(self, count):
-	length = self.tkwin.width / self.cell_size
-	start = self.start_idx
-	self.start_idx = self.start_idx + count * length
-	self.normalize_start()
-	if start != self.start_idx:
-	    self.UpdateWhenIdle()
-	    self.issue(VIEW)
+        length = self.tkwin.width / self.cell_size
+        start = self.start_idx
+        self.start_idx = self.start_idx + count * length
+        self.normalize_start()
+        if start != self.start_idx:
+            self.UpdateWhenIdle()
+            self.issue(VIEW)
 
     def ScrollXUnits(self, count):
-	start = self.start_idx
-	self.start_idx = self.start_idx + count
-	self.normalize_start()
-	if start != self.start_idx:
-	    self.UpdateWhenIdle()
-	    self.issue(VIEW)
+        start = self.start_idx
+        self.start_idx = self.start_idx + count
+        self.normalize_start()
+        if start != self.start_idx:
+            self.UpdateWhenIdle()
+            self.issue(VIEW)
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/plugindlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/plugindlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/plugindlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -71,219 +71,219 @@
 class Parameter:
 
     def __init__(self, panel, name, value, range, label):
-	self.name = name
-	self.value = value
-	self.range = range
-	self.label = label
-	self.var = None
-	self.panel = panel
+        self.name = name
+        self.value = value
+        self.range = range
+        self.label = label
+        self.var = None
+        self.panel = panel
 
 
     def build_widgets(self, master, row):
-	label = Label(master, text = self.label)
-	label.grid(row = row, column = 0, sticky = E)
+        label = Label(master, text = self.label)
+        label.grid(row = row, column = 0, sticky = E)
 
     def __call__(self, *args):
-	if args:
-	    self.var.set(args[0])
-	else:
-	    return self.var.get()
+        if args:
+            self.var.set(args[0])
+        else:
+            return self.var.get()
 
 parameter_types = {}
 
 class NumberParameter(Parameter):
 
     def is_valid(self):
-	value = self.var.get()
-	min, max = self.range
-	if min is not None and min > value:
-	    return 0
-	if max is not None and max < value:
-	    return 0
-	return 1
+        value = self.var.get()
+        min, max = self.range
+        if min is not None and min > value:
+            return 0
+        if max is not None and max < value:
+            return 0
+        return 1
 
     def init_var(self):
-	lo, hi = self.range
-	value = self.value
-	if lo is None:
-	    if hi is not None:
-		if value > hi:
-		    value = hi
-	else:
-	    if hi is None:
-		if value < lo:
-		    value = lo
-	    else:
-		value = max(lo, min(hi, value))
-	if value != self.value:
-	    warn(USER,
-		 'Initial value in parameter %s of plugin %s out of range',
-		 self.name, self.panel.title)
-	self.var.set(value)
+        lo, hi = self.range
+        value = self.value
+        if lo is None:
+            if hi is not None:
+                if value > hi:
+                    value = hi
+        else:
+            if hi is None:
+                if value < lo:
+                    value = lo
+            else:
+                value = max(lo, min(hi, value))
+        if value != self.value:
+            warn(USER,
+                 'Initial value in parameter %s of plugin %s out of range',
+                 self.name, self.panel.title)
+        self.var.set(value)
 
     def var_changed(self, *rest):
-	if self.is_valid():
-	    self.panel.set_parameter(self)
+        if self.is_valid():
+            self.panel.set_parameter(self)
 
     def build_widgets(self, master, row, build_entry = 1):
-	self.init_var()
-	Parameter.build_widgets(self, master, row)
-	if build_entry:
-	    entry = MyEntry(master, textvariable = self.var, justify = RIGHT,
-			    width = 6, command = self.var_changed)
-	    entry.grid(row = row, column = 1, sticky = 'ew')
-	    min, max = self.range
-	    scroll = MiniScroller(master, variable = self.var,
-				  min = min, max = max, step = 1)
-	    scroll.grid(row = row, column = 2, sticky = 'news')
+        self.init_var()
+        Parameter.build_widgets(self, master, row)
+        if build_entry:
+            entry = MyEntry(master, textvariable = self.var, justify = RIGHT,
+                            width = 6, command = self.var_changed)
+            entry.grid(row = row, column = 1, sticky = 'ew')
+            min, max = self.range
+            scroll = MiniScroller(master, variable = self.var,
+                                  min = min, max = max, step = 1)
+            scroll.grid(row = row, column = 2, sticky = 'news')
 
 
 class IntParameter(NumberParameter):
 
     def build_widgets(self, master, row):
-	self.var = IntVar(master)
-	NumberParameter.build_widgets(self, master, row)
+        self.var = IntVar(master)
+        NumberParameter.build_widgets(self, master, row)
 
 parameter_types['int'] = IntParameter
 
 class FloatParameter(NumberParameter):
 
     def build_widgets(self, master, row):
-	self.var = DoubleVar(master)
-	NumberParameter.build_widgets(self, master, row)
+        self.var = DoubleVar(master)
+        NumberParameter.build_widgets(self, master, row)
 
 parameter_types['float'] = FloatParameter
 
 class LengthParameter(NumberParameter):
 
     def build_widgets(self, master, row):
-	self.var, entry, scroll, menu = create_length_widgets(master, master,
-							      self.var_changed)
-	NumberParameter.build_widgets(self, master, row, build_entry = 0)
-	entry.grid(row = row, column = 1, sticky = 'ew')
-	scroll.grid(row = row, column = 2, sticky = 'ns')
-	menu.grid(row = row, column = 3)
+        self.var, entry, scroll, menu = create_length_widgets(master, master,
+                                                              self.var_changed)
+        NumberParameter.build_widgets(self, master, row, build_entry = 0)
+        entry.grid(row = row, column = 1, sticky = 'ew')
+        scroll.grid(row = row, column = 2, sticky = 'ns')
+        menu.grid(row = row, column = 3)
 
 parameter_types['length'] = LengthParameter
 
 class TextParameter(Parameter):
 
     def build_widgets(self, master, row):
-	Parameter.build_widgets(self, master, row)
-	self.var = StringVar(master)
-	self.var.set(self.value)
-	entry = MyEntry(master, textvariable = self.var, width = 0,
-			command = self.var_changed)
-	entry.grid(row = row, column = 1, columnspan = 3, sticky = 'ew')
+        Parameter.build_widgets(self, master, row)
+        self.var = StringVar(master)
+        self.var.set(self.value)
+        entry = MyEntry(master, textvariable = self.var, width = 0,
+                        command = self.var_changed)
+        entry.grid(row = row, column = 1, columnspan = 3, sticky = 'ew')
 
     def var_changed(self, *rest):
-	self.panel.set_parameter(self)
+        self.panel.set_parameter(self)
 
 parameter_types['text'] = TextParameter
 
 class PluginPanel(PropertyPanel):
 
     def __init__(self, master, main_window, doc, info):
-	self.var_auto_update = IntVar(master)
-	self.var_auto_update.set(1)
-	self.info = info
-	self.title = info.menu_text
-	self.vars = []
-	name = 'dlg' + info.class_name
-	PropertyPanel.__init__(self, master, main_window, doc, name = name)
+        self.var_auto_update = IntVar(master)
+        self.var_auto_update.set(1)
+        self.info = info
+        self.title = info.menu_text
+        self.vars = []
+        name = 'dlg' + info.class_name
+        PropertyPanel.__init__(self, master, main_window, doc, name = name)
 
     def build_dlg(self):
-	top = self.top
-	row = 0
+        top = self.top
+        row = 0
 
-	for row in range(len(self.info.parameters)):
-	    name, type, value, prange, label = self.info.parameters[row]
-	    try:
-		#print name, type, value, prange, label
-		var = parameter_types[type](self, name, value, prange, label)
-		var.build_widgets(top, row)
-		self.vars.append(var)
-	    except KeyError:
-		warn(USER, 'Unknown plugin parameter type %s' % type)
-		continue
-	row = row + 1
-	top.columnconfigure(0, weight = 0)
-	top.columnconfigure(1, weight = 1)
-	top.columnconfigure(2, weight = 0)
-	top.columnconfigure(3, weight = 0)
+        for row in range(len(self.info.parameters)):
+            name, type, value, prange, label = self.info.parameters[row]
+            try:
+                #print name, type, value, prange, label
+                var = parameter_types[type](self, name, value, prange, label)
+                var.build_widgets(top, row)
+                self.vars.append(var)
+            except KeyError:
+                warn(USER, 'Unknown plugin parameter type %s' % type)
+                continue
+        row = row + 1
+        top.columnconfigure(0, weight = 0)
+        top.columnconfigure(1, weight = 1)
+        top.columnconfigure(2, weight = 0)
+        top.columnconfigure(3, weight = 0)
 
 
-	frame = self.create_std_buttons(top)
-	frame.grid(row = row, columnspan = 4, sticky = 'ew')
+        frame = self.create_std_buttons(top)
+        frame.grid(row = row, columnspan = 4, sticky = 'ew')
 
     def set_parameter(self, var):
-	if not self.current_is_plugin():
-	    return
-	doc = self.document
-	doc.BeginTransaction(_("Set %s") % var.label) # NLS
-	try:
-	    try:
-		kw = {var.name: var()}
-		doc.AddUndo(self.current_object().SetParameters(kw))
-	    except:
-		doc.AbortTransaction()
-	finally:
-	    doc.EndTransaction()
+        if not self.current_is_plugin():
+            return
+        doc = self.document
+        doc.BeginTransaction(_("Set %s") % var.label) # NLS
+        try:
+            try:
+                kw = {var.name: var()}
+                doc.AddUndo(self.current_object().SetParameters(kw))
+            except:
+                doc.AbortTransaction()
+        finally:
+            doc.EndTransaction()
 
     def can_apply(self):
-	return 1
+        return 1
 
     def do_apply(self):
-	if self.current_is_plugin():
-	    doc = self.document
-	    doc.BeginTransaction(_("Set Parameters"))
-	    try:
-		try:
-		    kw = {}
-		    for var in self.vars:
-			kw[var.name] = var()
-		    doc.AddUndo(self.current_object().SetParameters(kw))
-		except:
-		    doc.AbortTransaction()
-	    finally:
-		doc.EndTransaction()
-	else:
-	    # create that object
-	    dict = {}
-	    for var in self.vars:
-		dict[var.name] = var()
-	    obj = apply(self.info.Constructor(), (), dict)
-	    text = 'Create ' + self.info.menu_text # NLS
-	    self.main_window.canvas.PlaceObject(obj, text)
+        if self.current_is_plugin():
+            doc = self.document
+            doc.BeginTransaction(_("Set Parameters"))
+            try:
+                try:
+                    kw = {}
+                    for var in self.vars:
+                        kw[var.name] = var()
+                    doc.AddUndo(self.current_object().SetParameters(kw))
+                except:
+                    doc.AbortTransaction()
+            finally:
+                doc.EndTransaction()
+        else:
+            # create that object
+            dict = {}
+            for var in self.vars:
+                dict[var.name] = var()
+            obj = apply(self.info.Constructor(), (), dict)
+            text = 'Create ' + self.info.menu_text # NLS
+            self.main_window.canvas.PlaceObject(obj, text)
 
 
     def current_is_plugin(self):
-	o = self.document.CurrentObject()
-	return o is not None and o.is_Plugin and \
-	       o.class_name == self.info.class_name
+        o = self.document.CurrentObject()
+        return o is not None and o.is_Plugin and \
+               o.class_name == self.info.class_name
 
     def current_object(self):
-	return self.document.CurrentObject()
+        return self.document.CurrentObject()
 
     def init_from_doc(self):
-	self.Update()
-	self.issue(SELECTION)
+        self.Update()
+        self.issue(SELECTION)
 
     def Update(self):
-	if self.current_is_plugin():
-	    object = self.current_object()
-	    for var in self.vars:
-		var(getattr(object, capwords(var.name))())
+        if self.current_is_plugin():
+            object = self.current_object()
+            for var in self.vars:
+                var(getattr(object, capwords(var.name))())
 
     def update_from_object_cb(self, obj):
         print 'update_from_object_cb', obj
         while not obj.is_Plugin and not obj.is_Layer:
             obj = obj.parent
-	if obj.is_Plugin and obj.class_name == self.info.class_name:
+        if obj.is_Plugin and obj.class_name == self.info.class_name:
             for var in self.vars:
                 print 'update_from_object_cb', var
-		var(getattr(obj, capwords(var.name))())
+                var(getattr(obj, capwords(var.name))())
 
     def close_dlg(self):
-	self.vars = []
-	PropertyPanel.close_dlg(self)
+        self.vars = []
+        PropertyPanel.close_dlg(self)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/poslabel.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/poslabel.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/poslabel.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -23,46 +23,46 @@
 
 # NLS:
 formats = {'in': '(%3.3f", %3.3f")',
-	   'pt': '(%3.1fpt, %3.1fpt)',
-	   'cm': '(%2.2fcm, %2.2fcm)',
-	   'mm': '(%3.1fmm, %3.1fmm)',
-	   }
+           'pt': '(%3.1fpt, %3.1fpt)',
+           'cm': '(%2.2fcm, %2.2fcm)',
+           'mm': '(%3.1fmm, %3.1fmm)',
+           }
 
 class PositionLabel(UpdatedLabel):
 
     context_menu = None
 
     def __init__(self, *args, **kw):
-	apply(UpdatedLabel.__init__, (self,) + args, kw)
-	self.bind('<ButtonPress-3>', self.popup_context_menu)
+        apply(UpdatedLabel.__init__, (self,) + args, kw)
+        self.bind('<ButtonPress-3>', self.popup_context_menu)
         self.set_unit(config.preferences.default_unit)
         config.preferences.Subscribe(CHANGED, self.preference_changed)
 
     def Update(self, *rest):
-	if self.sensitivecb:
-	    self.SetSensitive(self.sensitivecb())
-	if self.updatecb and self.update_field:
-	    x, y = self.updatecb()
-	    x = x / self.factor
-	    y = y / self.factor
-	    self[self.update_field] = self.format % (x, y)
+        if self.sensitivecb:
+            self.SetSensitive(self.sensitivecb())
+        if self.updatecb and self.update_field:
+            x, y = self.updatecb()
+            x = x / self.factor
+            y = y / self.factor
+            self[self.update_field] = self.format % (x, y)
 
     def popup_context_menu(self, event):
-	if self.context_menu is None:
-	    items = []
-	    set_unit = self.SetUnit
-	    for unit in unit_names:
-		items.append(MenuCommand(unit, set_unit, unit))
-	    self.context_menu = UpdatedMenu(self, items, tearoff = 0)
-	self.context_menu.Popup(event.x_root, event.y_root)
+        if self.context_menu is None:
+            items = []
+            set_unit = self.SetUnit
+            for unit in unit_names:
+                items.append(MenuCommand(unit, set_unit, unit))
+            self.context_menu = UpdatedMenu(self, items, tearoff = 0)
+        self.context_menu.Popup(event.x_root, event.y_root)
 
     def set_unit(self, unit):
         self.factor = unit_dict[unit]
         self.format = formats[unit]
         self.Update()
-        
+
     def SetUnit(self, unit):
-	self.unit = unit
+        self.unit = unit
         if config.preferences.poslabel_sets_default_unit:
             config.preferences.default_unit = unit
         else:

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/printdlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/printdlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/printdlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -37,81 +37,81 @@
     title = _("Print")
 
     def __init__(self, master, main_window, doc):
-	SketchPanel.__init__(self, master, main_window, doc, name = 'printdlg')
+        SketchPanel.__init__(self, master, main_window, doc, name = 'printdlg')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	# The preview widget
-	self.view = SketchView(top, self.document, width = 200, height = 200,
-			       background = 'white')
-	self.view.pack(side = TOP, fill = BOTH, expand = 1)
+        # The preview widget
+        self.view = SketchView(top, self.document, width = 200, height = 200,
+                               background = 'white')
+        self.view.pack(side = TOP, fill = BOTH, expand = 1)
 
-	# PostScript Options
-	frame = Frame(top, name = "options")
-	frame.pack(side = TOP, fill = X)
-	#	EPS
-	#self.var_create_eps = IntVar(top)
-	#self.var_create_eps.set(1)
-	#button = Checkbutton(frame, text = _("Create EPS file"),
-	#		      variable = self.var_create_eps)
-	#button.pack(side = LEFT, expand = 1, fill = X)
-	#	Rotate
-	self.var_rotate = IntVar(top)
-	self.var_rotate.set(0)
-	button = Checkbutton(frame, text = _("Rotate ccw."),
-			     variable = self.var_rotate)
-	button.pack(side = LEFT, expand = 1, fill = X)
-	#    Embed fonts
-	self.var_embfnt = IntVar(top)
-	self.var_embfnt.set(0)
-	button = Checkbutton(frame, text = _("Embed fonts"),
-	                     variable = self.var_embfnt)
-	button.pack(side = LEFT, expand = 1, fill = X)
+        # PostScript Options
+        frame = Frame(top, name = "options")
+        frame.pack(side = TOP, fill = X)
+        #	EPS
+        #self.var_create_eps = IntVar(top)
+        #self.var_create_eps.set(1)
+        #button = Checkbutton(frame, text = _("Create EPS file"),
+        #		      variable = self.var_create_eps)
+        #button.pack(side = LEFT, expand = 1, fill = X)
+        #	Rotate
+        self.var_rotate = IntVar(top)
+        self.var_rotate.set(0)
+        button = Checkbutton(frame, text = _("Rotate ccw."),
+                             variable = self.var_rotate)
+        button.pack(side = LEFT, expand = 1, fill = X)
+        #    Embed fonts
+        self.var_embfnt = IntVar(top)
+        self.var_embfnt.set(0)
+        button = Checkbutton(frame, text = _("Embed fonts"),
+                             variable = self.var_embfnt)
+        button.pack(side = LEFT, expand = 1, fill = X)
 
 
-	# Print Command and Filename
-	frame = Frame(top, name = "command")
-	frame.pack(side = TOP)
-	self.print_dest = StringVar(top)
-	button = Radiobutton(frame, text = _("Printer"), value = 'printer',
-			     variable = self.print_dest, anchor = 'w')
-	button.grid(column = 0,row = 0, sticky = 'ew')
-	label = Label(frame, text = _("Command"), anchor = 'e')
-	label.grid(column = 1, row = 0, sticky = 'ew')
-	self.print_command = StringVar(top)
-	self.print_command.set('lpr')
-	entry = MyEntry(frame, textvariable = self.print_command)
-	entry.grid(column = 2, row = 0, sticky = 'ew')
+        # Print Command and Filename
+        frame = Frame(top, name = "command")
+        frame.pack(side = TOP)
+        self.print_dest = StringVar(top)
+        button = Radiobutton(frame, text = _("Printer"), value = 'printer',
+                             variable = self.print_dest, anchor = 'w')
+        button.grid(column = 0,row = 0, sticky = 'ew')
+        label = Label(frame, text = _("Command"), anchor = 'e')
+        label.grid(column = 1, row = 0, sticky = 'ew')
+        self.print_command = StringVar(top)
+        self.print_command.set('lpr')
+        entry = MyEntry(frame, textvariable = self.print_command)
+        entry.grid(column = 2, row = 0, sticky = 'ew')
 
-	button = Radiobutton(frame, text = _("EPS"), value = 'file',
-			     variable = self.print_dest, anchor = 'w')
-	button.grid(column = 0, row = 1, sticky = 'ew')
-	label = Label(frame, text = _("Filename"), anchor = 'e')
-	label.grid(column = 1, row = 1, sticky = 'ew')
-	self.print_filename = StringVar(top)
-	self.print_filename.set('')
-	entry = MyEntry(frame, textvariable = self.print_filename)
-	entry.grid(column = 2, row = 1, sticky = 'ew')
-	button = UpdatedButton(frame, text = _("..."),
-			       command = self.get_filename)
-	button.grid(column = 3, row = 1, sticky = 'ew')
+        button = Radiobutton(frame, text = _("EPS"), value = 'file',
+                             variable = self.print_dest, anchor = 'w')
+        button.grid(column = 0, row = 1, sticky = 'ew')
+        label = Label(frame, text = _("Filename"), anchor = 'e')
+        label.grid(column = 1, row = 1, sticky = 'ew')
+        self.print_filename = StringVar(top)
+        self.print_filename.set('')
+        entry = MyEntry(frame, textvariable = self.print_filename)
+        entry.grid(column = 2, row = 1, sticky = 'ew')
+        button = UpdatedButton(frame, text = _("..."),
+                               command = self.get_filename)
+        button.grid(column = 3, row = 1, sticky = 'ew')
 
-	frame = Frame(top)
-	frame.pack(side = TOP)
-	button = UpdatedButton(frame, text = _("Print"),
-			       command = self.do_print)
-	button.pack(side = LEFT)
-	button = UpdatedButton(frame, text = _("Close"),
-			       command = self.close_dlg)
-	button.pack(side = LEFT)
+        frame = Frame(top)
+        frame.pack(side = TOP)
+        button = UpdatedButton(frame, text = _("Print"),
+                               command = self.do_print)
+        button.pack(side = LEFT)
+        button = UpdatedButton(frame, text = _("Close"),
+                               command = self.close_dlg)
+        button.pack(side = LEFT)
 
-	# init vars
-	self.print_dest.set(config.preferences.print_destination)
+        # init vars
+        self.print_dest.set(config.preferences.print_destination)
 
     def init_from_doc(self):
-	self.view.SetDocument(self.document)
-	self.print_filename.set(self.default_filename())
+        self.view.SetDocument(self.document)
+        self.print_filename.set(self.default_filename())
 
     def get_filename(self):
         app = self.main_window.application
@@ -128,15 +128,15 @@
             self.print_filename.set(filename)
 
     def default_filename(self):
-	dir = self.document.meta.ps_directory
-	if not dir:
-	    dir = self.document.meta.directory
-	if not dir:
-	    dir = os.getcwd()
+        dir = self.document.meta.ps_directory
+        if not dir:
+            dir = self.document.meta.directory
+        if not dir:
+            dir = os.getcwd()
 
-	name = self.document.meta.filename
-	name, ext = os.path.splitext(name)
-	return os.path.join(dir, name + '.ps')
+        name = self.document.meta.filename
+        name, ext = os.path.splitext(name)
+        return os.path.join(dir, name + '.ps')
 
 
     def do_print(self):

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/prompt.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/prompt.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/prompt.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -51,7 +51,7 @@
     dict['connections'] = connector._the_connector.print_connections
     dict['get_sketch_modules'] = get_sketch_modules
     for key, val in user_functions.items():
-	dict[key] = val
+        dict[key] = val
 
 
 
@@ -62,44 +62,44 @@
     # try to import readline in Python 1.5
     have_readline = 0
     try:
-	import readline
-	have_readline = 1
-	Sketch.Issue(None, Sketch.const.INIT_READLINE)
+        import readline
+        have_readline = 1
+        Sketch.Issue(None, Sketch.const.INIT_READLINE)
     except ImportError:
-	pass
+        pass
     globals = {}
     # put all of Sketch.main and Sketch into the globals
     exec 'from Sketch.main import *' in globals
     exec 'from Sketch import *' in globals
     # put all sketch specific modules into the globals
     for module in get_sketch_modules():
-	globals[module.__name__] = module
+        globals[module.__name__] = module
     add_sketch_objects(globals)
     if have_readline:
-	from Sketch.Lib import skcompleter
-	skcompleter.install(globals, locals)
+        from Sketch.Lib import skcompleter
+        skcompleter.install(globals, locals)
     while 1:
-	try:
-	    cmd = raw_input(prompt)
-	    #cmd = string.strip(cmd)
-	    if cmd:
-		if cmd[-1] == ':':
-		    # a compound statement
-		    lines = []
-		    while string.strip(cmd):
-			lines.append(cmd)
-			cmd = raw_input(prompt2)
-		    cmd = string.join(lines + [''], '\n')
-		    kind = 'exec'
-		else:
-		    kind = 'single'
+        try:
+            cmd = raw_input(prompt)
+            #cmd = string.strip(cmd)
+            if cmd:
+                if cmd[-1] == ':':
+                    # a compound statement
+                    lines = []
+                    while string.strip(cmd):
+                        lines.append(cmd)
+                        cmd = raw_input(prompt2)
+                    cmd = string.join(lines + [''], '\n')
+                    kind = 'exec'
+                else:
+                    kind = 'single'
 
-		c = compile(cmd, '<string>', kind)
-		exec c in globals, locals
-	except EOFError:
-	    print '----- returning to Sketch'
-	    return
-	except:
-	    import traceback
-	    traceback.print_tb(sys.exc_traceback)
-	    print 'Exception %s: %s' % (sys.exc_type, sys.exc_value)
+                c = compile(cmd, '<string>', kind)
+                exec c in globals, locals
+        except EOFError:
+            print '----- returning to Sketch'
+            return
+        except:
+            import traceback
+            traceback.print_tb(sys.exc_traceback)
+            print 'Exception %s: %s' % (sys.exc_type, sys.exc_value)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/reloaddlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/reloaddlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/reloaddlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -34,52 +34,52 @@
     receivers = []
 
     def __init__(self, master, main_window, doc):
-	SketchPanel.__init__(self, master, main_window, doc,
-			     name = 'reloaddlg')
+        SketchPanel.__init__(self, master, main_window, doc,
+                             name = 'reloaddlg')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	list_frame = Frame(top)
-	list_frame.pack(side = TOP, expand = 1, fill = BOTH)
+        list_frame = Frame(top)
+        list_frame.pack(side = TOP, expand = 1, fill = BOTH)
 
-	sb_vert = Scrollbar(list_frame, takefocus = 0)
-	sb_vert.pack(side = RIGHT, fill = Y)
-	module_list = UpdatedListbox(list_frame, name = 'list')
-	module_list.pack(expand = 1, fill = BOTH)
-	module_list.Subscribe(COMMAND, self.do_reload)
-	sb_vert['command'] = (module_list, 'yview')
-	module_list['yscrollcommand'] = (sb_vert, 'set')
-	self.module_list = module_list
+        sb_vert = Scrollbar(list_frame, takefocus = 0)
+        sb_vert.pack(side = RIGHT, fill = Y)
+        module_list = UpdatedListbox(list_frame, name = 'list')
+        module_list.pack(expand = 1, fill = BOTH)
+        module_list.Subscribe(COMMAND, self.do_reload)
+        sb_vert['command'] = (module_list, 'yview')
+        module_list['yscrollcommand'] = (sb_vert, 'set')
+        self.module_list = module_list
 
-	frame = Frame(top)
-	frame.pack(side = BOTTOM, fill = X)
-	for text, cmd in [('Reload Module', self.do_reload),
-			  ('Update List', self.update_list),
-			  ('Close', self.close_dlg)]:
-	    button = UpdatedButton(frame, text = text, command = cmd)
-	    button.pack(side = TOP, fill = X, expand = 1)
+        frame = Frame(top)
+        frame.pack(side = BOTTOM, fill = X)
+        for text, cmd in [('Reload Module', self.do_reload),
+                          ('Update List', self.update_list),
+                          ('Close', self.close_dlg)]:
+            button = UpdatedButton(frame, text = text, command = cmd)
+            button.pack(side = TOP, fill = X, expand = 1)
 
-	self.update_list()
+        self.update_list()
 
 
     def init_from_doc(self):
-	pass
+        pass
 
     def update_list(self):
-	modules = prompt.get_sketch_modules()
-	modules = map(lambda mod: (mod.__name__, mod), modules)
-	modules.sort()
-	names = map(operator.getitem, modules, [0] * len(modules))
-	self.module_list.SetList(names)
-	self.modules = modules
+        modules = prompt.get_sketch_modules()
+        modules = map(lambda mod: (mod.__name__, mod), modules)
+        modules.sort()
+        names = map(operator.getitem, modules, [0] * len(modules))
+        self.module_list.SetList(names)
+        self.modules = modules
 
     def do_reload(self):
-	index = self.module_list.curselection()
-	index = string.atoi(index[0])
+        index = self.module_list.curselection()
+        index = string.atoi(index[0])
 
-	pdebug(None, 'reloading', self.modules[index])
-	try:
-	    reload(self.modules[index][1])
-	except:
-	    warn_tb(INTERNAL)
+        pdebug(None, 'reloading', self.modules[index])
+        try:
+            reload(self.modules[index][1])
+        except:
+            warn_tb(INTERNAL)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/ruler.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -46,28 +46,28 @@
 class Ruler(PyWidget):
 
     def __init__(self, master=None, orient = HORIZONTAL, canvas = None, **kw):
-	apply(PyWidget.__init__, (self, master), kw)
-	self.orient = orient
+        apply(PyWidget.__init__, (self, master), kw)
+        self.orient = orient
         self.canvas = canvas
-	self.gcs_initialized = 0
-	self.gc = None
+        self.gcs_initialized = 0
+        self.gc = None
         self.positions = None
-	self.SetRange(0.0, 1.0, force = 1)
+        self.SetRange(0.0, 1.0, force = 1)
         if orient == VERTICAL:
             self.text_type = config.preferences.ruler_text_type
         else:
             self.text_type = 'horizontal'
-	font = None
-	fontname = config.preferences.ruler_font
-	try:
-	    font = self.tkwin.LoadQueryFont(fontname)
-	except:
-	    # NLS
-	    warn(USER, 'Could not load font %s for ruler. using defaults.',
-		 `fontname`)
+        font = None
+        fontname = config.preferences.ruler_font
+        try:
+            font = self.tkwin.LoadQueryFont(fontname)
+        except:
+            # NLS
+            warn(USER, 'Could not load font %s for ruler. using defaults.',
+                 `fontname`)
             font = self.tkwin.LoadQueryFont('fixed')
-	self.font = font
-        
+        self.font = font
+
         font = None
         if self.text_type == 'rotated':
             fontname = config.preferences.ruler_font_rotated
@@ -80,68 +80,68 @@
         self.rotated_font = font
         if not self.rotated_font and self.text_type == 'rotated':
             self.text_type = 'horizontal'
-            
-	border_width = self.option_get('borderWidth', 'BorderWidth')
-	if border_width:
-	    self.border_width = atoi(border_width)
-	else:
-	    self.border_width = 0
 
+        border_width = self.option_get('borderWidth', 'BorderWidth')
+        if border_width:
+            self.border_width = atoi(border_width)
+        else:
+            self.border_width = 0
+
         height = self.font.ascent + self.font.descent \
-                 + self.border_width + tick_lengths[0]
-	if orient == HORIZONTAL:
-	    self['height'] = height
-	else:
+               + self.border_width + tick_lengths[0]
+        if orient == HORIZONTAL:
+            self['height'] = height
+        else:
             if self.text_type == 'rotated':
                 self['width'] = height
             elif self.text_type == 'vertical':
                 self['width'] = self.font.TextWidth('0') + self.border_width \
-                        + tick_lengths[0]
+                    + tick_lengths[0]
             else: # horizontal
                 width = self.font.TextWidth('000') + self.border_width \
-                        + tick_lengths[0]
+                      + tick_lengths[0]
                 self['width'] = width
 
-	self.bind('<ButtonPress>', self.ButtonPressEvent)
-	self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
-	self.bind('<Motion>', self.PointerMotionEvent)
+        self.bind('<ButtonPress>', self.ButtonPressEvent)
+        self.bind('<ButtonRelease>', self.ButtonReleaseEvent)
+        self.bind('<Motion>', self.PointerMotionEvent)
         self.button_down = 0
         self.forward_motion = 0
 
         config.preferences.Subscribe(CHANGED, self.preference_changed)
 
     def destroy(self):
-	PyWidget.destroy(self)
+        PyWidget.destroy(self)
         self.canvas = None
 
     def MapMethod(self):
-	if not self.gcs_initialized:
-	    self.init_gcs()
-	    self.gcs_initialized = 1
+        if not self.gcs_initialized:
+            self.init_gcs()
+            self.gcs_initialized = 1
 
     def init_gcs(self):
-	cmap = self.tkwin.colormap()
-	foreground = cmap.AllocColor(0, 0, 0)[0]
-	attrs = {'foreground': foreground, 'line_width':0}
+        cmap = self.tkwin.colormap()
+        foreground = cmap.AllocColor(0, 0, 0)[0]
+        attrs = {'foreground': foreground, 'line_width':0}
         if not self.rotated_font:
             if self.font:
                 attrs['font'] = self.font
         else:
             attrs['font'] = self.rotated_font
-	self.gc = self.tkwin.GetGC(attrs)
+        self.gc = self.tkwin.GetGC(attrs)
         if self.font is None:
             self.font = self.gc.font
 
     def ResizedMethod(self, width, height):
-	self.SetRange(self.start, self.pixel_per_pt, force = 1)
+        self.SetRange(self.start, self.pixel_per_pt, force = 1)
 
     def SetRange(self, start, pixel_per_pt, force = 0):
-	if not force and start==self.start and pixel_per_pt==self.pixel_per_pt:
-	    return
-	self.start = start
-	self.pixel_per_pt = pixel_per_pt
+        if not force and start==self.start and pixel_per_pt==self.pixel_per_pt:
+            return
+        self.start = start
+        self.pixel_per_pt = pixel_per_pt
         self.positions = None
-	self.UpdateWhenIdle()
+        self.UpdateWhenIdle()
 
     def preference_changed(self, pref, value):
         if pref == 'default_unit':
@@ -155,11 +155,11 @@
         min_text_step = config.preferences.ruler_min_text_step
         max_text_step = config.preferences.ruler_max_text_step
         min_tick_step = config.preferences.ruler_min_tick_step
-	if self.orient == HORIZONTAL:
-	    length = self.tkwin.width
+        if self.orient == HORIZONTAL:
+            length = self.tkwin.width
             origin = self.start
-	else:
-	    length = self.tkwin.height
+        else:
+            length = self.tkwin.height
             origin = self.start - length / self.pixel_per_pt
         unit_name = config.preferences.default_unit
         pt_per_unit = units.unit_dict[unit_name]
@@ -187,7 +187,7 @@
                     break
                 ticks = ticks * subdivisions[depth]
             subdivisions = subdivisions[:depth + 1]
-        
+
         positions = range(int(num_ticks * ticks))
         positions = map(operator.mul, [tick_step] * len(positions), positions)
         positions = map(operator.add, positions,
@@ -235,41 +235,41 @@
         self.texts = texts
 
         return self.positions, self.texts
-        
 
+
     def RedrawMethod(self, region = None):
-	pixmap = self.tkwin.CreatePixmap()
-	width = self.tkwin.width
-	height = self.tkwin.height
-	bd = self.border_width
-	self.gc.SetDrawable(pixmap)
-	self.tkborder.Fill3DRectangle(pixmap, 0, 0, width, height,
-				      bd, pax.TK_RELIEF_RAISED);
-	if self.orient == HORIZONTAL:
-	    self.draw_ruler_horizontal()
-	else:
-	    self.draw_ruler_vertical()
-	self.gc.SetDrawable(self.tkwin)
-	pixmap.CopyArea(self.tkwin, self.gc, 0, 0, width, height, 0, 0)
+        pixmap = self.tkwin.CreatePixmap()
+        width = self.tkwin.width
+        height = self.tkwin.height
+        bd = self.border_width
+        self.gc.SetDrawable(pixmap)
+        self.tkborder.Fill3DRectangle(pixmap, 0, 0, width, height,
+                                      bd, pax.TK_RELIEF_RAISED);
+        if self.orient == HORIZONTAL:
+            self.draw_ruler_horizontal()
+        else:
+            self.draw_ruler_vertical()
+        self.gc.SetDrawable(self.tkwin)
+        pixmap.CopyArea(self.tkwin, self.gc, 0, 0, width, height, 0, 0)
 
 
     def draw_ruler_horizontal(self):
-	darkgc = self.tkborder.BorderGC(pax.TK_3D_DARK_GC)
-	darkgc.SetDrawable(self.gc.drawable)
-	lightgc = self.tkborder.BorderGC(pax.TK_3D_LIGHT_GC)
-	lightgc.SetDrawable(self.gc.drawable)
-	DrawString = self.gc.DrawString
-	DrawDarkLine = darkgc.DrawLine
-	DrawLightLine = lightgc.DrawLine
-	TextWidth = self.font.TextWidth
-	descent = self.font.descent
-	height = self.tkwin.height
-        
+        darkgc = self.tkborder.BorderGC(pax.TK_3D_DARK_GC)
+        darkgc.SetDrawable(self.gc.drawable)
+        lightgc = self.tkborder.BorderGC(pax.TK_3D_LIGHT_GC)
+        lightgc.SetDrawable(self.gc.drawable)
+        DrawString = self.gc.DrawString
+        DrawDarkLine = darkgc.DrawLine
+        DrawLightLine = lightgc.DrawLine
+        TextWidth = self.font.TextWidth
+        descent = self.font.descent
+        height = self.tkwin.height
+
         ticks, texts = self.get_positions()
         for h, pos in ticks:
-	    DrawDarkLine(pos, height, pos, height - h)
-	    pos = pos + 1
-	    DrawLightLine(pos, height, pos, height - h)
+            DrawDarkLine(pos, height, pos, height - h)
+            pos = pos + 1
+            DrawLightLine(pos, height, pos, height - h)
 
         y = height - tick_lengths[0] - descent
         for text, pos in texts:
@@ -281,24 +281,24 @@
             DrawString(pos - tw / 2, y, text)
 
     def draw_ruler_vertical(self):
-	darkgc = self.tkborder.BorderGC(pax.TK_3D_DARK_GC)
-	darkgc.SetDrawable(self.gc.drawable)
-	lightgc = self.tkborder.BorderGC(pax.TK_3D_LIGHT_GC)
-	lightgc.SetDrawable(self.gc.drawable)
-	DrawString = self.gc.DrawString
-	DrawDarkLine = darkgc.DrawLine
-	DrawLightLine = lightgc.DrawLine
+        darkgc = self.tkborder.BorderGC(pax.TK_3D_DARK_GC)
+        darkgc.SetDrawable(self.gc.drawable)
+        lightgc = self.tkborder.BorderGC(pax.TK_3D_LIGHT_GC)
+        lightgc.SetDrawable(self.gc.drawable)
+        DrawString = self.gc.DrawString
+        DrawDarkLine = darkgc.DrawLine
+        DrawLightLine = lightgc.DrawLine
         descent = self.font.descent
-	height = self.tkwin.height
+        height = self.tkwin.height
         width = self.tkwin.width
-	font_height = self.font.ascent + self.font.descent
+        font_height = self.font.ascent + self.font.descent
 
         ticks, texts = self.get_positions()
         for h, pos in ticks:
             pos = height - pos
-	    DrawDarkLine(width - h, pos, width, pos)
-	    pos = pos + 1
-	    DrawLightLine(width - h, pos, width, pos)
+            DrawDarkLine(width - h, pos, width, pos)
+            pos = pos + 1
+            DrawLightLine(width - h, pos, width, pos)
 
         if self.text_type == 'rotated':
             TextWidth = self.font.TextWidth
@@ -336,7 +336,7 @@
         if event.num == const.Button1:
             self.button_down = 1
             self.pressevent = event
-        
+
     def ButtonReleaseEvent(self, event):
         if event.num == const.Button1:
             self.button_down = 0

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/skapp.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/skapp.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/skapp.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -47,11 +47,11 @@
     ('compressed', ''),			# was compressed (by gzip or bzip2)
     ('compressed_file', ''),		# filename of compressed file
     ('load_messages', ''),		# (warning) messages
-    ]
+]
 
 for key, val in meta_defaults:
     if not hasattr(document.MetaInfo, key):
-	setattr(document.MetaInfo, key, val)
+        setattr(document.MetaInfo, key, val)
 
 #
 #	file type info
@@ -60,7 +60,7 @@
 def openfiletypes():
     types = [(_("Skencil/Sketch Document"), '.sk')]
     for info in plugins.import_plugins:
-	types.append(info.tk_file_type)
+        types.append(info.tk_file_type)
     types.append((_("All Files"), '*'))
     types = tuple(types)
     return types
@@ -68,22 +68,22 @@
 def savefiletypes():
     types = [(_("Skencil/Sketch Document"), '.sk')]
     for info in plugins.export_plugins:
-	types.append(info.tk_file_type)
+        types.append(info.tk_file_type)
     types = tuple(types)
     return types
 
 psfiletypes = (('PostScript', '.ps'),)
 
 imagefiletypes = ((_("All Files"), '*'),
-		  (_("Encapsulated PostScript"), ('.eps', '.ps')),
-		  (_("JPEG"),	('.jpg', '.jpeg')),
-		  (_("GIF"),	'.gif'),
-		  (_("Portable Bitmap"),	'.pbm'),
-		  (_("Portable Graymap"),	'.pgm'),
-		  (_("Portable Pixmap"),	'.ppm'),
-		  (_("TIFF"),	('.tif', '.tiff')),
-		  (_("Windows / OS/2 Bitmap"), '.bmp'),
-		  (_("PCX"),	'.pcx'))
+                  (_("Encapsulated PostScript"), ('.eps', '.ps')),
+                  (_("JPEG"),	('.jpg', '.jpeg')),
+                  (_("GIF"),	'.gif'),
+                  (_("Portable Bitmap"),	'.pbm'),
+                  (_("Portable Graymap"),	'.pgm'),
+                  (_("Portable Pixmap"),	'.ppm'),
+                  (_("TIFF"),	('.tif', '.tiff')),
+                  (_("Windows / OS/2 Bitmap"), '.bmp'),
+                  (_("PCX"),	'.pcx'))
 bitmapfiletypes = imagefiletypes[:1] + imagefiletypes[2:]
 
 
@@ -98,12 +98,12 @@
     tk_class_name = ''
 
     def __init__(self, screen_name = None, geometry = None):
-	self.init_tk(screen_name, geometry)
+        self.init_tk(screen_name, geometry)
 
     def init_tk(self, screen_name = None, geometry = None):
-	self.root = Tk(screenName = screen_name,
-		       baseName = self.tk_basename,
-		       className = self.tk_class_name)
+        self.root = Tk(screenName = screen_name,
+                       baseName = self.tk_basename,
+                       className = self.tk_class_name)
         # Reset locale again to make sure we get properly translated
         # messages if desired by the user. For some reason it may
         # have been reset by Tcl/Tk.
@@ -119,54 +119,54 @@
             except:
                 pass
 
-	if not geometry:
-	    # try to read geometry from resource database
-	    geometry = self.root.option_get('geometry', 'Geometry')
-	if geometry:
-	    try:
-		self.root.geometry(geometry)
-	    except TclError:
-		sys.stderr.write('%s: invalid geometry specification %s'
-				 % (self.tk_basename, geometry))
+        if not geometry:
+            # try to read geometry from resource database
+            geometry = self.root.option_get('geometry', 'Geometry')
+        if geometry:
+            try:
+                self.root.geometry(geometry)
+            except TclError:
+                sys.stderr.write('%s: invalid geometry specification %s'
+                                 % (self.tk_basename, geometry))
 
     def Mainloop(self):
-	self.root.mainloop()
+        self.root.mainloop()
 
     def MessageBox(self, *args, **kw):
-	return apply(tkext.MessageDialog, (self.root,) + args, kw)
+        return apply(tkext.MessageDialog, (self.root,) + args, kw)
 
     def GetOpenFilename(self, **kwargs):
-	return apply(tkext.GetOpenFilename, (self.root,), kwargs)
+        return apply(tkext.GetOpenFilename, (self.root,), kwargs)
 
     def GetSaveFilename(self, **kwargs):
-	return apply(tkext.GetSaveFilename, (self.root,), kwargs)
+        return apply(tkext.GetSaveFilename, (self.root,), kwargs)
 
     clipboard = None
 
     def EmptyClipboard(self):
-	self.SetClipboard(None)
+        self.SetClipboard(None)
 
     def SetClipboard(self, data):
-	self.clipboard = data
+        self.clipboard = data
 
     def GetClipboard(self):
-	return self.clipboard
+        return self.clipboard
 
     def ClipboardContainsData(self):
-	return self.clipboard is not None
+        return self.clipboard is not None
 
 
 class ClipboardWrapper:
 
     def __init__(self, object):
-	self.object = object
+        self.object = object
 
     def __del__(self):
-	pdebug('__del__', '__del__', self)
-	self.object.Destroy()
+        pdebug('__del__', '__del__', self)
+        self.object.Destroy()
 
     def Object(self):
-	return self.object
+        return self.object
 
 
 class SketchApplication(TkApplication, Publisher):
@@ -176,52 +176,52 @@
 
     def __init__(self, filename, screen_name = None, geometry = None,
                  run_script = None):
-	self.filename = filename
+        self.filename = filename
         self.run_script = run_script
-	TkApplication.__init__(self, screen_name = screen_name,
-			       geometry = geometry)
-	self.build_window()
+        TkApplication.__init__(self, screen_name = screen_name,
+                               geometry = geometry)
+        self.build_window()
 
     def issue_clipboard(self):
-	self.issue(CLIPBOARD)
+        self.issue(CLIPBOARD)
 
     def SetClipboard(self, data):
-	if data is not None:
-	    data = ClipboardWrapper(data)
-	TkApplication.SetClipboard(self, data)
-	self.issue_clipboard()
+        if data is not None:
+            data = ClipboardWrapper(data)
+        TkApplication.SetClipboard(self, data)
+        self.issue_clipboard()
 
     def AskUser(self, title, message):
-	return self.MessageBox(title = title, message = message,
-			       buttons = tkext.YesNo) == tkext.Yes
+        return self.MessageBox(title = title, message = message,
+                               buttons = tkext.YesNo) == tkext.Yes
 
     def Run(self):
-	self.SetClipboard(None)
-	tooltips.Init(self.root)
-	self.main_window.UpdateCommands()
-	# Enter Main Loop
-	self.main_window.Run()
+        self.SetClipboard(None)
+        tooltips.Init(self.root)
+        self.main_window.UpdateCommands()
+        # Enter Main Loop
+        self.main_window.Run()
 
     def Exit(self):
         pixmaps.clear_cache()
-	self.root.destroy()
+        self.root.destroy()
 
     def init_tk(self, screen_name = None, geometry = None):
-	TkApplication.init_tk(self, screen_name = screen_name,
-			      geometry = geometry)
-	root = self.root
-	Sketch.init_modules_from_widget(root)
-	root.iconbitmap(pixmaps.Icon)
-	root.iconmask(pixmaps.Icon_mask)
-	root.iconname('Skencil')
-	root.group(root)
-	config.add_options(root)
+        TkApplication.init_tk(self, screen_name = screen_name,
+                              geometry = geometry)
+        root = self.root
+        Sketch.init_modules_from_widget(root)
+        root.iconbitmap(pixmaps.Icon)
+        root.iconmask(pixmaps.Icon_mask)
+        root.iconname('Skencil')
+        root.group(root)
+        config.add_options(root)
 
     def build_window(self):
-	from mainwindow import SketchMainWindow
-	self.main_window = SketchMainWindow(self, self.filename,
+        from mainwindow import SketchMainWindow
+        self.main_window = SketchMainWindow(self, self.filename,
                                             self.run_script)
 
     def SavePreferences(self, *args):
-	config.save_user_preferences()
+        config.save_user_preferences()
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/sketchdlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/sketchdlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/sketchdlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -91,148 +91,148 @@
     y_correction = 0
 
     def __init__(self, master, main_window, doc, **kw):
-	self.master = master
-	self.main_window = main_window
-	self.document = None
+        self.master = master
+        self.main_window = main_window
+        self.document = None
 
-	kw['class'] = self.class_name
-	top = apply(Toplevel, (master,), kw)
-	top.title(self.title)
-	self.pref_pos_name = 'dlg_pos_' + self.__class__.__name__
-	if config.preferences.panel_use_coordinates:
-	    posx, posy = config.get_preference(self.pref_pos_name, (0.1, 0.1))
-	    # avoid confusing behaviour of panels if the position is negative
-	    # or > 1:
-	    posx = max(min(posx, 1), 0)
-	    posy = max(min(posy, 1), 0)
+        kw['class'] = self.class_name
+        top = apply(Toplevel, (master,), kw)
+        top.title(self.title)
+        self.pref_pos_name = 'dlg_pos_' + self.__class__.__name__
+        if config.preferences.panel_use_coordinates:
+            posx, posy = config.get_preference(self.pref_pos_name, (0.1, 0.1))
+            # avoid confusing behaviour of panels if the position is negative
+            # or > 1:
+            posx = max(min(posx, 1), 0)
+            posy = max(min(posy, 1), 0)
 
-	    posx = master.winfo_rootx() + int(posx * master.winfo_width())
-	    posy = master.winfo_rooty() + int(posy * master.winfo_height())
-	    top.geometry('%+d%+d' % (posx, posy))
+            posx = master.winfo_rootx() + int(posx * master.winfo_width())
+            posy = master.winfo_rooty() + int(posy * master.winfo_height())
+            top.geometry('%+d%+d' % (posx, posy))
 
-	top.transient(master)
-	top.group(master)
-	top.iconname(self.title)
-	top.iconbitmap(pixmaps.Icon)
-	top.iconmask(pixmaps.Icon_mask)
-	top.protocol('WM_DELETE_WINDOW',
-		     tkext.MakeMethodCommand(self.close_dlg))
-	# the following is a workaround for a Tkinter bug. Tkinter 1.63
-	# doesn't like bindings for the Destroy event.
-	top.tk.call('bind', top._w, '<Destroy>',
-		    tkext.MakeMethodCommand(self.destroyed) + ('%W',))
+        top.transient(master)
+        top.group(master)
+        top.iconname(self.title)
+        top.iconbitmap(pixmaps.Icon)
+        top.iconmask(pixmaps.Icon_mask)
+        top.protocol('WM_DELETE_WINDOW',
+                     tkext.MakeMethodCommand(self.close_dlg))
+        # the following is a workaround for a Tkinter bug. Tkinter 1.63
+        # doesn't like bindings for the Destroy event.
+        top.tk.call('bind', top._w, '<Destroy>',
+                    tkext.MakeMethodCommand(self.destroyed) + ('%W',))
 
-	self.top = top
-	self.build_dlg()
-	self.SetDocument(doc)
+        self.top = top
+        self.build_dlg()
+        self.SetDocument(doc)
 
-	self.main_window.Subscribe(DOCUMENT, self.doc_changed)
+        self.main_window.Subscribe(DOCUMENT, self.doc_changed)
 
-	if config.preferences.panel_use_coordinates \
-	   and config.preferences.panel_correct_wm:
-	    if not top.winfo_ismapped():
-		top.wait_visibility()
-	    self.x_correction = posx - top.winfo_rootx()
-	    self.y_correction = posy - top.winfo_rooty()
+        if config.preferences.panel_use_coordinates \
+           and config.preferences.panel_correct_wm:
+            if not top.winfo_ismapped():
+                top.wait_visibility()
+            self.x_correction = posx - top.winfo_rootx()
+            self.y_correction = posy - top.winfo_rooty()
 
     if __debug__:
-	def __del__(self):
-	    pdebug('__del__', '__del__', self)
+        def __del__(self):
+            pdebug('__del__', '__del__', self)
 
     def deiconify_and_raise(self):
-	self.top.deiconify()
-	self.top.tkraise()
+        self.top.deiconify()
+        self.top.tkraise()
 
     def withdraw(self):
-	self.top.withdraw()
+        self.top.withdraw()
 
     def doc_changed(self, doc):
-	self.SetDocument(doc)
+        self.SetDocument(doc)
 
     def doc_has_selection(self):
-	return self.document.HasSelection()
+        return self.document.HasSelection()
 
     def destroyed(self, widget, *args):
-	if widget == self.top._w:
-	    self.save_prefs()
+        if widget == self.top._w:
+            self.save_prefs()
 
     def subscribe_receivers(self):
-	for info in self.receivers:
-	    apply(self.document.Subscribe,
-		  (info[0], getattr(self, info[1])) + info[2:])
+        for info in self.receivers:
+            apply(self.document.Subscribe,
+                  (info[0], getattr(self, info[1])) + info[2:])
 
     def unsubscribe_receivers(self):
-	for info in self.receivers:
-	    apply(self.document.Unsubscribe,
-		  (info[0], getattr(self, info[1])) + info[2:])
+        for info in self.receivers:
+            apply(self.document.Unsubscribe,
+                  (info[0], getattr(self, info[1])) + info[2:])
 
     def SetDocument(self, doc):
-	if self.document:
-	    self.unsubscribe_receivers()
-	self.document = doc
-	self.init_from_doc()
-	self.subscribe_receivers()
+        if self.document:
+            self.unsubscribe_receivers()
+        self.document = doc
+        self.init_from_doc()
+        self.subscribe_receivers()
 
     def save_prefs(self):
-	# Save preferences. Called when dialog is closed.
-	master = self.master
-	top = self.top
-	width = float(master.winfo_width())
-	height = float(master.winfo_height())
-	posx = (top.winfo_rootx() + self.x_correction - master.winfo_rootx())\
-	       / width
-	posy = (top.winfo_rooty() + self.y_correction - master.winfo_rooty())\
-	       / height
-	setattr(config.preferences, self.pref_pos_name, (posx, posy))
+        # Save preferences. Called when dialog is closed.
+        master = self.master
+        top = self.top
+        width = float(master.winfo_width())
+        height = float(master.winfo_height())
+        posx = (top.winfo_rootx() + self.x_correction - master.winfo_rootx())\
+             / width
+        posy = (top.winfo_rooty() + self.y_correction - master.winfo_rooty())\
+             / height
+        setattr(config.preferences, self.pref_pos_name, (posx, posy))
 
     def close_dlg(self):
-	self.issue(CLOSED, self)
-	if self.document:
-	    self.unsubscribe_receivers()
-	self.document = None
-	try:
-	    self.main_window.Unsubscribe(DOCUMENT, self.doc_changed)
-	except:
-	    warn_tb(INTERNAL)
-	self.main_window = None
-	Publisher.Destroy(self)
-	self.save_prefs()
-	self.top.destroy()
-	self.master = None
-	import pax
-	pax.unregister_object(self)
+        self.issue(CLOSED, self)
+        if self.document:
+            self.unsubscribe_receivers()
+        self.document = None
+        try:
+            self.main_window.Unsubscribe(DOCUMENT, self.doc_changed)
+        except:
+            warn_tb(INTERNAL)
+        self.main_window = None
+        Publisher.Destroy(self)
+        self.save_prefs()
+        self.top.destroy()
+        self.master = None
+        import pax
+        pax.unregister_object(self)
 
     def create_std_buttons(self, master):
-	frame = Frame(master)
+        frame = Frame(master)
 
-	button = UpdatedButton(frame, text = _("Apply"),
-			       command = self.do_apply,
-			       sensitivecb = self.can_apply)
-	button.pack(side = LEFT, expand = 1, fill = X)
-	button = UpdatedButton(frame, text = _("Close"),
-			       command = self.close_dlg)
-	button.pack(side = RIGHT, expand = 1, fill = X)
+        button = UpdatedButton(frame, text = _("Apply"),
+                               command = self.do_apply,
+                               sensitivecb = self.can_apply)
+        button.pack(side = LEFT, expand = 1, fill = X)
+        button = UpdatedButton(frame, text = _("Close"),
+                               command = self.close_dlg)
+        button.pack(side = RIGHT, expand = 1, fill = X)
 
-	return frame
+        return frame
 
     def build_dlg(self):
-	# Build the dialog window. Must be provided by the subclasses.
-	pass
+        # Build the dialog window. Must be provided by the subclasses.
+        pass
 
     def init_from_doc(self):
-	# Called whenever the document changes and from __init__
-	pass
+        # Called whenever the document changes and from __init__
+        pass
 
     def Update(self):
-	# Called when the selection changes.
-	pass
+        # Called when the selection changes.
+        pass
 
     def do_apply(self):
-	# called by the `Apply' standard button to apply the settings
-	pass
+        # called by the `Apply' standard button to apply the settings
+        pass
 
     def can_apply(self):
-	return 1
+        return 1
 
 
 class PropertyPanel(SketchPanel):
@@ -240,50 +240,50 @@
     receivers = SketchPanel.receivers[:]
 
     def __init__(self, master, main_window, doc, *args, **kw):
-	self.var_auto_update = IntVar(master)
-	self.var_auto_update.set(1)
-	apply(SketchPanel.__init__, (self, master, main_window, doc) +args, kw)
+        self.var_auto_update = IntVar(master)
+        self.var_auto_update.set(1)
+        apply(SketchPanel.__init__, (self, master, main_window, doc) +args, kw)
 
     receivers.append((SELECTION, 'selection_changed'))
     receivers.append((EDITED, 'selection_changed'))
     def selection_changed(self, *args):
-	if self.var_auto_update.get():
-	    self.Update()
+        if self.var_auto_update.get():
+            self.Update()
 
     def create_std_buttons(self, master, update_from = 1):
-	button_frame = Frame(master)
+        button_frame = Frame(master)
 
-	button = Checkbutton(button_frame, text = _("Auto Update"),
-			     variable = self.var_auto_update)
-	button.pack(side = TOP, expand = 1, fill = X)
+        button = Checkbutton(button_frame, text = _("Auto Update"),
+                             variable = self.var_auto_update)
+        button.pack(side = TOP, expand = 1, fill = X)
 
-	if update_from:
-	    button = UpdatedButton(button_frame, text = _("Update From..."),
-				   command = self.update_from_object)
-	    button.pack(side = TOP, expand = 1, fill = X)
+        if update_from:
+            button = UpdatedButton(button_frame, text = _("Update From..."),
+                                   command = self.update_from_object)
+            button.pack(side = TOP, expand = 1, fill = X)
 
-	button = UpdatedButton(button_frame, text = _("Apply"),
-			       command = self.do_apply,
-			       sensitivecb = self.can_apply)
-	button.pack(side = LEFT, expand = 1, fill = X)
-	self.Subscribe(SELECTION, button.Update)
-	button = UpdatedButton(button_frame, text = _("Close"),
-			       command = self.close_dlg)
-	button.pack(side = RIGHT, expand = 1, fill = X)
+        button = UpdatedButton(button_frame, text = _("Apply"),
+                               command = self.do_apply,
+                               sensitivecb = self.can_apply)
+        button.pack(side = LEFT, expand = 1, fill = X)
+        self.Subscribe(SELECTION, button.Update)
+        button = UpdatedButton(button_frame, text = _("Close"),
+                               command = self.close_dlg)
+        button.pack(side = RIGHT, expand = 1, fill = X)
 
-	return button_frame
+        return button_frame
 
     def update_from_object(self):
-	self.main_window.canvas.PickObject(self.update_from_object_cb)
+        self.main_window.canvas.PickObject(self.update_from_object_cb)
 
     def update_from_object_cb(self, obj):
-	pass
+        pass
 
     can_apply = SketchPanel.doc_has_selection
 
     def SetDocument(self, doc):
-	SketchPanel.SetDocument(self, doc)
-	self.selection_changed()
+        SketchPanel.SetDocument(self, doc)
+        self.selection_changed()
 
 
 class StylePropertyPanel(PropertyPanel):
@@ -317,80 +317,80 @@
     focus_widget = None
 
     def __init__(self, master, **kw):
-	self.master = master
+        self.master = master
 
-	kw['class'] = self.class_name
-	top = apply(Toplevel, (master,), kw)
-	top.title(self.title)
-	top.transient(master)
-	top.group(master)
-	top.iconname(self.title)
-	top.iconbitmap(pixmaps.Icon)
-	top.iconmask(pixmaps.Icon_mask)
-	top.protocol('WM_DELETE_WINDOW', self.close_dlg)
+        kw['class'] = self.class_name
+        top = apply(Toplevel, (master,), kw)
+        top.title(self.title)
+        top.transient(master)
+        top.group(master)
+        top.iconname(self.title)
+        top.iconbitmap(pixmaps.Icon)
+        top.iconmask(pixmaps.Icon_mask)
+        top.protocol('WM_DELETE_WINDOW', self.close_dlg)
 
-	self.top = top
-	self.build_dlg()
-	mcx = master.winfo_rootx() + master.winfo_width()/ 2
-	mcy = master.winfo_rooty() + master.winfo_height() / 2
-	top.withdraw()
-	top.update()
-	width = top.winfo_reqwidth()
-	height = top.winfo_reqheight()
-	posx = max(min(top.winfo_screenwidth() - width, mcx - width / 2), 0)
-	posy = max(min(top.winfo_screenheight() - height, mcy - height / 2), 0)
-	top.geometry('%+d%+d' % (posx, posy))
-	top.deiconify()
+        self.top = top
+        self.build_dlg()
+        mcx = master.winfo_rootx() + master.winfo_width()/ 2
+        mcy = master.winfo_rooty() + master.winfo_height() / 2
+        top.withdraw()
+        top.update()
+        width = top.winfo_reqwidth()
+        height = top.winfo_reqheight()
+        posx = max(min(top.winfo_screenwidth() - width, mcx - width / 2), 0)
+        posy = max(min(top.winfo_screenheight() - height, mcy - height / 2), 0)
+        top.geometry('%+d%+d' % (posx, posy))
+        top.deiconify()
 
-	self.result = None
+        self.result = None
 
     if __debug__:
-	def __del__(self):
-	    pdebug('__del__', '__del__', self)
+        def __del__(self):
+            pdebug('__del__', '__del__', self)
 
     def build_dlg(self):
-	pass
+        pass
 
     def ok(self, *args):
-	self.close_dlg()
+        self.close_dlg()
 
     def cancel(self):
-	self.close_dlg(None)
+        self.close_dlg(None)
 
     def close_dlg(self, result = None):
-	self.result = result
-	if self.old_focus is not None:
-	    self.old_focus.focus_set()
-	    self.old_focus = None
-	self.top.destroy()
+        self.result = result
+        if self.old_focus is not None:
+            self.old_focus.focus_set()
+            self.old_focus = None
+        self.top.destroy()
 
     def RunDialog(self, grab = 1):
-	try:
-	    self.old_focus = self.top.focus_get()
-	except KeyError:
-	    # focus_get fails when the focus widget is a torn-off menu,
-	    # since there#s no corresponding Tkinter object.
-	    self.old_focus = None
-	grab_widget = None
-	if grab:
-	    if not self.top.winfo_ismapped():
-		self.top.wait_visibility()
-	    grab_widget = self.top.grab_current()
-	    if grab_widget is not None:
-		grab_status = grab_widget.grab_status()
-	    self.top.grab_set()
-	if self.focus_widget is not None:
-	    self.focus_widget.focus_set()
-	else:
-	    self.top.focus_set()
-	self.result = None
-	self.master.wait_window(self.top)
-	if grab_widget is not None:
-	    if grab_status == 'global':
-		grab_widget.grab_set_global()
-	    else:
-		grab_widget.grab_set()
-	return self.result
+        try:
+            self.old_focus = self.top.focus_get()
+        except KeyError:
+            # focus_get fails when the focus widget is a torn-off menu,
+            # since there#s no corresponding Tkinter object.
+            self.old_focus = None
+        grab_widget = None
+        if grab:
+            if not self.top.winfo_ismapped():
+                self.top.wait_visibility()
+            grab_widget = self.top.grab_current()
+            if grab_widget is not None:
+                grab_status = grab_widget.grab_status()
+            self.top.grab_set()
+        if self.focus_widget is not None:
+            self.focus_widget.focus_set()
+        else:
+            self.top.focus_set()
+        self.result = None
+        self.master.wait_window(self.top)
+        if grab_widget is not None:
+            if grab_status == 'global':
+                grab_widget.grab_set_global()
+            else:
+                grab_widget.grab_set()
+        return self.result
 
 
 class MessageDialog(SKModal):
@@ -398,36 +398,36 @@
     class_name = 'SKMessageDialog'
 
     def __init__(self, master, title, message, buttons = _("OK"), default = 0,
-		 bitmap = 'warning', dlgname = '__dialog__'):
-	self.title = title
-	self.message = message
-	if type(buttons) != type(()):
-	    buttons = (buttons,)
-	self.buttons = buttons
-	self.default = default
-	self.bitmap = bitmap
-	SKModal.__init__(self, master, name = dlgname)
+                 bitmap = 'warning', dlgname = '__dialog__'):
+        self.title = title
+        self.message = message
+        if type(buttons) != type(()):
+            buttons = (buttons,)
+        self.buttons = buttons
+        self.default = default
+        self.bitmap = bitmap
+        SKModal.__init__(self, master, name = dlgname)
 
     def build_dlg(self):
-	top = self.top
-	frame = Frame(top, name = 'top')
-	frame.pack(side = TOP, fill = BOTH, expand = 1)
+        top = self.top
+        frame = Frame(top, name = 'top')
+        frame.pack(side = TOP, fill = BOTH, expand = 1)
         bitmap = pixmaps.load_image(self.bitmap)
         if type(bitmap) == StringType:
             label = Label(frame, bitmap = bitmap, name = 'bitmap')
         else:
             label = Label(frame, image = bitmap, name = 'bitmap')
-	label.pack(side = LEFT, padx = 5, pady = 5)
-	label = Label(frame, text = self.message, name = 'msg')
-	label.pack(side = RIGHT, fill = BOTH, expand = 1, padx = 5, pady = 5)
+        label.pack(side = LEFT, padx = 5, pady = 5)
+        label = Label(frame, text = self.message, name = 'msg')
+        label.pack(side = RIGHT, fill = BOTH, expand = 1, padx = 5, pady = 5)
 
-	frame = Frame(top, name = 'bot')
-	frame.pack(side = BOTTOM, fill = X, expand = 1)
-	command = self.ok
-	for i in range(len(self.buttons)):
-	    button = UpdatedButton(frame, text = self.buttons[i],
-				   command = command, args = i)
-	    button.grid(column = i, row = 0, sticky = 'ew', padx = 10)
+        frame = Frame(top, name = 'bot')
+        frame.pack(side = BOTTOM, fill = X, expand = 1)
+        command = self.ok
+        for i in range(len(self.buttons)):
+            button = UpdatedButton(frame, text = self.buttons[i],
+                                   command = command, args = i)
+            button.grid(column = i, row = 0, sticky = 'ew', padx = 10)
             if i == self.default:
                 if TkVersion >= 8.0:
                     button['default'] = 'active'
@@ -436,11 +436,11 @@
                 if TkVersion >= 8.0:
                     button['default'] = 'normal'
 
-	if self.default is not None:
-	    top.bind('<Return>', self.invoke_default)
+        if self.default is not None:
+            top.bind('<Return>', self.invoke_default)
 
     def ok(self, pos):
-	self.close_dlg(pos)
+        self.close_dlg(pos)
 
     def invoke_default(self, *rest):
-	self.ok(self.default)
+        self.ok(self.default)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/skpixmaps.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/skpixmaps.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/skpixmaps.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -25,47 +25,47 @@
 from Sketch.warn import warn, USER
 
 _builtin = ['NewDocument', 'Open', 'Save',
-	    'EditMode', 'SelectionMode',
-	    'Undo', 'Redo', 'Delete',
-	    'MoveToTop', 'MoveToBottom', 'MoveOneUp', 'MoveOneDown',
-	    'CreateRect', 'CreateEllipse', 'CreateCurve', 'CreatePoly',
-	    'Text', 'Image',
-	    'BezierAngle', 'BezierSmooth', 'BezierSymm',
-	    'BezierDeleteNode', 'BezierInsertNode',
-	    'BezierCurveLine', 'BezierLineCurve',
-	    'BezierOpenNodes', 'BezierCloseNodes',
-	    'Group', 'Ungroup',
-	    'GridOn', 'Zoom',
-	    'JoinMiter', 'JoinRound', 'JoinBevel',
-	    'CapButt', 'CapRound', 'CapProjecting',
-	    'FlipVertical', 'FlipHorizontal',
-	    'Duplicate',
+            'EditMode', 'SelectionMode',
+            'Undo', 'Redo', 'Delete',
+            'MoveToTop', 'MoveToBottom', 'MoveOneUp', 'MoveOneDown',
+            'CreateRect', 'CreateEllipse', 'CreateCurve', 'CreatePoly',
+            'Text', 'Image',
+            'BezierAngle', 'BezierSmooth', 'BezierSymm',
+            'BezierDeleteNode', 'BezierInsertNode',
+            'BezierCurveLine', 'BezierLineCurve',
+            'BezierOpenNodes', 'BezierCloseNodes',
+            'Group', 'Ungroup',
+            'GridOn', 'Zoom',
+            'JoinMiter', 'JoinRound', 'JoinBevel',
+            'CapButt', 'CapRound', 'CapProjecting',
+            'FlipVertical', 'FlipHorizontal',
+            'Duplicate',
 
-	    'fill_gradient', 'fill_hatch', 'fill_solid', 'fill_tile',
+            'fill_gradient', 'fill_hatch', 'fill_solid', 'fill_tile',
             'fill_none',
-	    'gradient_linear', 'gradient_conical', 'gradient_radial',
-            
-	    'AlignTop', 'AlignBottom', 'AlignCenterY',
-	    'AlignLeft', 'AlignRight', 'AlignCenterX',
+            'gradient_linear', 'gradient_conical', 'gradient_radial',
 
+            'AlignTop', 'AlignBottom', 'AlignCenterY',
+            'AlignLeft', 'AlignRight', 'AlignCenterX',
+
             'LayerNew', 'LayerUp', 'LayerDown',
-            
-	    'ArrLeft', 'ArrRight', 'ArrArrLeft', 'ArrArrRight', 'NoPattern',
 
-	    'Portrait', 'Portrait_mask',
+            'ArrLeft', 'ArrRight', 'ArrArrLeft', 'ArrArrRight', 'NoPattern',
+
+            'Portrait', 'Portrait_mask',
             'EyeInHand', 'EyeInHand_mask', 'EyeInHand_large',
             'hand_pencil', 'hand_pencil_mask', 'skencil_splash'
-	    ]
+            ]
 
 _small = ['MiniEyeOpen', 'MiniEyeClosed', 'MiniPrintOn', 'MiniPrintOff',
-	  'MiniLockOpen', 'MiniLockClosed', 'MiniOutlineOn', 'MiniOutlineOff']
+          'MiniLockOpen', 'MiniLockClosed', 'MiniOutlineOn', 'MiniOutlineOff']
 
 _small_dir = 'New12'
 
 _cursors = ['CurEdit', 'CurZoom', 'CurUpDown', 'CurDown', 'CurUp']
 
 _load_these = ['TurnTL', 'TurnTR', 'TurnBL', 'TurnBR', 'Center',
-	       'ShearLR', 'ShearUD']
+               'ShearLR', 'ShearUD']
 
 _alias = [('Icon', 'hand_pencil'), ('Icon_mask', 'hand_pencil_mask'),
           ('IconLarge', 'skencil_splash')]
@@ -74,14 +74,14 @@
 class SketchPixmaps:
 
     def InitFromWidget(self, widget, files, basedir):
-	for name in files:
-	    file_base = os.path.join(basedir, name)
-	    try:
-		pixmap = widget.ReadBitmapFile(file_base + '.xbm')[2]
-		setattr(self, name, pixmap)
-	    except IOError, info:
-		warn(USER, "Warning: Can't load Pixmap from %s: %s",
-		     file_base + '.xbm', info)
+        for name in files:
+            file_base = os.path.join(basedir, name)
+            try:
+                pixmap = widget.ReadBitmapFile(file_base + '.xbm')[2]
+                setattr(self, name, pixmap)
+            except IOError, info:
+                warn(USER, "Warning: Can't load Pixmap from %s: %s",
+                     file_base + '.xbm', info)
 
 
 class PixmapTk:
@@ -111,15 +111,15 @@
 def make_file_names(filenames, subdir = ''):
     default = 'error'	# a standard Tk bitmap
     for name in filenames:
-	fullname = os.path.join(config.pixmap_dir, subdir, name)
+        fullname = os.path.join(config.pixmap_dir, subdir, name)
         if os.path.exists(fullname + '.gif'):
             setattr(PixmapTk, name, '*' + fullname + '.gif')
-	elif os.path.exists(fullname + '.xbm'):
-	    setattr(PixmapTk, name, '@' + fullname + '.xbm')
-	else:
-	    warn(USER, "Warning: no file %s substituting '%s'",
-		 fullname, default)
-	    setattr(PixmapTk, name, default)
+        elif os.path.exists(fullname + '.xbm'):
+            setattr(PixmapTk, name, '@' + fullname + '.xbm')
+        else:
+            warn(USER, "Warning: no file %s substituting '%s'",
+                 fullname, default)
+            setattr(PixmapTk, name, default)
 
 make_file_names(_builtin)
 make_file_names(_small, _small_dir)
@@ -128,21 +128,21 @@
     from Sketch import const
     default = 'X_cursor'	# a standard X cursor
     for name in names:
-	fullname = os.path.join(config.pixmap_dir, name + '.xbm')
-	fullname_mask = os.path.join(config.pixmap_dir, name + '_mask.xbm')
-	if os.path.exists(fullname) and os.path.exists(fullname_mask):
-	    setattr(const, name, ('@' + fullname, fullname_mask,
-				  'black', 'white'))
-	else:
-	    warn(USER, "Warning: no file %s (or *_mask) substituting '%s'",
-		 fullname, default)
-	    setattr(const, name, default)
+        fullname = os.path.join(config.pixmap_dir, name + '.xbm')
+        fullname_mask = os.path.join(config.pixmap_dir, name + '_mask.xbm')
+        if os.path.exists(fullname) and os.path.exists(fullname_mask):
+            setattr(const, name, ('@' + fullname, fullname_mask,
+                                  'black', 'white'))
+        else:
+            warn(USER, "Warning: no file %s (or *_mask) substituting '%s'",
+                 fullname, default)
+            setattr(const, name, default)
 
 make_cursor_names(_cursors)
 
 def make_alias(aliases):
     for alias, name in aliases:
-	setattr(PixmapTk, alias, getattr(PixmapTk, name))
+        setattr(PixmapTk, alias, getattr(PixmapTk, name))
 
 make_alias(_alias)
 
@@ -153,4 +153,4 @@
 def InitFromWidget(widget):
     global _init_done
     if not _init_done:
-	pixmaps.InitFromWidget(widget, _load_these, config.pixmap_dir)
+        pixmaps.InitFromWidget(widget, _load_these, config.pixmap_dir)

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/styledlg.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/styledlg.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/styledlg.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -44,73 +44,73 @@
     receivers = PropertyPanel.receivers[:]
 
     def __init__(self, master, main_window, doc):
-	PropertyPanel.__init__(self, master, main_window, doc,
-			       name = 'styledlg')
+        PropertyPanel.__init__(self, master, main_window, doc,
+                               name = 'styledlg')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	button = UpdatedButton(top, text = _("Close"), name = 'close',
-				       command = self.close_dlg)
-	button.pack(side = BOTTOM, expand = 0, fill = X)
-	button = UpdatedButton(top, text = _("Apply"),
-			       command = self.apply_style,
-			       sensitivecb = self.can_apply)
-	button.pack(side = BOTTOM, expand = 0, fill = X)
-	self.Subscribe(SELECTION, button.Update)
+        button = UpdatedButton(top, text = _("Close"), name = 'close',
+                               command = self.close_dlg)
+        button.pack(side = BOTTOM, expand = 0, fill = X)
+        button = UpdatedButton(top, text = _("Apply"),
+                               command = self.apply_style,
+                               sensitivecb = self.can_apply)
+        button.pack(side = BOTTOM, expand = 0, fill = X)
+        self.Subscribe(SELECTION, button.Update)
 
-	button = UpdatedButton(top, text = _("Delete"),
-			       command = self.remove_style,
-			       sensitivecb = self.can_remove)
-	button.pack(side = BOTTOM, expand = 0, fill = X)
+        button = UpdatedButton(top, text = _("Delete"),
+                               command = self.remove_style,
+                               sensitivecb = self.can_remove)
+        button.pack(side = BOTTOM, expand = 0, fill = X)
 
-	list_frame = Frame(top)
-	list_frame.pack(side = TOP, expand = 1, fill = BOTH)
+        list_frame = Frame(top)
+        list_frame.pack(side = TOP, expand = 1, fill = BOTH)
 
-	sb_vert = Scrollbar(list_frame, takefocus = 0)
-	sb_vert.pack(side = RIGHT, fill = Y)
-	styles = UpdatedListbox(list_frame, name = 'list')
-	styles.pack(expand = 1, fill = BOTH)
-	styles.Subscribe(COMMAND, self.apply_style)
-	sb_vert['command'] = (styles, 'yview')
-	styles['yscrollcommand'] = (sb_vert, 'set')
-	self.styles = styles
+        sb_vert = Scrollbar(list_frame, takefocus = 0)
+        sb_vert.pack(side = RIGHT, fill = Y)
+        styles = UpdatedListbox(list_frame, name = 'list')
+        styles.pack(expand = 1, fill = BOTH)
+        styles.Subscribe(COMMAND, self.apply_style)
+        sb_vert['command'] = (styles, 'yview')
+        styles['yscrollcommand'] = (sb_vert, 'set')
+        self.styles = styles
 
     def init_from_doc(self):
-	self.styles_changed()
-	self.Update()
-	self.issue(SELECTION)
+        self.styles_changed()
+        self.Update()
+        self.issue(SELECTION)
 
     def Update(self):
-	self.styles.select_clear(0, END)
-	properties = self.document.CurrentProperties()
-	for name in properties.DynamicStyleNames():
-	    idx = self.style_names.index(name)
-	    self.styles.select_set(idx)
-	    self.styles.see(idx)
+        self.styles.select_clear(0, END)
+        properties = self.document.CurrentProperties()
+        for name in properties.DynamicStyleNames():
+            idx = self.style_names.index(name)
+            self.styles.select_set(idx)
+            self.styles.see(idx)
 
     receivers.append((STYLE, 'styles_changed'))
     def styles_changed(self):
-	self.style_names = self.document.GetStyleNames()
-	self.styles.SetList(self.style_names)
-	self.Update()
+        self.style_names = self.document.GetStyleNames()
+        self.styles.SetList(self.style_names)
+        self.Update()
 
     can_apply = PropertyPanel.doc_has_selection
 
     def apply_style(self):
-	sel = self.styles.curselection()
-	if sel:
-	    index = atoi(sel[0])
-	    self.document.AddStyle(self.style_names[index])
+        sel = self.styles.curselection()
+        if sel:
+            index = atoi(sel[0])
+            self.document.AddStyle(self.style_names[index])
 
     def can_remove(self):
-	len(self.styles.curselection()) == 1
+        len(self.styles.curselection()) == 1
 
     def remove_style(self):
-	sel = self.styles.curselection()
-	if sel:
-	    index = atoi(sel[0])
-	    self.document.RemoveDynamicStyle(self.style_names[index])
+        sel = self.styles.curselection()
+        if sel:
+            index = atoi(sel[0])
+            self.document.RemoveDynamicStyle(self.style_names[index])
 
 
 class CreateStyleDlg(SKModal):
@@ -118,71 +118,71 @@
     title = _("Create Style")
 
     def __init__(self, master, object, style_names, **kw):
-	self.object = object
-	self.style_names = style_names
-	apply(SKModal.__init__, (self, master), kw)
+        self.object = object
+        self.style_names = style_names
+        apply(SKModal.__init__, (self, master), kw)
 
     def __del__(self):
-	if __debug__:
-	    pdebug('__del__', '__del__', self)
+        if __debug__:
+            pdebug('__del__', '__del__', self)
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
-	self.var_style_name = StringVar(top)
-	entry_name = MyEntry(top, textvariable = self.var_style_name,
-					command = self.ok, width = 15)
-	entry_name.pack(side = TOP, fill = X)
+        self.var_style_name = StringVar(top)
+        entry_name = MyEntry(top, textvariable = self.var_style_name,
+                             command = self.ok, width = 15)
+        entry_name.pack(side = TOP, fill = X)
 
-	properties = self.object.Properties()
-	self.flags = {}
-	for prop in property_names:
-	    type = property_types[prop]
-	    if type == FillProperty:
-		state = self.object.has_fill and NORMAL or DISABLED
-	    elif type == LineProperty:
-		state = self.object.has_line and NORMAL or DISABLED
-	    elif type == FontProperty:
-		state = self.object.has_font and NORMAL or DISABLED
-	    else:
-		# unknown property type!
-		continue
-	    long, short = property_titles[prop]
-	    self.flags[prop] = var = IntVar(top)
-	    var.set(state == NORMAL)
-	    radio = Checkbutton(top, text = long, state = state,
-				variable = var)
-	    radio.pack(side = TOP, anchor = W)
+        properties = self.object.Properties()
+        self.flags = {}
+        for prop in property_names:
+            type = property_types[prop]
+            if type == FillProperty:
+                state = self.object.has_fill and NORMAL or DISABLED
+            elif type == LineProperty:
+                state = self.object.has_line and NORMAL or DISABLED
+            elif type == FontProperty:
+                state = self.object.has_font and NORMAL or DISABLED
+            else:
+                # unknown property type!
+                continue
+            long, short = property_titles[prop]
+            self.flags[prop] = var = IntVar(top)
+            var.set(state == NORMAL)
+            radio = Checkbutton(top, text = long, state = state,
+                                variable = var)
+            radio.pack(side = TOP, anchor = W)
 
-	but_frame = Frame(top)
-	but_frame.pack(side = TOP, fill = BOTH, expand = 1)
+        but_frame = Frame(top)
+        but_frame.pack(side = TOP, fill = BOTH, expand = 1)
 
-	button = Button(but_frame, text = _("OK"), command = self.ok)
-	button.pack(side = LEFT, expand = 1)
-	button = Button(but_frame, text = _("Cancel"), command = self.cancel)
-	button.pack(side = RIGHT, expand = 1)
+        button = Button(but_frame, text = _("OK"), command = self.ok)
+        button.pack(side = LEFT, expand = 1)
+        button = Button(but_frame, text = _("Cancel"), command = self.cancel)
+        button.pack(side = RIGHT, expand = 1)
 
-	entry_name.focus()
+        entry_name.focus()
 
     def ok(self, *args):
-	name = self.var_style_name.get()
-	if not name:
-	    MessageDialog(self.top, title =_("Create Style"),
-			  message = _("Please enter a style name."),
-			  icon = 'info')
-	    return
-	if name in self.style_names:
-	    MessageDialog(self.top, title =_("Create Style"),
-			  message = _("The name `%(name)s' is already used.\n"
-				      "Please choose another one.") % locals(),
-			  icon = 'info')
-	    return
+        name = self.var_style_name.get()
+        if not name:
+            MessageDialog(self.top, title =_("Create Style"),
+                          message = _("Please enter a style name."),
+                          icon = 'info')
+            return
+        if name in self.style_names:
+            MessageDialog(self.top, title =_("Create Style"),
+                          message = _("The name `%(name)s' is already used.\n"
+                                      "Please choose another one.") % locals(),
+                          icon = 'info')
+            return
 
-	which_properties = []
-	for prop, var in self.flags.items():
-	    if var.get():
-		which_properties.append(prop)
-	self.close_dlg((name, which_properties))
+        which_properties = []
+        for prop, var in self.flags.items():
+            if var.get():
+                which_properties.append(prop)
+        self.close_dlg((name, which_properties))
 
 
 def GetStyleName(master, object, style_names):
@@ -199,11 +199,11 @@
     title = _("Set Default Properties")
 
     def __init__(self, master, category):
-	self.category = category
-	SKModal.__init__(self, master, name = 'setdefaults')
+        self.category = category
+        SKModal.__init__(self, master, name = 'setdefaults')
 
     def build_dlg(self):
-	top = self.top
+        top = self.top
 
         label = Label(top, name = 'label',
                       text = _("Please select the object categories whose "
@@ -228,18 +228,18 @@
                              variable = self.var_text)
         button.pack(side = TOP, anchor = W)
 
-	but_frame = Frame(top)
-	but_frame.pack(side = TOP, fill = BOTH, expand = 1)
+        but_frame = Frame(top)
+        but_frame.pack(side = TOP, fill = BOTH, expand = 1)
 
-	button = Button(but_frame, text = _("OK"), command = self.ok)
-	button.pack(side = LEFT, expand = 1)
-	button = Button(but_frame, text = _("Cancel"), command = self.cancel)
-	button.pack(side = RIGHT, expand = 1)
+        button = Button(but_frame, text = _("OK"), command = self.ok)
+        button.pack(side = LEFT, expand = 1)
+        button = Button(but_frame, text = _("Cancel"), command = self.cancel)
+        button.pack(side = RIGHT, expand = 1)
 
     def ok(self, *args):
-	which_properties = (self.var_graphics.get(),
+        which_properties = (self.var_graphics.get(),
                             self.var_text.get())
-	self.close_dlg(which_properties)
+        self.close_dlg(which_properties)
 
 
 def WhichDefaultStyles(master, category = 0):

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/tkext.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/tkext.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/tkext.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -37,7 +37,7 @@
     accept_drop = ()
 
     def DropAt(self, x, y, what, data):
-	pass
+        pass
 
 
 class AutoUpdate:
@@ -47,51 +47,51 @@
     sensitivecb = None
 
     def __init__(self, sensitivecb = None, updatecb = None,
-		 update_field = None, kw = None):
-	if kw is None:
-	    kw = {}
+                 update_field = None, kw = None):
+        if kw is None:
+            kw = {}
 
-	if kw.has_key('sensitivecb'):
-	    self.sensitivecb = kw['sensitivecb']
-	    del kw['sensitivecb']
-	else:
-	    self.sensitivecb = sensitivecb
+        if kw.has_key('sensitivecb'):
+            self.sensitivecb = kw['sensitivecb']
+            del kw['sensitivecb']
+        else:
+            self.sensitivecb = sensitivecb
 
-	if kw.has_key('updatecb'):
-	    self.updatecb = kw['updatecb']
-	    del kw['updatecb']
-	else:
-	    self.updatecb = updatecb
+        if kw.has_key('updatecb'):
+            self.updatecb = kw['updatecb']
+            del kw['updatecb']
+        else:
+            self.updatecb = updatecb
 
-	if kw.has_key('update_field'):
-	    self.update_field = kw['update_field']
-	    del kw['update_field']
-	else:
-	    if update_field is not None:
-		self.update_field = update_field
+        if kw.has_key('update_field'):
+            self.update_field = kw['update_field']
+            del kw['update_field']
+        else:
+            if update_field is not None:
+                self.update_field = update_field
 
     def clean_up(self):
-	self.sensitivecb = None
-	self.updatecb = None
+        self.sensitivecb = None
+        self.updatecb = None
 
     def SetSensitiveCallback(self, sensitivecb):
-	self.sensitivecb = sensitivecb
+        self.sensitivecb = sensitivecb
 
     def SetUpdateCallback(self, updatecb):
-	self.updatecb = updatecb
+        self.updatecb = updatecb
 
     def Update(self, *rest):
-	if self.sensitivecb:
-	    self.SetSensitive(self.sensitivecb())
-	if self.updatecb and self.update_field:
-	    self[self.update_field] = self.updatecb()
+        if self.sensitivecb:
+            self.SetSensitive(self.sensitivecb())
+        if self.updatecb and self.update_field:
+            self[self.update_field] = self.updatecb()
 
     def SetSensitive(self, on):
-	# for ordinary TkWidgets:
-	if on:
-	    self['state'] = NORMAL
-	else:
-	    self['state'] = DISABLED
+        # for ordinary TkWidgets:
+        if on:
+            self['state'] = NORMAL
+        else:
+            self['state'] = DISABLED
 
 class WidgetWithCommand(Publisher):
 
@@ -99,24 +99,24 @@
     tk_widget_has_command = 1
 
     def __init__(self):
-	pass
+        pass
 
     def clean_up(self):
-	Publisher.Destroy(self)
-	pax.unregister_object(self)
+        Publisher.Destroy(self)
+        pax.unregister_object(self)
 
     def set_command(self, command, args = ()):
-	if self.tk_widget_has_command and not self['command']:
-	    self['command'] = MakeMethodCommand(self._call_cmd)
-	if type(args) != TupleType:
-	    args = (args,)
-	apply(self.Subscribe, (COMMAND, command,) + args)
+        if self.tk_widget_has_command and not self['command']:
+            self['command'] = MakeMethodCommand(self._call_cmd)
+        if type(args) != TupleType:
+            args = (args,)
+        apply(self.Subscribe, (COMMAND, command,) + args)
 
     def _call_cmd(self, *args):
-	try:
-	    apply(self.issue, (COMMAND,) + args)
-	except:
-	    warn_tb(INTERNAL)
+        try:
+            apply(self.issue, (COMMAND,) + args)
+        except:
+            warn_tb(INTERNAL)
 
 
 class MenuEntry:
@@ -126,42 +126,42 @@
     menu = None
 
     def __init__(self, kw_args):
-	self.rest = kw_args
+        self.rest = kw_args
 
     def clean_up(self):
-	self.rest = {}
-	pax.unregister_object(self)
-	self.variable = None
+        self.rest = {}
+        pax.unregister_object(self)
+        self.variable = None
 
     def AddToMenu(self, menu):
-	if menu:
-	    apply(menu.add, (self.tk_entry_type,), self.rest)
-	self.menu = menu
+        if menu:
+            apply(menu.add, (self.tk_entry_type,), self.rest)
+        self.menu = menu
 
     def SetIndex(self, index):
-	self.index = index
+        self.index = index
 
     def Update(self):
-	pass
+        pass
 
     def __setitem__(self, key, item):
-	if self.menu is not None:
-	    self.menu.entryconfig(self.index, {key:item})
-	else:
-	    self.rest[key] = item
+        if self.menu is not None:
+            self.menu.entryconfig(self.index, {key:item})
+        else:
+            self.rest[key] = item
 
     def __getitem__(self, key):
-	if self.menu is not None:
-	    self.menu.entryconfig(self.index, key)
-	else:
-	    return self.rest[key]
+        if self.menu is not None:
+            self.menu.entryconfig(self.index, key)
+        else:
+            return self.rest[key]
 
     def configure(self, **kw):
-	if self.menu is not None:
-	    self.menu.entryconfig(self.index, kw)
+        if self.menu is not None:
+            self.menu.entryconfig(self.index, kw)
 
     def IgnoreEntry(self):
-	return 0
+        return 0
 
 
 
@@ -172,53 +172,53 @@
     update_field = 'label'
 
     def __init__(self, text = '', command = None, args = (),
-		 sensitivecb = None, updatecb = None, bitmap = None,
-		 **rest):
-	AutoUpdate.__init__(self, sensitivecb, updatecb)
-	WidgetWithCommand.__init__(self)
-	rest['command'] = ''
-	MenuEntry.__init__(self, rest)
-	if bitmap:
-	    rest['bitmap'] = bitmap
-	else:
-	    rest['label'] = text
-	self.set_command(command, args)
+                 sensitivecb = None, updatecb = None, bitmap = None,
+                 **rest):
+        AutoUpdate.__init__(self, sensitivecb, updatecb)
+        WidgetWithCommand.__init__(self)
+        rest['command'] = ''
+        MenuEntry.__init__(self, rest)
+        if bitmap:
+            rest['bitmap'] = bitmap
+        else:
+            rest['label'] = text
+        self.set_command(command, args)
 
     def clean_up(self):
-	AutoUpdate.clean_up(self)
-	WidgetWithCommand.clean_up(self)
-	MenuEntry.clean_up(self)
+        AutoUpdate.clean_up(self)
+        WidgetWithCommand.clean_up(self)
+        MenuEntry.clean_up(self)
 
 class MenuCommand2(MenuEntry):
 
     tk_entry_type = 'command'
 
     def __init__(self, command, **rest):
-	self.command = command
-	rest = self.add_kw_args(rest)
-	rest['command'] = MakeMethodCommand(self.command.Invoke)
-	MenuEntry.__init__(self, rest)
-	command.Subscribe(CHANGED, self._update)
-	self._update()
+        self.command = command
+        rest = self.add_kw_args(rest)
+        rest['command'] = MakeMethodCommand(self.command.Invoke)
+        MenuEntry.__init__(self, rest)
+        command.Subscribe(CHANGED, self._update)
+        self._update()
 
     def add_kw_args(self, dict, no_active = 0):
-	cmd = self.command
-	dict['label'] = cmd.menu_name
-	dict['state'] = cmd.sensitive and NORMAL or DISABLED
-	key_stroke = cmd.key_stroke
-	if key_stroke:
-	    if type(key_stroke) == TupleType:
-		dict['accelerator'] = key_stroke[0]
-	    else:
-		dict['accelerator'] = key_stroke
-	return dict
+        cmd = self.command
+        dict['label'] = cmd.menu_name
+        dict['state'] = cmd.sensitive and NORMAL or DISABLED
+        key_stroke = cmd.key_stroke
+        if key_stroke:
+            if type(key_stroke) == TupleType:
+                dict['accelerator'] = key_stroke[0]
+            else:
+                dict['accelerator'] = key_stroke
+        return dict
 
     def _update(self):
-	self.rest = self.add_kw_args(self.rest)
-	apply(self.configure, (), self.rest)
+        self.rest = self.add_kw_args(self.rest)
+        apply(self.configure, (), self.rest)
 
     def IgnoreEntry(self):
-	return not self.command.menu_name
+        return not self.command.menu_name
 
 
 
@@ -229,55 +229,55 @@
     update_field = ''
 
     def __init__(self, text = '', command = None, args = (),
-		 sensitivecb = None, updatecb = None, bitmap = None,
-		 **rest):
-	self.var_on = Tkinter.IntVar()
-	rest['variable'] = self.var_on
-	AutoUpdate.__init__(self, sensitivecb, updatecb)
-	WidgetWithCommand.__init__(self)
-	rest['command'] = ''
-	MenuEntry.__init__(self, rest)
-	if bitmap:
-	    rest['bitmap'] = bitmap
-	else:
-	    rest['label'] = text
-	self.set_command(command, args)
+                 sensitivecb = None, updatecb = None, bitmap = None,
+                 **rest):
+        self.var_on = Tkinter.IntVar()
+        rest['variable'] = self.var_on
+        AutoUpdate.__init__(self, sensitivecb, updatecb)
+        WidgetWithCommand.__init__(self)
+        rest['command'] = ''
+        MenuEntry.__init__(self, rest)
+        if bitmap:
+            rest['bitmap'] = bitmap
+        else:
+            rest['label'] = text
+        self.set_command(command, args)
 
     def Update(self):
-	AutoUpdate.Update(self)
-	if self.updatecb:
-	    self.var_on.set(self.updatecb())
+        AutoUpdate.Update(self)
+        if self.updatecb:
+            self.var_on.set(self.updatecb())
 
 class MenuCheck2(MenuEntry):
 
     tk_entry_type = 'checkbutton'
 
     def __init__(self, command, **rest):
-	self.command = command
-	self.var_value = Tkinter.IntVar()
-	self.var_value.set(command.IsOn())
-	rest['variable'] = self.var_value
-	rest = self.add_kw_args(rest)
-	rest['command'] = MakeMethodCommand(self.command.Invoke)
-	MenuEntry.__init__(self, rest)
+        self.command = command
+        self.var_value = Tkinter.IntVar()
+        self.var_value.set(command.IsOn())
+        rest['variable'] = self.var_value
+        rest = self.add_kw_args(rest)
+        rest['command'] = MakeMethodCommand(self.command.Invoke)
+        MenuEntry.__init__(self, rest)
 
-	command.Subscribe(CHANGED, self._update)
+        command.Subscribe(CHANGED, self._update)
 
     def add_kw_args(self, dict):
-	cmd = self.command
-	dict['label'] = cmd.menu_name
-	dict['state'] = cmd.sensitive and NORMAL or DISABLED
-	key_stroke = cmd.key_stroke
-	if key_stroke:
-	    if type(key_stroke) == TupleType:
-		dict['accelerator'] = key_stroke[0]
-	    else:
-		dict['accelerator'] = key_stroke
-	return dict
+        cmd = self.command
+        dict['label'] = cmd.menu_name
+        dict['state'] = cmd.sensitive and NORMAL or DISABLED
+        key_stroke = cmd.key_stroke
+        if key_stroke:
+            if type(key_stroke) == TupleType:
+                dict['accelerator'] = key_stroke[0]
+            else:
+                dict['accelerator'] = key_stroke
+        return dict
 
     def _update(self):
-	self.var_value.set(self.command.IsOn())
-	apply(self.configure, (), self.add_kw_args(self.rest))
+        self.var_value.set(self.command.IsOn())
+        apply(self.configure, (), self.add_kw_args(self.rest))
 
 
 class MenuSeparator(MenuEntry):
@@ -285,7 +285,7 @@
     tk_entry_type = 'separator'
 
     def __init__(self, **rest):
-	MenuEntry.__init__(self, rest)
+        MenuEntry.__init__(self, rest)
 
 
 class UpdatedMenu:
@@ -296,71 +296,71 @@
     rebuild_func = None
 
     def __init__(self, master, entries, auto_update = 1, auto_rebuild = None,
-		 **rest):
-	if auto_update:
-	    rest['postcommand'] = MakeMethodCommand(self.Update)
-	if auto_rebuild is not None:
-	    rest['postcommand'] = MakeMethodCommand(self.RebuildMenu)
-	    self.rebuild_func = auto_rebuild
-	rest['tearoffcommand'] = MakeMethodCommand(self._tearoff)
-	self.menu = apply(Menu, (master,), rest)
-	self.SetEntries(entries)
+                 **rest):
+        if auto_update:
+            rest['postcommand'] = MakeMethodCommand(self.Update)
+        if auto_rebuild is not None:
+            rest['postcommand'] = MakeMethodCommand(self.RebuildMenu)
+            self.rebuild_func = auto_rebuild
+        rest['tearoffcommand'] = MakeMethodCommand(self._tearoff)
+        self.menu = apply(Menu, (master,), rest)
+        self.SetEntries(entries)
 
     def __del__(self):
-	self.clean_up()
+        self.clean_up()
 
     def clean_up(self):
-	if self.entries:
-	    for entry in self.entries:
-		entry.clean_up()
-	self.entries = None
-	self.menu = None
-	pax.unregister_object(self)
+        if self.entries:
+            for entry in self.entries:
+                entry.clean_up()
+        self.entries = None
+        self.menu = None
+        pax.unregister_object(self)
 
     destroy = clean_up
 
     def _tearoff(self, menu, tearoff):
-	# tk8 needs this on my machine... (afterstep 1.4)
-	# in tk4.2 this wasn't necessary.
+        # tk8 needs this on my machine... (afterstep 1.4)
+        # in tk4.2 this wasn't necessary.
         try:
-	    call = self.menu.tk.call
+            call = self.menu.tk.call
             # Set the group and transient window properties so that
             # torn-off menus stay on top of the main window. It seems
             # that tk4.2 did this itself, but not tk8.
-	    call('wm', 'group', tearoff, '.')
-	    call('wm', 'transient', tearoff, '.')
-	    # withdraw and deiconify needed for `braindead' Window
-	    # managers that don't recognize property changes after
-	    # windows are mapped.
+            call('wm', 'group', tearoff, '.')
+            call('wm', 'transient', tearoff, '.')
+            # withdraw and deiconify needed for `braindead' Window
+            # managers that don't recognize property changes after
+            # windows are mapped.
             if config.preferences.menu_tearoff_fix:
                 call('wm', 'withdraw', tearoff)
                 call('wm', 'deiconify', tearoff)
-	except:
-	    warn_tb(INTERNAL, 'tearoffcommand')
+        except:
+            warn_tb(INTERNAL, 'tearoffcommand')
 
     def Update(self):
-	try:
-	    for entry in self.entries:
-		entry.Update()
-	except:
-	    warn_tb(INTERNAL, 'Updating menu Entries')
+        try:
+            for entry in self.entries:
+                entry.Update()
+        except:
+            warn_tb(INTERNAL, 'Updating menu Entries')
 
     def __build_menu(self):
-	if self.menu['tearoff'] == '1':
-	    index = 1
-	else:
-	    index = 0
-	last_was_sep = 0
-	for entry in self.entries:
-	    if not entry.IgnoreEntry():
-		if last_was_sep and isinstance(entry, MenuSeparator):
-		    continue
-		entry.AddToMenu(self.menu)
-		entry.SetIndex(index)
-		index = index + 1
-		last_was_sep = isinstance(entry, MenuSeparator)
-	    else:
-		entry.AddToMenu(None)
+        if self.menu['tearoff'] == '1':
+            index = 1
+        else:
+            index = 0
+        last_was_sep = 0
+        for entry in self.entries:
+            if not entry.IgnoreEntry():
+                if last_was_sep and isinstance(entry, MenuSeparator):
+                    continue
+                entry.AddToMenu(self.menu)
+                entry.SetIndex(index)
+                index = index + 1
+                last_was_sep = isinstance(entry, MenuSeparator)
+            else:
+                entry.AddToMenu(None)
 
     def RebuildMenu(self):
         if self.entries is not None:
@@ -384,21 +384,21 @@
         self.__build_menu()
 
     def Popup(self, x, y):
-	self.menu.tk_popup(x, y)
+        self.menu.tk_popup(x, y)
 
 class MenuCascade(MenuEntry):
 
     def __init__(self, text, entries, **kw):
-	self.entries = entries
-	self.label = text
-	self.submenu = None
-	self.kwargs = kw
+        self.entries = entries
+        self.label = text
+        self.submenu = None
+        self.kwargs = kw
 
     def AddToMenu(self, menu):
-	if menu:
-	    self.submenu = apply(UpdatedMenu, (menu, self.entries),self.kwargs)
-	    menu.add('cascade', label = self.label, menu = self.submenu.menu)
-	self.menu = menu
+        if menu:
+            self.submenu = apply(UpdatedMenu, (menu, self.entries),self.kwargs)
+            menu.add('cascade', label = self.label, menu = self.submenu.menu)
+        self.menu = menu
 
 
 def AppendMenu(mbar, text, menu_list):
@@ -420,60 +420,60 @@
 
 def MakeCommand(label, func = None, args = (), sensitive = None, update =None):
     if label:
-	if type(label) == TupleType:
-	    return apply(MakeCommand, label)
-	elif type(label) == ListType:
-	    text = label[0]
-	    if type(text) == TupleType:
-		text, kwargs = text
-	    else:
-		kwargs = {}
-	    return apply(MenuCascade, (text, map(MakeCommand, label[1:])),
-				       kwargs)
-	elif type(label) == InstanceType:
-	    if label.__class__ in cmd_classes:
-		if label.is_command:
-		    return MenuCommand2(label)
-		elif label.is_check:
-		    return MenuCheck2(label)
-		raise ValueError, 'invalid menu specifier'
+        if type(label) == TupleType:
+            return apply(MakeCommand, label)
+        elif type(label) == ListType:
+            text = label[0]
+            if type(text) == TupleType:
+                text, kwargs = text
+            else:
+                kwargs = {}
+            return apply(MenuCascade, (text, map(MakeCommand, label[1:])),
+                         kwargs)
+        elif type(label) == InstanceType:
+            if label.__class__ in cmd_classes:
+                if label.is_command:
+                    return MenuCommand2(label)
+                elif label.is_check:
+                    return MenuCheck2(label)
+                raise ValueError, 'invalid menu specifier'
 
-	    else:
-		return label
-	elif label[0] == '*':
-	    return MenuCheck(label[1:], func, args,
-			     sensitivecb = sensitive, updatecb = update)
-	else:
-	    return MenuCommand(label, func, args,
-			       sensitivecb = sensitive, updatecb = update)
+            else:
+                return label
+        elif label[0] == '*':
+            return MenuCheck(label[1:], func, args,
+                             sensitivecb = sensitive, updatecb = update)
+        else:
+            return MenuCommand(label, func, args,
+                               sensitivecb = sensitive, updatecb = update)
     else:
-	return MenuSeparator()
+        return MenuSeparator()
 
 
 class UpdatedLabel(Tkinter.Label, AutoUpdate):
 
     def __init__(self, master, **kw):
-	AutoUpdate.__init__(self, kw = kw)
-	apply(Tkinter.Label.__init__, (self, master), kw)
+        AutoUpdate.__init__(self, kw = kw)
+        apply(Tkinter.Label.__init__, (self, master), kw)
 
     def destroy(self):
-	AutoUpdate.clean_up(self)
-	Tkinter.Label.destroy(self)
+        AutoUpdate.clean_up(self)
+        Tkinter.Label.destroy(self)
 
 
 class UpdatedButton(Tkinter.Button, AutoUpdate, WidgetWithCommand):
 
     def __init__(self, master, command = None, args = (), **kw):
-	AutoUpdate.__init__(self, kw = kw)
-	WidgetWithCommand.__init__(self)
-	apply(Tkinter.Button.__init__, (self, master), kw)
-	if command:
-	    self.set_command(command, args)
+        AutoUpdate.__init__(self, kw = kw)
+        WidgetWithCommand.__init__(self)
+        apply(Tkinter.Button.__init__, (self, master), kw)
+        if command:
+            self.set_command(command, args)
 
     def destroy(self):
-	AutoUpdate.clean_up(self)
-	WidgetWithCommand.clean_up(self)
-	Tkinter.Button.destroy(self)
+        AutoUpdate.clean_up(self)
+        WidgetWithCommand.clean_up(self)
+        Tkinter.Button.destroy(self)
 
 class MultiButton(UpdatedButton):
 
@@ -492,8 +492,8 @@
             self.event_generate('<ButtonRelease-1>')
         finally:
             self.two = 0
-        
-        
+
+
     def _call_cmd(self, *args):
         if self.two:
             try:
@@ -502,49 +502,49 @@
                 warn_tb(INTERNAL)
         else:
             apply(UpdatedButton._call_cmd, (self,) + args)
-                
 
+
 import tooltips
 
 class CommandButton(Tkinter.Button):
 
     def __init__(self, master, command = None, args = (), **kw):
-	self.command = command
-	if type(args) != TupleType:
-	    args = (args,)
-	self.args = args
-	kw['command'] = MakeMethodCommand(self.command.Invoke)
-	if command.bitmap:
+        self.command = command
+        if type(args) != TupleType:
+            args = (args,)
+        self.args = args
+        kw['command'] = MakeMethodCommand(self.command.Invoke)
+        if command.bitmap:
             bitmap = PixmapTk.load_image(command.bitmap)
             if type(bitmap) == StringType:
                 kw['bitmap'] = bitmap
             else:
                 kw['image'] = bitmap
-	else:
-	    kw['text'] = command.button_name
-	command.Subscribe(CHANGED, self._update)
-	apply(Tkinter.Button.__init__, (self, master), kw)
-	tooltips.AddDescription(self, command.menu_name)
-	self._update()
+        else:
+            kw['text'] = command.button_name
+        command.Subscribe(CHANGED, self._update)
+        apply(Tkinter.Button.__init__, (self, master), kw)
+        tooltips.AddDescription(self, command.menu_name)
+        self._update()
 
     def _update(self):
-	state = self.command.sensitive and NORMAL or DISABLED
-	if self.command.bitmap:
+        state = self.command.sensitive and NORMAL or DISABLED
+        if self.command.bitmap:
             bitmap = PixmapTk.load_image(self.command.bitmap)
             if type(bitmap) == StringType:
                 self.configure(bitmap = bitmap, state = state)
             else:
                 self.configure(image = bitmap, state = state)
         else:
-	    self.configure(text = self.command.button_name, state = state)
-	tooltips.AddDescription(self, self.command.menu_name)
+            self.configure(text = self.command.button_name, state = state)
+        tooltips.AddDescription(self, self.command.menu_name)
 
     def destroy(self):
-	self.command.Unsubscribe(CHANGED, self._update)
-	pax.unregister_object(self.command)
-	self.command = self.args = None
-	Tkinter.Button.destroy(self)
-	pax.unregister_object(self)
+        self.command.Unsubscribe(CHANGED, self._update)
+        pax.unregister_object(self.command)
+        self.command = self.args = None
+        Tkinter.Button.destroy(self)
+        pax.unregister_object(self)
 
 class CommandCheckbutton(CommandButton):
 
@@ -564,30 +564,30 @@
 class UpdatedCheckbutton(Tkinter.Checkbutton, AutoUpdate, WidgetWithCommand):
 
     def __init__(self, master, command = None, args = (), **kw):
-	AutoUpdate.__init__(self, kw = kw)
-	WidgetWithCommand.__init__(self)
-	apply(Tkinter.Checkbutton.__init__, (self, master), kw)
-	if command:
-	    self.set_command(command, args)
+        AutoUpdate.__init__(self, kw = kw)
+        WidgetWithCommand.__init__(self)
+        apply(Tkinter.Checkbutton.__init__, (self, master), kw)
+        if command:
+            self.set_command(command, args)
 
     def destroy(self):
-	AutoUpdate.clean_up(self)
-	WidgetWithCommand.clean_up(self)
-	Tkinter.Checkbutton.destroy(self)
+        AutoUpdate.clean_up(self)
+        WidgetWithCommand.clean_up(self)
+        Tkinter.Checkbutton.destroy(self)
 
 class UpdatedRadiobutton(Tkinter.Radiobutton, AutoUpdate, WidgetWithCommand):
 
     def __init__(self, master, command = None, args = (), **kw):
-	AutoUpdate.__init__(self, kw = kw)
-	WidgetWithCommand.__init__(self)
-	apply(Tkinter.Radiobutton.__init__, (self, master), kw)
-	if command:
-	    self.set_command(command, args)
+        AutoUpdate.__init__(self, kw = kw)
+        WidgetWithCommand.__init__(self)
+        apply(Tkinter.Radiobutton.__init__, (self, master), kw)
+        if command:
+            self.set_command(command, args)
 
     def destroy(self):
-	AutoUpdate.clean_up(self)
-	WidgetWithCommand.clean_up(self)
-	Tkinter.Radiobutton.destroy(self)
+        AutoUpdate.clean_up(self)
+        WidgetWithCommand.clean_up(self)
+        Tkinter.Radiobutton.destroy(self)
 
 
 class UpdatedListbox(Tkinter.Listbox, AutoUpdate, WidgetWithCommand):
@@ -598,41 +598,41 @@
     tk_event_bound = 0
 
     def __init__(self, master, command = None, args = (), **kw):
-	AutoUpdate.__init__(self, kw = kw)
-	apply(Tkinter.Listbox.__init__, (self, master), kw)
-	WidgetWithCommand.__init__(self)
-	if command:
-	    self.set_command(command, args)
-	self.bind(self.tk_command_event, self._call_cmd)
-	self.bind(self.tk_select_event, self._call_selection)
+        AutoUpdate.__init__(self, kw = kw)
+        apply(Tkinter.Listbox.__init__, (self, master), kw)
+        WidgetWithCommand.__init__(self)
+        if command:
+            self.set_command(command, args)
+        self.bind(self.tk_command_event, self._call_cmd)
+        self.bind(self.tk_select_event, self._call_selection)
 
     def destroy(self):
-	AutoUpdate.clean_up(self)
-	WidgetWithCommand.clean_up(self)
-	Tkinter.Listbox.destroy(self)
+        AutoUpdate.clean_up(self)
+        WidgetWithCommand.clean_up(self)
+        Tkinter.Listbox.destroy(self)
 
     def set_command(self, command, args = ()):
-	WidgetWithCommand.set_command(self, command, args)
+        WidgetWithCommand.set_command(self, command, args)
 
     def SetList(self, list):
-	self.delete(0, END)
-	for item in list:
-	    self.insert(END, item)
+        self.delete(0, END)
+        for item in list:
+            self.insert(END, item)
 
     def SelectNone(self):
-	self.select_clear(0, END)
+        self.select_clear(0, END)
 
     def Select(self, idx, view = 0):
-	self.select_clear(0, END)
-	self.select_set(idx)
+        self.select_clear(0, END)
+        self.select_set(idx)
         if view:
             self.yview(idx)
 
     def _call_cmd(self, event, *rest):
-	WidgetWithCommand._call_cmd(self)
+        WidgetWithCommand._call_cmd(self)
 
     def _call_selection(self, event, *rest):
-	self.issue(SELECTION)
+        self.issue(SELECTION)
 
 class MyEntry(Tkinter.Entry, WidgetWithCommand):
 
@@ -641,59 +641,59 @@
     tk_event_bound = 0
 
     def __init__(self, master, command = None, args = (), **kw):
-	apply(Tkinter.Entry.__init__, (self, master), kw)
-	WidgetWithCommand.__init__(self)
-	if command:
-	    self.set_command(command, args)
+        apply(Tkinter.Entry.__init__, (self, master), kw)
+        WidgetWithCommand.__init__(self)
+        if command:
+            self.set_command(command, args)
 
     def destroy(self):
-	WidgetWithCommand.clean_up(self)
-	Tkinter.Entry.destroy(self)
+        WidgetWithCommand.clean_up(self)
+        Tkinter.Entry.destroy(self)
 
     def SetText(self, text):
-	self.delete(0, END)
-	self.insert(0, text)
+        self.delete(0, END)
+        self.insert(0, text)
 
     def set_command(self, command, args = ()):
-	WidgetWithCommand.set_command(self, command, args)
-	if command and not self.tk_event_bound:
-	    self.bind(self.tk_command_event, self._call_cmd)
-	    self.tk_event_bound = 1
+        WidgetWithCommand.set_command(self, command, args)
+        if command and not self.tk_event_bound:
+            self.bind(self.tk_command_event, self._call_cmd)
+            self.tk_event_bound = 1
 
     def _call_cmd(self, event, *rest):
-	WidgetWithCommand._call_cmd(self, self.get())
+        WidgetWithCommand._call_cmd(self, self.get())
 
 
 class PyWidget(Widget, SketchDropTarget):
 
     def __init__(self, master=None, **kw):
-	key = pax.register_object(self)
-	kw['pyobject'] = key
-	kw['class'] = self.__class__.__name__
-	Widget.__init__(self, master, 'paxwidget', kw = kw)
+        key = pax.register_object(self)
+        kw['pyobject'] = key
+        kw['class'] = self.__class__.__name__
+        Widget.__init__(self, master, 'paxwidget', kw = kw)
 
     def DestroyMethod(self):
-	self.tkwin = None
-	self.tkborder = None
-	pax.unregister_object(self)
+        self.tkwin = None
+        self.tkborder = None
+        pax.unregister_object(self)
 
     def MapMethod(self):
-	pass
+        pass
 
     def RedrawMethod(self, region = None):
-	pass
+        pass
 
     def ResizedMethod(self, width, height):
-	pass
+        pass
 
     def InitTkWinObject(self, tkwin):
-	self.tkwin = tkwin
+        self.tkwin = tkwin
 
     def InitTkBorder(self, tkborder):
-	self.tkborder = tkborder
+        self.tkborder = tkborder
 
     def UpdateWhenIdle(self):
-	self.tk.call(self._w, 'update')
+        self.tk.call(self._w, 'update')
 
 
 
@@ -722,14 +722,14 @@
 YesNoCancel = (Yes, No, Cancel)
 
 def MessageDialog(master, title, message, buttons = Ok, default = 0,
-		  icon = 'warning'):
+                  icon = 'warning'):
     if type(buttons) != TupleType:
-	buttons = (buttons,)
+        buttons = (buttons,)
     from sketchdlg import MessageDialog
     dlg = MessageDialog(master, title, message, buttons, default, icon)
     result = dlg.RunDialog()
     if result is not None:
-	return buttons[result]
+        return buttons[result]
     return ''
 
 
@@ -744,48 +744,48 @@
     accept_drop = (DROP_COLOR,)
 
     def __init__(self, master, command = None, args = (),
-		 color = None, dialog_master = None, **kw):
-	WidgetWithCommand.__init__(self)
-	apply(Tkinter.Button.__init__, (self, master), kw)
-	if color is None:
-	    color = StandardColors.white
-	self.set_color(color)
-	if command:
-	    self.set_command(command, args)
-	if dialog_master is None:
-	    self.dialog_master = master
-	else:
-	    self.dialog_master = dialog_master
+                 color = None, dialog_master = None, **kw):
+        WidgetWithCommand.__init__(self)
+        apply(Tkinter.Button.__init__, (self, master), kw)
+        if color is None:
+            color = StandardColors.white
+        self.set_color(color)
+        if command:
+            self.set_command(command, args)
+        if dialog_master is None:
+            self.dialog_master = master
+        else:
+            self.dialog_master = dialog_master
 
     def destroy(self):
-	self.clean_up()
-	Tkinter.Button.destroy(self)
+        self.clean_up()
+        Tkinter.Button.destroy(self)
 
     def set_color(self, color):
-	self.color = color
-	tk_color = rgb_to_tk(color)
-	self[self.color_option] = tk_color
-	self['activebackground'] = tk_color
+        self.color = color
+        tk_color = rgb_to_tk(color)
+        self[self.color_option] = tk_color
+        self['activebackground'] = tk_color
 
     def SetColor(self, color):
-	changed = self.color != color
-	self.set_color(color)
-	return changed
+        changed = self.color != color
+        self.set_color(color)
+        return changed
 
     def Color(self):
-	return self.color
+        return self.color
 
     def _call_cmd(self, *args):
-	import colordlg
-	new_color = colordlg.GetColor(self.dialog_master, self.color)
-	if new_color:
-	    self.set_color(new_color)
-	    apply(WidgetWithCommand._call_cmd, (self,) + args)
+        import colordlg
+        new_color = colordlg.GetColor(self.dialog_master, self.color)
+        if new_color:
+            self.set_color(new_color)
+            apply(WidgetWithCommand._call_cmd, (self,) + args)
 
     def DropAt(self, x, y, what, data):
-	if what == DROP_COLOR:
-	    if self.SetColor(data):
-		apply(WidgetWithCommand._call_cmd, (self,))
+        if what == DROP_COLOR:
+            if self.SetColor(data):
+                apply(WidgetWithCommand._call_cmd, (self,))
 
 #
 option_menu_defaults = {
@@ -794,46 +794,46 @@
     "relief": RAISED,
     "anchor": "c",
     "highlightthickness": 1
-    }
+}
 class MyOptionMenu(WidgetWithCommand, Menubutton):
 
     tk_widget_has_command = 0
 
     def __init__(self, master, values, command = None, args = (),
-		 variable = None):
-	kw = option_menu_defaults.copy()
-	if variable is not None:
-	    kw['textvariable'] = variable
-	self.variable = variable
-	WidgetWithCommand.__init__(self)
-	Widget.__init__(self, master, "menubutton", kw)
-	#self.widgetName = 'tk_optionMenu'
-	if command:
-	    self.set_command(command, args)
+                 variable = None):
+        kw = option_menu_defaults.copy()
+        if variable is not None:
+            kw['textvariable'] = variable
+        self.variable = variable
+        WidgetWithCommand.__init__(self)
+        Widget.__init__(self, master, "menubutton", kw)
+        #self.widgetName = 'tk_optionMenu'
+        if command:
+            self.set_command(command, args)
 
-	entries = []
-	for value in values:
-	    entries.append(MenuCommand(value, command = self.choose_opt,
-				       args = value))
-	self.__menu = UpdatedMenu(self, entries, auto_update = 0,
-				  name="menu", tearoff=0)
-	menu = self.__menu.menu
-	self.menuname = menu._w
-	self["menu"] = menu
+        entries = []
+        for value in values:
+            entries.append(MenuCommand(value, command = self.choose_opt,
+                                       args = value))
+        self.__menu = UpdatedMenu(self, entries, auto_update = 0,
+                                  name="menu", tearoff=0)
+        menu = self.__menu.menu
+        self.menuname = menu._w
+        self["menu"] = menu
 
     def destroy(self):
-	WidgetWithCommand.clean_up(self)
-	Menubutton.destroy(self)
-	self.__menu = None
+        WidgetWithCommand.clean_up(self)
+        Menubutton.destroy(self)
+        self.__menu = None
 
     def choose_opt(self, value):
-	self['text'] = value
-	self._call_cmd(value)
+        self['text'] = value
+        self._call_cmd(value)
 
     def __getitem__(self, name):
-	if name == 'menu':
-	    return self.__menu.menu
-	return Widget.__getitem__(self, name)
+        if name == 'menu':
+            return self.__menu.menu
+        return Widget.__getitem__(self, name)
 
 
 class MyOptionMenu2(WidgetWithCommand, Menubutton):
@@ -841,66 +841,66 @@
     tk_widget_has_command = 0
 
     def __init__(self, master, values, command = None, args = (),
-		 entry_type = 'text', **rest):
-	kw = option_menu_defaults.copy()
-	kw.update(rest)
-	WidgetWithCommand.__init__(self)
-	Widget.__init__(self, master, "menubutton", kw)
-	self.widgetName = 'tk_optionMenu'
-	if command:
-	    self.set_command(command, args)
+                 entry_type = 'text', **rest):
+        kw = option_menu_defaults.copy()
+        kw.update(rest)
+        WidgetWithCommand.__init__(self)
+        Widget.__init__(self, master, "menubutton", kw)
+        self.widgetName = 'tk_optionMenu'
+        if command:
+            self.set_command(command, args)
 
-	entries = []
-	value_dict = {}
-	cfg = {'command' : self.choose_opt}
-	for value in values:
-	    if type(value) == TupleType:
-		text, value = value
-	    else:
-		text = value
-	    value_dict[value] = text
-	    if not rest.has_key('initial'):
-		rest['initial'] = value
+        entries = []
+        value_dict = {}
+        cfg = {'command' : self.choose_opt}
+        for value in values:
+            if type(value) == TupleType:
+                text, value = value
+            else:
+                text = value
+            value_dict[value] = text
+            if not rest.has_key('initial'):
+                rest['initial'] = value
 
-	    cfg[entry_type] = text
-	    cfg['args'] = (value,)
-	    entries.append(apply(MenuCommand, (), cfg))
+            cfg[entry_type] = text
+            cfg['args'] = (value,)
+            entries.append(apply(MenuCommand, (), cfg))
 
-	self.__menu = UpdatedMenu(self, entries, auto_update = 0,
-				  name="menu", tearoff=0)
-	menu = self.__menu.menu
-	self.menuname = menu._w
-	self["menu"] = menu
-	self.entry_type = entry_type
-	self.value_dict = value_dict
-	if rest.has_key('initial'):
-	    self.SetValue(rest['initial'])
+        self.__menu = UpdatedMenu(self, entries, auto_update = 0,
+                                  name="menu", tearoff=0)
+        menu = self.__menu.menu
+        self.menuname = menu._w
+        self["menu"] = menu
+        self.entry_type = entry_type
+        self.value_dict = value_dict
+        if rest.has_key('initial'):
+            self.SetValue(rest['initial'])
 
     def destroy(self):
-	WidgetWithCommand.clean_up(self)
-	Menubutton.destroy(self)
-	self.__menu = None
+        WidgetWithCommand.clean_up(self)
+        Menubutton.destroy(self)
+        self.__menu = None
 
     def choose_opt(self, value):
-	self.SetValue(value)
-	self._call_cmd(value)
+        self.SetValue(value)
+        self._call_cmd(value)
 
     def SetValue(self, value, text = None):
-	try:
-	    text = self.value_dict[value]
-	except KeyError:
-	    if text is None:
-		return
-	self[self.entry_type] = text
-	self.value = value
+        try:
+            text = self.value_dict[value]
+        except KeyError:
+            if text is None:
+                return
+        self[self.entry_type] = text
+        self.value = value
 
     def GetValue(self):
-	return self.value
+        return self.value
 
     def __getitem__(self, name):
-	if name == 'menu':
-	    return self.__menu.menu
-	return Widget.__getitem__(self, name)
+        if name == 'menu':
+            return self.__menu.menu
+        return Widget.__getitem__(self, name)
 
 
 def MakeMethodCommand(method, *args):

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/tooltips.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/tooltips.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/tooltips.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -31,84 +31,84 @@
 class Tooltips:
 
     def __init__(self):
-	self.descriptions = {}
-	self.balloon = None
-	self.balloon_label = None
-	self.last_widget = ''
-	self.after_id = None
+        self.descriptions = {}
+        self.balloon = None
+        self.balloon_label = None
+        self.last_widget = ''
+        self.after_id = None
 
     def AddDescription(self, widget, description):
-	self.descriptions[widget._w] = description
-	if widget._w == self.last_widget:
-	    self.balloon_label['text'] = description
+        self.descriptions[widget._w] = description
+        if widget._w == self.last_widget:
+            self.balloon_label['text'] = description
 
     def RemoveDescription(self, widget):
-	if type(widget) == InstanceType:
-	    widget = widget._w
-	if self.descriptions.has_key(widget):
-	    del self.descriptions[widget]
+        if type(widget) == InstanceType:
+            widget = widget._w
+        if self.descriptions.has_key(widget):
+            del self.descriptions[widget]
 
     def GetDescription(self, widget):
-	if type(widget) == InstanceType:
-	    widget = widget._w
-	if self.descriptions.has_key(widget):
-	    return self.descriptions[widget]
-	return ''
+        if type(widget) == InstanceType:
+            widget = widget._w
+        if self.descriptions.has_key(widget):
+            return self.descriptions[widget]
+        return ''
 
 
     def create_balloon(self, root):
-	self.root = root
-	self.balloon = Toplevel(self.root, name = 'tooltips')
-	self.balloon.withdraw()
-	self.balloon.overrideredirect(1)
-	label = Label(self.balloon, name = 'label', text = 'Tooltip')
-	label.pack()
-	self.balloon_label = label
+        self.root = root
+        self.balloon = Toplevel(self.root, name = 'tooltips')
+        self.balloon.withdraw()
+        self.balloon.overrideredirect(1)
+        label = Label(self.balloon, name = 'label', text = 'Tooltip')
+        label.pack()
+        self.balloon_label = label
 
 
     def popup_balloon(self, widget_name, x, y, text):
-	self.last_widget = widget_name
-	self.balloon.withdraw()
-	self.balloon_label['text'] = text
-	x = x - self.balloon_label.winfo_reqwidth() / 2
-	self.balloon.geometry('%+d%+d' % (x, y))
-	self.balloon.update()
-	self.balloon.deiconify()
-	self.balloon.tkraise()
+        self.last_widget = widget_name
+        self.balloon.withdraw()
+        self.balloon_label['text'] = text
+        x = x - self.balloon_label.winfo_reqwidth() / 2
+        self.balloon.geometry('%+d%+d' % (x, y))
+        self.balloon.update()
+        self.balloon.deiconify()
+        self.balloon.tkraise()
 
     def popup_delayed(self, widget_name, x, y, text, *args):
-	self.after_id = None
-	self.popup_balloon(widget_name, x, y, text)
+        self.after_id = None
+        self.popup_balloon(widget_name, x, y, text)
 
     def enter_widget(self, widget_name):
-	text = self.GetDescription(widget_name)
-	if text:
-	    widget = self.root.nametowidget(widget_name)
-	    x = widget.winfo_rootx() + widget.winfo_width() / 2
-	    y = widget.winfo_rooty() + widget.winfo_height()
-	    #y = y + height
-	    #x = x + width / 2
-	    if self.after_id:
-		print 'after_id in enter'
-		self.root.after_cancel(self.after_id)
-	    self.after_id = self.root.after(config.preferences.tooltip_delay,
-					    self.popup_delayed,
-					    widget_name, x, y, text)
+        text = self.GetDescription(widget_name)
+        if text:
+            widget = self.root.nametowidget(widget_name)
+            x = widget.winfo_rootx() + widget.winfo_width() / 2
+            y = widget.winfo_rooty() + widget.winfo_height()
+            #y = y + height
+            #x = x + width / 2
+            if self.after_id:
+                print 'after_id in enter'
+                self.root.after_cancel(self.after_id)
+            self.after_id = self.root.after(config.preferences.tooltip_delay,
+                                            self.popup_delayed,
+                                            widget_name, x, y, text)
 
     def leave_widget(self, widget_name):
-	global last_widget, after_id
-	if self.after_id is not None:
-	    self.root.after_cancel(self.after_id)
-	    self.after_id = None
-	    self.last_widget = ''
-	last_widget = ''
-	self.balloon.withdraw()
+        global last_widget, after_id
+        if self.after_id is not None:
+            self.root.after_cancel(self.after_id)
+            self.after_id = None
+            self.last_widget = ''
+        last_widget = ''
+        self.balloon.withdraw()
 
     button_press = leave_widget
 
 
     def destroy_widget(self, event):
-	self.RemoveDescription(event.widget)
+        self.RemoveDescription(event.widget)
 
 
 _tooltips = Tooltips()
@@ -117,11 +117,11 @@
 
 def Init(root):
     if config.preferences.activate_tooltips:
-	root.tk.call('bind', 'all', '<Enter>',
-		     tkext.MakeMethodCommand(_tooltips.enter_widget, '%W'))
-	root.tk.call('bind', 'all', '<Leave>',
-		     tkext.MakeMethodCommand(_tooltips.leave_widget, '%W'))
-	root.tk.call('bind', 'all', '<ButtonPress>',
-		     tkext.MakeMethodCommand(_tooltips.button_press, '%W'))
-	_tooltips.create_balloon(root)
+        root.tk.call('bind', 'all', '<Enter>',
+                     tkext.MakeMethodCommand(_tooltips.enter_widget, '%W'))
+        root.tk.call('bind', 'all', '<Leave>',
+                     tkext.MakeMethodCommand(_tooltips.leave_widget, '%W'))
+        root.tk.call('bind', 'all', '<ButtonPress>',
+                     tkext.MakeMethodCommand(_tooltips.button_press, '%W'))
+        _tooltips.create_balloon(root)
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/view.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/view.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/view.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -32,155 +32,155 @@
     document = None
 
     def __init__(self, master=None, toplevel = None, document = None,
-		 show_visible = 0, show_printable = 1,
-		 resolution = None, **kw):
-	apply(PyWidget.__init__, (self, master), kw)
-	Viewport.__init__(self, resolution)
-	QueueingPublisher.__init__(self)
-	self.toplevel = toplevel
+                 show_visible = 0, show_printable = 1,
+                 resolution = None, **kw):
+        apply(PyWidget.__init__, (self, master), kw)
+        Viewport.__init__(self, resolution)
+        QueueingPublisher.__init__(self)
+        self.toplevel = toplevel
 
-	self.move_window_count = 0
-	self.show_page_outline = 1
-	self.show_visible = show_visible
-	self.show_printable = show_printable
-	self.gcs_initialized = 0
-	self.gc = GraphicsDevice()
+        self.move_window_count = 0
+        self.show_page_outline = 1
+        self.show_visible = show_visible
+        self.show_printable = show_printable
+        self.gcs_initialized = 0
+        self.gc = GraphicsDevice()
 
-	self.init_transactions()
-	if document is not None:
-	    self.SetDocument(document)
-	else:
-	    self.SetDocument(Document(create_layer = 1))
+        self.init_transactions()
+        if document is not None:
+            self.SetDocument(document)
+        else:
+            self.SetDocument(Document(create_layer = 1))
 
     def destroy(self):
         self.unsubscribe_doc()
-	PyWidget.destroy(self)
-	QueueingPublisher.Destroy(self)
+        PyWidget.destroy(self)
+        QueueingPublisher.Destroy(self)
 
 
     def MapMethod(self):
-	# when being mapped the first time, initialise the gcs. this cannot be
-	# done earlier, because the hitgc creates a pixmap which currently
-	# only works after the window (id) has been created. In Xt this can be
-	# done in the Realize widget method (after calling the superclass'
-	# method), but Tk doesn't seem to offer any similar thing.
-	if not self.gcs_initialized:
-	    self.init_gcs()
-	    self.issue_state()
+        # when being mapped the first time, initialise the gcs. this cannot be
+        # done earlier, because the hitgc creates a pixmap which currently
+        # only works after the window (id) has been created. In Xt this can be
+        # done in the Realize widget method (after calling the superclass'
+        # method), but Tk doesn't seem to offer any similar thing.
+        if not self.gcs_initialized:
+            self.init_gcs()
+            self.issue_state()
 
     def DestroyMethod(self):
-	# make sure that gc is deleted. gc may have a shared memory ximage
-	# which is not freed if the gc is not destroyed leaving unused shared
-	# memory segments in the system even after the process has finished.
-	self.gc = None
-	PyWidget.DestroyMethod(self)
+        # make sure that gc is deleted. gc may have a shared memory ximage
+        # which is not freed if the gc is not destroyed leaving unused shared
+        # memory segments in the system even after the process has finished.
+        self.gc = None
+        PyWidget.DestroyMethod(self)
 
     def init_gcs(self):
-	self.gc.init_gc(self.tkwin, graphics_exposures = 1)
-	self.gc.draw_visible = self.show_visible
-	self.gc.draw_printable = self.show_printable
-	self.gc.allow_outline = 0
-	self.gcs_initialized = 1
-	self.default_view()
-	self.set_gc_transforms()
+        self.gc.init_gc(self.tkwin, graphics_exposures = 1)
+        self.gc.draw_visible = self.show_visible
+        self.gc.draw_printable = self.show_printable
+        self.gc.allow_outline = 0
+        self.gcs_initialized = 1
+        self.default_view()
+        self.set_gc_transforms()
 
     def default_view(self):
         self.FitPageToWindow()
 
     def set_gc_transforms(self):
-	self.gc.SetViewportTransform(self.scale, self.doc_to_win,
-				     self.win_to_doc)
+        self.gc.SetViewportTransform(self.scale, self.doc_to_win,
+                                     self.win_to_doc)
 
     #
     #	Channels
     #
 
     def issue_state(self):
-	self.queue_message(STATE)
+        self.queue_message(STATE)
 
     def issue_view(self):
-	self.queue_message(VIEW)
+        self.queue_message(VIEW)
 
     def issue_document(self):
-	self.doc_changed = 1
+        self.doc_changed = 1
 
     def queue_message(self, Publisher):
-	if self.transaction:
-	    QueueingPublisher.queue_message(self, Publisher)
-	else:
-	    self.issue(Publisher)
+        if self.transaction:
+            QueueingPublisher.queue_message(self, Publisher)
+        else:
+            self.issue(Publisher)
 
     def init_transactions(self):
-	self.sb_update_pending = 0
-	self.doc_changed = 0
-	self.transaction = 0
+        self.sb_update_pending = 0
+        self.doc_changed = 0
+        self.transaction = 0
 
     def begin_transaction(self):
-	self.transaction = self.transaction + 1
+        self.transaction = self.transaction + 1
 
     def end_transaction(self):
-	self.transaction = self.transaction - 1
-	if self.transaction == 0:
-	    if self.doc_changed:
-		self.issue(DOCUMENT, self.document)
-	    self.sb_update_pending = 0
-	    self.doc_changed = 0
-	    self.flush_message_queue()
-	elif self.transaction < 0:
-	    raise SketchInternalError('transaction count < 0')
+        self.transaction = self.transaction - 1
+        if self.transaction == 0:
+            if self.doc_changed:
+                self.issue(DOCUMENT, self.document)
+            self.sb_update_pending = 0
+            self.doc_changed = 0
+            self.flush_message_queue()
+        elif self.transaction < 0:
+            raise SketchInternalError('transaction count < 0')
 
     #
     #	receivers
     #
 
     def redraw_doc(self, all, rects = None):
-	if all:
-	    self.clear_window()
-	else:
-	    map(self.clear_area_doc, rects)
+        if all:
+            self.clear_window()
+        else:
+            map(self.clear_area_doc, rects)
 
     def layout_changed(self):
         self.SetPageSize(self.document.Layout().Size())
         self.set_gc_transforms()
         self.update_scrollbars()
         self.update_rulers()
-	if self.show_page_outline:
-	    self.clear_window()
+        if self.show_page_outline:
+            self.clear_window()
 
     def layer_changed(self, *args):
-	if args:
-	    redraw = EmptyRect
-	    if args[0] == LAYER_STATE:
-		layer, visible_changed, printable_changed, outlined_changed \
-		       = args[1]
-		rect = layer.bounding_rect
-		if rect is not EmptyRect:
-		    if self.show_printable and printable_changed:
-			redraw = rect
-		    if self.show_visible:
-			if visible_changed:
-			    redraw = rect
-			if outlined_changed and layer.Visible():
-			    redraw = rect
-	    elif args[0] == LAYER_ORDER:
-		layer = args[1]
-		if (self.show_printable and layer.Printable()
-		    or self.show_visible and layer.Visible()):
-		    redraw = layer.bounding_rect
-		if len(args) > 2:
-		    other = args[2]
-		    if (self.show_printable and other.Printable()
-			or self.show_visible and other.Visible()):
-			redraw = IntersectRects(redraw, other.bounding_rect)
-		    else:
-			redraw = EmptyRect
-	    elif args[0] == LAYER_COLOR:
-		layer = args[1]
-		rect = layer.bounding_rect
-		if self.show_visible and rect is not EmptyRect \
-		   and layer.Visible():
-		    redraw = rect
-	    self.clear_area_doc(redraw)
+        if args:
+            redraw = EmptyRect
+            if args[0] == LAYER_STATE:
+                layer, visible_changed, printable_changed, outlined_changed \
+                     = args[1]
+                rect = layer.bounding_rect
+                if rect is not EmptyRect:
+                    if self.show_printable and printable_changed:
+                        redraw = rect
+                    if self.show_visible:
+                        if visible_changed:
+                            redraw = rect
+                        if outlined_changed and layer.Visible():
+                            redraw = rect
+            elif args[0] == LAYER_ORDER:
+                layer = args[1]
+                if (self.show_printable and layer.Printable()
+                    or self.show_visible and layer.Visible()):
+                    redraw = layer.bounding_rect
+                if len(args) > 2:
+                    other = args[2]
+                    if (self.show_printable and other.Printable()
+                        or self.show_visible and other.Visible()):
+                        redraw = IntersectRects(redraw, other.bounding_rect)
+                    else:
+                        redraw = EmptyRect
+            elif args[0] == LAYER_COLOR:
+                layer = args[1]
+                rect = layer.bounding_rect
+                if self.show_visible and rect is not EmptyRect \
+                   and layer.Visible():
+                    redraw = rect
+            self.clear_area_doc(redraw)
 
     #
     #	Widget Methods (Redraw, ... )
@@ -188,27 +188,27 @@
 
     time_redraw = 0
     def RedrawMethod(self, region = None):
-	# draw the document
-	if __debug__:
-	    if self.time_redraw:
-		import time
-		start = time.clock()
-	if self.move_window_count >= 2:
-	    self.clear_window(update = 0)
-	self.move_window_count = 0
+        # draw the document
+        if __debug__:
+            if self.time_redraw:
+                import time
+                start = time.clock()
+        if self.move_window_count >= 2:
+            self.clear_window(update = 0)
+        self.move_window_count = 0
 
-	region = self.do_clear(region)
+        region = self.do_clear(region)
 
-	# draw document
-	self.gc.InitClip()
-	self.gc.ResetFontCache()
-	if region:
-	    self.gc.PushClip()
-	    self.gc.ClipRegion(region)
+        # draw document
+        self.gc.InitClip()
+        self.gc.ResetFontCache()
+        if region:
+            self.gc.PushClip()
+            self.gc.ClipRegion(region)
 
         tkwin = self.tkwin
-	if region:
-	    x, y, w, h = region.ClipBox()
+        if region:
+            x, y, w, h = region.ClipBox()
             if x < 0:
                 w = w - x; x = 0
             if y < 0:
@@ -217,36 +217,36 @@
                 w = tkwin.width
             if h > tkwin.height:
                 h = tkwin.height
-	else:
-	    x = y = 0
-	    w = tkwin.width
-	    h = tkwin.height
-	p1 = self.WinToDoc(x - 1, y - 1)
-	p2 = self.WinToDoc(x + w + 1, y + h + 1)
-	rect = Rect(p1, p2)
+        else:
+            x = y = 0
+            w = tkwin.width
+            h = tkwin.height
+        p1 = self.WinToDoc(x - 1, y - 1)
+        p2 = self.WinToDoc(x + w + 1, y + h + 1)
+        rect = Rect(p1, p2)
 
         self.gc.SetFillColor(StandardColors.white)
         self.gc.gc.FillRectangle(x, y, w, h) # XXX ugly to access gc.gc
 
-	#	draw paper
-	if self.show_page_outline:
-	    w, h = self.document.PageSize()
-	    self.gc.DrawPageOutline(w, h)
+        #	draw paper
+        if self.show_page_outline:
+            w, h = self.document.PageSize()
+            self.gc.DrawPageOutline(w, h)
 
 
-	self.document.Draw(self.gc, rect)
-	if region:
-	    self.gc.PopClip()
+        self.document.Draw(self.gc, rect)
+        if region:
+            self.gc.PopClip()
 
-	if __debug__:
-	    if self.time_redraw:
-		pdebug('timing', 'redraw', time.clock() - start)
+        if __debug__:
+            if self.time_redraw:
+                pdebug('timing', 'redraw', time.clock() - start)
 
-	return region
+        return region
 
     def ResizedMethod(self, width, height):
-	Viewport.ResizedMethod(self, width, height)
-	self.gc.WindowResized(width, height)
+        Viewport.ResizedMethod(self, width, height)
+        self.gc.WindowResized(width, height)
 
 
     #
@@ -257,11 +257,11 @@
     #
 
     def ForceRedraw(self):
-	# Force a redraw of the whole window
-	self.clear_window()
-	if __debug__:
-	    #self.time_redraw = 1
-	    pass
+        # Force a redraw of the whole window
+        self.clear_window()
+        if __debug__:
+            #self.time_redraw = 1
+            pass
 
 #     def SetScrollbars(self, hbar, vbar):
 # 	Viewport.SetScrollbars(self, hbar, vbar)
@@ -269,64 +269,64 @@
 # 	vbar.configure(jump = 1)
 
     def set_origin(self, xorg, yorg, move_contents = 1):
-	self.begin_transaction()
-	try:
-	    Viewport.set_origin(self, xorg, yorg,
-				move_contents = move_contents)
-	    self.set_gc_transforms()
-	    self.issue_view()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            Viewport.set_origin(self, xorg, yorg,
+                                move_contents = move_contents)
+            self.set_gc_transforms()
+            self.issue_view()
+        finally:
+            self.end_transaction()
 
     def move_window_contents(self, offx, offy):
-	# implement the method needed by Viewport.set_origin
-	w = self.tkwin
-	width = w.width
-	height = w.height
-	if abs(offx) < width and abs(offy) < height:
-	    w.CopyArea(w, self.gc.gc, offx, offy, width, height, 0, 0)
-	    self.move_window_count = self.move_window_count + 1
-	else:
-	    self.clear_window()
+        # implement the method needed by Viewport.set_origin
+        w = self.tkwin
+        width = w.width
+        height = w.height
+        if abs(offx) < width and abs(offy) < height:
+            w.CopyArea(w, self.gc.gc, offx, offy, width, height, 0, 0)
+            self.move_window_count = self.move_window_count + 1
+        else:
+            self.clear_window()
 
     def SetScale(self, scale, do_center = 1):
-	# Set current scale
-	self.begin_transaction()
-	try:
-	    Viewport.SetScale(self, scale, do_center = do_center)
-	    self.set_gc_transforms()
-	finally:
-	    self.end_transaction()
+        # Set current scale
+        self.begin_transaction()
+        try:
+            Viewport.SetScale(self, scale, do_center = do_center)
+            self.set_gc_transforms()
+        finally:
+            self.end_transaction()
 
     def zoom_fit_rect(self, rect, save_viewport = 0):
-	if save_viewport:
-	    self.save_viewport()
-	Viewport.zoom_fit_rect(self, rect)
+        if save_viewport:
+            self.save_viewport()
+        Viewport.zoom_fit_rect(self, rect)
 
 
     #
     #	other view related methods
     #
     def FitToWindow(self, selected_only = 0, save_viewport = 1):
-	self.begin_transaction()
-	try:
-	    if selected_only:
-		rect = self.document.SelectionBoundingRect()
-	    else:
-		rect = self.document.BoundingRect()
-	    if rect:
-		self.zoom_fit_rect(rect, save_viewport = save_viewport)
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            if selected_only:
+                rect = self.document.SelectionBoundingRect()
+            else:
+                rect = self.document.BoundingRect()
+            if rect:
+                self.zoom_fit_rect(rect, save_viewport = save_viewport)
+        finally:
+            self.end_transaction()
 
     def FitPageToWindow(self, save_viewport = 1):
-	self.begin_transaction()
-	try:
-	    w, h = self.document.PageSize()
-	    self.zoom_fit_rect(Rect(0, 0, w, h).grown(10),
-			       save_viewport = save_viewport)
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            w, h = self.document.PageSize()
+            self.zoom_fit_rect(Rect(0, 0, w, h).grown(10),
+                               save_viewport = save_viewport)
+        finally:
+            self.end_transaction()
 
 
     #
@@ -337,49 +337,49 @@
     #	way the drawing is displayed and thus issues VIEW.
 
     def SetOutlineMode(self, on = 1):
-	self.begin_transaction()
-	try:
-	    if on:
-		if self.gc.IsOutlineActive():
-		    return
-		else:
-		    self.gc.StartOutlineMode()
-		    self.hitgc.StartOutlineMode()
-	    else:
-		if self.gc.IsOutlineActive():
-		    self.gc.EndOutlineMode()
-		    self.hitgc.EndOutlineMode()
-		else:
-		    return
-	    self.issue_view()
-	    self.clear_window()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            if on:
+                if self.gc.IsOutlineActive():
+                    return
+                else:
+                    self.gc.StartOutlineMode()
+                    self.hitgc.StartOutlineMode()
+            else:
+                if self.gc.IsOutlineActive():
+                    self.gc.EndOutlineMode()
+                    self.hitgc.EndOutlineMode()
+                else:
+                    return
+            self.issue_view()
+            self.clear_window()
+        finally:
+            self.end_transaction()
 
     def ToggleOutlineMode(self):
-	self.SetOutlineMode(not self.IsOutlineMode())
+        self.SetOutlineMode(not self.IsOutlineMode())
 
     def IsOutlineMode(self):
-	return self.gc and self.gc.IsOutlineActive()
+        return self.gc and self.gc.IsOutlineActive()
 
     #
     #	Show page outline on/off
     #
 
     def SetPageOutlineMode(self, on = 1):
-	self.begin_transaction()
-	try:
-	    self.show_page_outline = on
-	    self.issue_view()
-	    self.clear_window()
-	finally:
-	    self.end_transaction()
+        self.begin_transaction()
+        try:
+            self.show_page_outline = on
+            self.issue_view()
+            self.clear_window()
+        finally:
+            self.end_transaction()
 
     def TogglePageOutlineMode(self):
-	self.SetPageOutlineMode(not self.IsPageOutlineMode())
+        self.SetPageOutlineMode(not self.IsPageOutlineMode())
 
     def IsPageOutlineMode(self):
-	return self.show_page_outline
+        return self.show_page_outline
 
     #
     #
@@ -397,17 +397,17 @@
         self.document.Subscribe(LAYER, self.layer_changed)
 
     def SetDocument(self, doc):
-	self.begin_transaction()
-	try:
+        self.begin_transaction()
+        try:
             self.unsubscribe_doc()
-	    self.document = doc
+            self.document = doc
             self.subscribe_doc()
-	    self.clear_window()
-	    self.SetPageSize(self.document.Layout().Size())
-	    self.FitPageToWindow(save_viewport = 0)
-	    self.issue_document()
-	    self.issue_state()
-	    self.issue_view()
-	finally:
-	    self.end_transaction()
+            self.clear_window()
+            self.SetPageSize(self.document.Layout().Size())
+            self.FitPageToWindow(save_viewport = 0)
+            self.issue_document()
+            self.issue_state()
+            self.issue_view()
+        finally:
+            self.end_transaction()
 

Modified: skencil/branches/skencil-0.6/src/Sketch/UI/viewport.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/UI/viewport.py	2010-09-22 21:53:17 UTC (rev 729)
+++ skencil/branches/skencil-0.6/src/Sketch/UI/viewport.py	2010-09-22 21:53:59 UTC (rev 730)
@@ -26,93 +26,93 @@
     min_scale = 0.05
 
     def __init__(self, resolution = None):
-	self.hbar = None
-	self.vbar = None
-	self.hruler = None
-	self.vruler = None
+        self.hbar = None
+        self.vbar = None
+        self.hruler = None
+        self.vruler = None
 
-	self.base_width = 3000
-	self.base_height = 3000
-	self.nominal_scale = 1
-	self.scale = 1.0
-	self.virtual_width = self.base_width
-	self.virtual_height =  self.base_height
-	self.virtual_x = 0
-	self.virtual_y = 0
-	self.init_resolution(resolution)
-	self.set_page_size(Papersize['A4']) # XXX config
-	self.compute_win_to_doc()
-	self.clear_rects = []
-	self.clear_entire_window = 0
+        self.base_width = 3000
+        self.base_height = 3000
+        self.nominal_scale = 1
+        self.scale = 1.0
+        self.virtual_width = self.base_width
+        self.virtual_height =  self.base_height
+        self.virtual_x = 0
+        self.virtual_y = 0
+        self.init_resolution(resolution)
+        self.set_page_size(Papersize['A4']) # XXX config
+        self.compute_win_to_doc()
+        self.clear_rects = []
+        self.clear_entire_window = 0
 
-	self.init_viewport_ring()
+        self.init_viewport_ring()
 
 
     def init_resolution(self, resolution):
-	if resolution is not None:
-	    self.pixel_per_point = resolution
-	else:
-	    width = self.winfo_screenwidth()
-	    width_mm = self.winfo_screenmmwidth()
-	    pixel_per_point = (width / float(width_mm)) * 25.4 / 72
-	    self.pixel_per_point = float(pixel_per_point)
-	self.max_scale = self.__class__.max_scale * self.pixel_per_point
+        if resolution is not None:
+            self.pixel_per_point = resolution
+        else:
+            width = self.winfo_screenwidth()
+            width_mm = self.winfo_screenmmwidth()
+            pixel_per_point = (width / float(width_mm)) * 25.4 / 72
+            self.pixel_per_point = float(pixel_per_point)
+        self.max_scale = self.__class__.max_scale * self.pixel_per_point
 
     #
     #	Coordinate conversions
     #
 
     def set_page_size(self, (width, height)):
-	self.page_width = width
-	self.page_height = height
+        self.page_width = width
+        self.page_height = height
 
     def compute_win_to_doc(self):
-	scale = self.scale
-	# virtual coords of ll corner of page
-	llx = (self.virtual_width - self.page_width * scale) / 2
-	lly = (self.virtual_height + self.page_height * scale) / 2
-	self.doc_to_win = Trafo(scale, 0.0, 0.0, -scale,
-				llx - self.virtual_x, lly - self.virtual_y)
-	scale = 1.0 / scale
-	self.win_to_doc = Trafo(scale, 0.0, 0.0, -scale,
-				(self.virtual_x - llx) * scale,
-				(lly - self.virtual_y) * scale)
+        scale = self.scale
+        # virtual coords of ll corner of page
+        llx = (self.virtual_width - self.page_width * scale) / 2
+        lly = (self.virtual_height + self.page_height * scale) / 2
+        self.doc_to_win = Trafo(scale, 0.0, 0.0, -scale,
+                                llx - self.virtual_x, lly - self.virtual_y)
+        scale = 1.0 / scale
+        self.win_to_doc = Trafo(scale, 0.0, 0.0, -scale,
+                                (self.virtual_x - llx) * scale,
+                                (lly - self.virtual_y) * scale)
 
     #	document to window coordinates
 
     def DocToWin(self, *args):
-	# returns a tuple of ints
-	return apply(self.doc_to_win.DocToWin, args)
+        # returns a tuple of ints
+        return apply(self.doc_to_win.DocToWin, args)
 
     #	window to document coordinates
 
     def WinToDoc(self, *args):
-	return apply(self.win_to_doc, args)
+        return apply(self.win_to_doc, args)
 
     def LengthToDoc(self, len):
-	return len / self.scale
+        return len / self.scale
 
     #
     #	Redraw Parts of the window.
     #
 
     def clear_area_doc(self, rect):
-	# Mark the rectangular area of self, given by RECT in document
-	# coordinates, as invalid. The rect is put into a list of rects
-	# that have to be cleared via do_clear() once RedrawMethod() is
-	# invoked.
-	if not self.clear_entire_window:
-	    if rect is EmptyRect:
-		return
-	    elif rect is InfinityRect:
-		self.clear_window()
-	    elif type(rect) == RectType:
-		x1, y1 = self.DocToWin(rect.left, rect.top)
-		x2, y2 = self.DocToWin(rect.right, rect.bottom)
-		if x1 > x2:
-		    t = x1; x1 = x2; x2 = t
-		if y1 > y2:
-		    t = y1; y1 = y2; y2 = t
+        # Mark the rectangular area of self, given by RECT in document
+        # coordinates, as invalid. The rect is put into a list of rects
+        # that have to be cleared via do_clear() once RedrawMethod() is
+        # invoked.
+        if not self.clear_entire_window:
+            if rect is EmptyRect:
+                return
+            elif rect is InfinityRect:
+                self.clear_window()
+            elif type(rect) == RectType:
+                x1, y1 = self.DocToWin(rect.left, rect.top)
+                x2, y2 = self.DocToWin(rect.right, rect.bottom)
+                if x1 > x2:
+                    t = x1; x1 = x2; x2 = t
+                if y1 > y2:
+                    t = y1; y1 = y2; y2 = t
 
                 # clip the rect to the window
                 if x1 < 0:
@@ -131,79 +131,79 @@
                     y2 = self.tkwin.height
                 elif y2 < 0:
                     return
-                
-		self.clear_rects.append((x1 - 1, y1 - 1,
-					 x2 - x1 + 2, y2 - y1 + 2))
-	    else:
-		# special case: clear a guide line
-		p, horizontal = rect
-		x, y = self.DocToWin(p)
-		if horizontal:
-		    self.clear_rects.append((0, y, self.tkwin.width, 1))
-		else:
-		    self.clear_rects.append((x, 0, 1, self.tkwin.height))
-	self.UpdateWhenIdle()
 
+                self.clear_rects.append((x1 - 1, y1 - 1,
+                                         x2 - x1 + 2, y2 - y1 + 2))
+            else:
+                # special case: clear a guide line
+                p, horizontal = rect
+                x, y = self.DocToWin(p)
+                if horizontal:
+                    self.clear_rects.append((0, y, self.tkwin.width, 1))
+                else:
+                    self.clear_rects.append((x, 0, 1, self.tkwin.height))
+        self.UpdateWhenIdle()
+
     def clear_window(self, update = 1):
-	# Mark the entire window as invalid.
-	self.clear_entire_window = 1
-	self.clear_rects = []
-	if update:
-	    self.UpdateWhenIdle()
+        # Mark the entire window as invalid.
+        self.clear_entire_window = 1
+        self.clear_rects = []
+        if update:
+            self.UpdateWhenIdle()
 
     def do_clear(self, region):
-	# Clear all areas marked as invalid by clear_area_doc() or
-	# clear_window(). These areas are added to REGION via its
-	# UnionRectWithRegion method. This function should be called by
-	# RedrawMethod() before any drawing is done.
-	if region and not self.clear_entire_window:
-	    clear_area = self.tkwin.ClearArea
-	    union = region.UnionRectWithRegion
-	    for rect in self.clear_rects:
-		apply(clear_area, rect + (0,))
-		apply(union, rect)
-	else:
-	    self.tkwin.ClearArea(0, 0, 0, 0, 0)
-	    region = None
-	self.clear_entire_window = 0
-	self.clear_rects = []
-	return region
+        # Clear all areas marked as invalid by clear_area_doc() or
+        # clear_window(). These areas are added to REGION via its
+        # UnionRectWithRegion method. This function should be called by
+        # RedrawMethod() before any drawing is done.
+        if region and not self.clear_entire_window:
+            clear_area = self.tkwin.ClearArea
+            union = region.UnionRectWithRegion
+            for rect in self.clear_rects:
+                apply(clear_area, rect + (0,))
+                apply(union, rect)
+        else:
+            self.tkwin.ClearArea(0, 0, 0, 0, 0)
+            region = None
+        self.clear_entire_window = 0
+        self.clear_rects = []
+        return region
 
     #
     #
     #
 
     def set_origin(self, xorg, yorg, move_contents = 1):
-	old_org_x = xo = self.virtual_x
-	old_org_y = yo = self.virtual_y
-	if xorg != None:
-	    xo = xorg
-	if yorg != None:
-	    yo = yorg
-	offx = round(xo - old_org_x)
-	offy = round(yo - old_org_y)
-	xo = old_org_x + offx
-	yo = old_org_y + offy
-	self.virtual_x = xo
-	self.virtual_y = yo
-	offx = int(offx)
-	offy = int(offy)
-	if move_contents and (offx or offy):
-	    self.move_window_contents(offx, offy)
-	self.compute_win_to_doc()
-	self.update_scrollbars()
-	self.update_rulers()
+        old_org_x = xo = self.virtual_x
+        old_org_y = yo = self.virtual_y
+        if xorg != None:
+            xo = xorg
+        if yorg != None:
+            yo = yorg
+        offx = round(xo - old_org_x)
+        offy = round(yo - old_org_y)
+        xo = old_org_x + offx
+        yo = old_org_y + offy
+        self.virtual_x = xo
+        self.virtual_y = yo
+        offx = int(offx)
+        offy = int(offy)
+        if move_contents and (offx or offy):
+            self.move_window_contents(offx, offy)
+        self.compute_win_to_doc()
+        self.update_scrollbars()
+        self.update_rulers()
 
 
     def move_window_contents(self, offx, offy):
-	# Noop here, because moving the window contents requires a gc.
-	# The implementation could be as follows:
-	#
-	#	w = self.tkwin
-	#	width = w.width
-	#	height = w.height
-	#	w.CopyArea(w, self.gc.gc, offx, offy, width, height, 0, 0)
-	pass
+        # Noop here, because moving the window contents requires a gc.
+        # The implementation could be as follows:
+        #
+        #	w = self.tkwin
+        #	width = w.width
+        #	height = w.height
+        #	w.CopyArea(w, self.gc.gc, offx, offy, width, height, 0, 0)
+        pass
 
 
     #
@@ -211,45 +211,45 @@
     #
 
     def SetCenter(self, center, move_contents = 1):
-	# set origin so that center (in doc-coords) is in the center of the
-	# widget
-	cx, cy = self.DocToWin(center)
-	self.set_origin(self.virtual_x + cx - self.tkwin.width / 2,
-			self.virtual_y + cy - self.tkwin.height / 2,
-			move_contents = move_contents)
+        # set origin so that center (in doc-coords) is in the center of the
+        # widget
+        cx, cy = self.DocToWin(center)
+        self.set_origin(self.virtual_x + cx - self.tkwin.width / 2,
+                        self.virtual_y + cy - self.tkwin.height / 2,
+                        move_contents = move_contents)
 
     def SetScale(self, scale, do_center = 1):
-	# Set current scale
-	scale = scale * self.pixel_per_point
-	if scale > self.max_scale:
-	    scale = self.max_scale
-	elif scale < self.min_scale:
-	    scale = self.min_scale
-	self.scale = scale
-	self.nominal_scale = scale / self.pixel_per_point
-	width = int(scale * self.base_width)
-	height = int(scale * self.base_height)
-	self.virtual_width = width
-	self.virtual_height = height
-	if do_center:
-	    cx = self.tkwin.width / 2
-	    cy = self.tkwin.height / 2
-	    center = self.WinToDoc(cx, cy)
+        # Set current scale
+        scale = scale * self.pixel_per_point
+        if scale > self.max_scale:
+            scale = self.max_scale
+        elif scale < self.min_scale:
+            scale = self.min_scale
+        self.scale = scale
+        self.nominal_scale = scale / self.pixel_per_point
+        width = int(scale * self.base_width)
+        height = int(scale * self.base_height)
+        self.virtual_width = width
+        self.virtual_height = height
+        if do_center:
+            cx = self.tkwin.width / 2
+            cy = self.tkwin.height / 2
+            center = self.WinToDoc(cx, cy)
 
-	self.compute_win_to_doc()
+        self.compute_win_to_doc()
 
-	if do_center:
-	    self.SetCenter(center, move_contents = 0)
-	else:
-	    self.set_origin(0, 0, move_contents = 0)
+        if do_center:
+            self.SetCenter(center, move_contents = 0)
+        else:
+            self.set_origin(0, 0, move_contents = 0)
 
-	self.gc.SetViewportTransform(scale, self.doc_to_win, self.win_to_doc)
+        self.gc.SetViewportTransform(scale, self.doc_to_win, self.win_to_doc)
 
-	self.clear_window()
+        self.clear_window()
 
     def SetPageSize(self, size):
-	self.set_page_size(size)
-	self.compute_win_to_doc()
+        self.set_page_size(size)
+        self.compute_win_to_doc()
 
     def Scale(self):
         return self.scale
@@ -259,34 +259,34 @@
     #
 
     def zoom_fit_rect(self, rect):
-	# set the scale and origin of the canvas so that the document
-	# rectangle rect is centered and fills the window (keeping the aspect
-	# ratio)
-	epsilon = 1e-10
+        # set the scale and origin of the canvas so that the document
+        # rectangle rect is centered and fills the window (keeping the aspect
+        # ratio)
+        epsilon = 1e-10
 
-	rw = rect.right - rect.left
-	if abs(rw) < epsilon:
-	    return
-	width = self.tkwin.width
-	scalex = float(width) / rw
+        rw = rect.right - rect.left
+        if abs(rw) < epsilon:
+            return
+        width = self.tkwin.width
+        scalex = float(width) / rw
 
-	rh = rect.top - rect.bottom
-	if abs(rh) < epsilon:
-	    return
-	height = self.tkwin.height
-	scaley = float(height) / rh
+        rh = rect.top - rect.bottom
+        if abs(rh) < epsilon:
+            return
+        height = self.tkwin.height
+        scaley = float(height) / rh
 
-	scale = min((scalex, scaley, self.max_scale))
+        scale = min((scalex, scaley, self.max_scale))
 
-	self.SetScale(scale / self.pixel_per_point, do_center = 0)
-	self.SetCenter(rect.center(), move_contents = 0)
+        self.SetScale(scale / self.pixel_per_point, do_center = 0)
+        self.SetCenter(rect.center(), move_contents = 0)
 
 
     def ZoomInfoText(self):
-	# Return a string that describes the current zoom factor in percent.
-	# Usually this is displayed in a status bar.
+        # Return a string that describes the current zoom factor in percent.
+        # Usually this is displayed in a status bar.
         # NLS
-	return "%g%%" % round(100 * self.nominal_scale, 1)
+        return "%g%%" % round(100 * self.nominal_scale, 1)
 
 
     #
@@ -294,81 +294,81 @@
     #
 
     def ResizedMethod(self, width, height):
-	self.update_scrollbars()
+        self.update_scrollbars()
         self.update_rulers()
 
     def SetScrollbars(self, hbar, vbar):
-	self.hbar = hbar
-	self.vbar = vbar
+        self.hbar = hbar
+        self.vbar = vbar
 
     def SetRulers(self, hruler, vruler):
-	self.hruler = hruler
-	self.vruler = vruler
+        self.hruler = hruler
+        self.vruler = vruler
 
     def update_scrollbars(self):
-	w = self.tkwin.width
-	h = self.tkwin.height
-	if self.hbar:
-	    vw = float(self.virtual_width)
-	    min = self.virtual_x / vw
-	    self.hbar.set(min, min + w / vw)
-	if self.vbar:
-	    vh = float(self.virtual_height)
-	    min = self.virtual_y / vh
-	    self.vbar.set(min, min + h / vh)
+        w = self.tkwin.width
+        h = self.tkwin.height
+        if self.hbar:
+            vw = float(self.virtual_width)
+            min = self.virtual_x / vw
+            self.hbar.set(min, min + w / vw)
+        if self.vbar:
+            vh = float(self.virtual_height)
+            min = self.virtual_y / vh
+            self.vbar.set(min, min + h / vh)
 
     def update_rulers(self, force = 0):
         start = self.WinToDoc(0, 0)
-	if self.hruler:
-	    self.hruler.SetRange(start.x, self.scale, force = force)
-	if self.vruler:
-	    self.vruler.SetRange(start.y, self.scale, force = force)
+        if self.hruler:
+            self.hruler.SetRange(start.x, self.scale, force = force)
+        if self.vruler:
+            self.vruler.SetRange(start.y, self.scale, force = force)
 
     def xview(self, *args):
-	apply(self.tk.call, (self._w, 'xview') + args)
+        apply(self.tk.call, (self._w, 'xview') + args)
 
     def yview(self, *args):
-	apply(self.tk.call, (self._w, 'yview') + args)
+        apply(self.tk.call, (self._w, 'yview') + args)
 
     def ScrollXMove(self, fraction):
-	vw = self.virtual_width
-	w = self.tkwin.width
-	amount = float(w) / vw
-	max = 1.0 - amount
-	if fraction > max:
-	    fraction = max
-	if fraction < 0:
-	    fraction = 0
-	self.set_origin(fraction * vw, None)
+        vw = self.virtual_width
+        w = self.tkwin.width
+        amount = float(w) / vw
+        max = 1.0 - amount
+        if fraction > max:
+            fraction = max
+        if fraction < 0:
+            fraction = 0
+        self.set_origin(fraction * vw, None)
 
     def ScrollXPages(self, count):
-	vw = float(self.virtual_width)
-	w = self.tkwin.width
-	amount = w / vw
-	self.ScrollXMove(self.virtual_x / vw + count * amount)
+        vw = float(self.virtual_width)
+        w = self.tkwin.width
+        amount = w / vw
+        self.ScrollXMove(self.virtual_x / vw + count * amount)
 
     def ScrollXUnits(self, count):
-	self.set_origin(self.virtual_x + count * 10, None)
+        self.set_origin(self.virtual_x + count * 10, None)
 
     def ScrollYMove(self, fraction):
-	vh = self.virtual_height
-	h = self.tkwin.height
-	amount = float(h) / vh
-	max = 1.0 - amount
-	if fraction > max:
-	    fraction = max
-	if fraction < 0:
-	    fraction = 0
-	self.set_origin(None, fraction * vh)
+        vh = self.virtual_height
+        h = self.tkwin.height
+        amount = float(h) / vh
+        max = 1.0 - amount
+        if fraction > max:
+            fraction = max
+        if fraction < 0:
+            fraction = 0
+        self.set_origin(None, fraction * vh)
 
     def ScrollYPages(self, count):
-	vh = float(self.virtual_height)
-	h = self.tkwin.height
-	amount = h / vh
-	self.ScrollYMove(self.virtual_y / vh + count * amount)
+        vh = float(self.virtual_height)
+        h = self.tkwin.height
+        amount = h / vh
+        self.ScrollYMove(self.virtual_y / vh + count * amount)
 
     def ScrollYUnits(self, count):
-	self.set_origin(None, self.virtual_y + count * 10)
+        self.set_origin(None, self.virtual_y + count * 10)
 
 
     #
@@ -376,17 +376,17 @@
     #
 
     def init_viewport_ring(self):
-	self.viewport_ring = []
+        self.viewport_ring = []
 
     def save_viewport(self):
-	self.viewport_ring.insert(0,
-				  (self.scale, self.virtual_x, self.virtual_y))
-	length = preferences.viewport_ring_length
-	self.viewport_ring = self.viewport_ring[:length]
+        self.viewport_ring.insert(0,
+                                  (self.scale, self.virtual_x, self.virtual_y))
+        length = preferences.viewport_ring_length
+        self.viewport_ring = self.viewport_ring[:length]
 
     def restore_viewport(self):
-	if self.viewport_ring:
-	    scale, vx, vy = self.viewport_ring[0]
-	    del self.viewport_ring[0]
-	    self.SetScale(scale / self.pixel_per_point, do_center = 0)
-	    self.set_origin(vx, vy, move_contents = 0)
+        if self.viewport_ring:
+            scale, vx, vy = self.viewport_ring[0]
+            del self.viewport_ring[0]
+            self.SetScale(scale / self.pixel_per_point, do_center = 0)
+            self.set_origin(vx, vy, move_contents = 0)



More information about the Skencil-commits mailing list