[PythonCAD] [PATCH] Followup patch for gtkimage.py

Art Haas ahaas at airmail.net
Wed Oct 25 01:38:04 CEST 2006


On Tue, Oct 24, 2006 at 02:56:41PM -0500, Art Haas wrote:
> Hi.
> 
> Found another dumb copy-and-paste error today. Patch below for people
> not using Subversion; for those using it just 'svn update' to get
> the fix.
> 
> Index: PythonCAD/Generic/image.py
> ===================================================================
> --- PythonCAD/Generic/image.py	(revision 2628)
> +++ PythonCAD/Generic/image.py	(working copy)
> @@ -1829,7 +1829,7 @@
>              raise ValueError, "Invalid argument count: %d" % _alen
>          _units = args[0]
>          # fixme - maybe add error checking  ...
> -        self.saveUndoData('scale_changed', _units)
> +        self.saveUndoData('units_changed', _units)
>  
>      def __addedChild(self, image, *args):
>          _alen = len(args)

Hi.

After applying the patch above, the following patch is worth applying as
well. Switching units, then undoing the switch, will fail to generate
a redraw operation, a problem I just found after playing with the code
above. The change to gtkpycad.py below add the bits needed to make
the redraw operation occur as expected.

Index: PythonCAD/Interface/Gtk/gtkimage.py
===================================================================
--- PythonCAD/Interface/Gtk/gtkimage.py	(revision 2629)
+++ PythonCAD/Interface/Gtk/gtkimage.py	(revision 2630)
@@ -243,6 +243,7 @@
         _image.connect('removed_child', self.__imageRemovedChild)
         _image.connect('group_action_started', self.__groupActionStarted)
         _image.connect('group_action_ended', self.__groupActionEnded)
+        _image.connect('units_changed', self.__imageUnitsChanged)
 
         _layers = [_image.getTopLayer()]
         while len(_layers):
@@ -1141,7 +1142,11 @@
             self.refresh()
         else:
             self.__refresh = True
-            
+
+    def __imageUnitsChanged(self, obj, *args):
+        # print "__imageUnitsChanged()"
+        self.redraw()
+        
     def __objChangePending(self, obj, *args):
         # print "__objChangePending()" + `obj`
         _alen = len(args)
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822


More information about the PythonCAD mailing list