[pygtk] How to subclass gobject.GObject
Laszlo Nagy
gandalf at shopzeus.com
Thu Sep 4 01:34:41 WST 2008
Hi All,
I'm working on a special "non visual" component that allows moving
widgets between container with drag-and-drop. It is almost ready. I only
need to add events like "widget_moving" and "widget_moved" etc.
Currently, my non-visual component is based on object. I think I need to
subclass it from gobject.Object before I can setup __gsignals__ and call
self.emit("widget_moved"....). I read a tutorial about this:
http://www.pygtk.org/articles/cairo-pygtk-widgets/cairo-pygtk-widgets2.htm
I tried to do the same but I'm getting this nasty error:
Traceback (most recent call last):
File "demo01.py", line 22, in <module>
import mess.gtk.pivotview
File "/home/gandalf/Python/Lib/mess/gtk/pivotview.py", line 12, in
<module>
from mess.gtk.widgetsticker import WidgetSticker
File "/home/gandalf/Python/Lib/mess/gtk/widgetsticker.py", line 4, in
<module>
class WidgetSticker(gtk.Object):
File "/var/lib/python-support/python2.5/gtk-2.0/gobject/__init__.py",
line 41, in __init__
cls._type_register(cls.__dict__)
File "/var/lib/python-support/python2.5/gtk-2.0/gobject/__init__.py",
line 95, in _type_register
type_register(cls, namespace.get('__gtype_name__'))
TypeError: Error when calling the metaclass bases
could not get typecode from object
Finally the question: how can I add gtk compatible signal support to my
class? What should be the parent class? If you could point me to a good
URL it would be fine.
Thank you
Laszlo
More information about the pygtk
mailing list