[PythonCAD] Adding layers

Art Haas ahaas at airmail.net
Tue Oct 10 22:27:58 CEST 2006

On Fri, Oct 06, 2006 at 05:10:13PM +0200, nescivi wrote:
> Hi,
> I have however one question, regarding layers. PythonCAD seems to support 
> multiple layers, but I don't find how to add layers.
> Right clicking in the layers field on the left of the screen, gives me the 
> following errors in the console:
> Traceback (most recent call last):
>   File "/usr/lib/python2.4/site-packages/PythonCAD/Interface/Gtk/gtkshell.py", 
> line 104, in __treeViewButtonPress
>     _menu = self.__makePopupMenu(widget, _x, _y)
>   File "/usr/lib/python2.4/site-packages/PythonCAD/Interface/Gtk/gtkshell.py", 
> line 111, in __makePopupMenu
>     _path, _col, _cx, _cy = widget.get_path_at_pos(x, y)
> TypeError: unpack non-sequence
> So I have a feeling that something goes wrong in creating the PopupMenu.


The patch below should fix things. I've always clicked on the names in
the list and not the blank area below the final name, so I'd not seen
this before. After the patch is applied, I can click in the blank area
and not get the backtrace.

Thanks for the info, and please let me know if the patch below fixes 
things for you.

Art Haas

Index: PythonCAD/Interface/Gtk/gtkshell.py
--- PythonCAD/Interface/Gtk/gtkshell.py	(revision 2616)
+++ PythonCAD/Interface/Gtk/gtkshell.py	(working copy)
@@ -102,13 +102,17 @@
         _rv = event.window is widget.get_bin_window() and _button == 3
         if _rv:
             _menu = self.__makePopupMenu(widget, _x, _y)
-            _menu.popup(None, None, None, _button, event.time)
+            if _menu is not None:
+                _menu.popup(None, None, None, _button, event.time)
         return _rv
     def __makePopupMenu(self, widget, x, y):
         # print "Entered LayerDisplay._makePopupMenu"
+        _data = widget.get_path_at_pos(x, y)
+        if _data is None:
+            return None
+        _path, _col, _cx, _cy = _data
         _model = widget.get_model()
-        _path, _col, _cx, _cy = widget.get_path_at_pos(x, y)
         _iter = _model.get_iter(_path)
         _layer = _model.get_value(_iter, 1)

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