[pygtk] custom container class; installing child properties

David E. Konerding dekonerding at lbl.gov
Fri Jan 20 02:19:36 WST 2006


Hi folks,

I am trying to build a custom container.  This container is like a
layout, but it doesn't manage its own bin_window (since I can't for
the life of my find a way to make a gtk.Widget have a transparent
background so that stuff drawn to the parent of the widget gets
occluded by the container's gtk.gdk.Window).

I am stuck at tyrying to install the child properties.  Here's a
fragment of my constructor:

class TestContainer(gtk.Container):

    __gsignals__ = {
        'expose-event' : 'override',
        'size-allocate': 'override',
        'size-request': 'override',
        'add': 'override',
        'remove': 'override',
        }

    def __init__(self, *args):
        gtk.Container.__init__(self)
        self.set_flags(self.flags() | gtk.NO_WINDOW)
     
        gtk.container_class_install_child_property( \
            TestContainer,
            1,
            ("x", gobject.TYPE_INT, "X position", "X position of child
widget"))
       
gtk.container_class_install_child_property complains:
first, if you don't end the 3rd argument tuple with an int, it
complains.  But there are no extra parameters
documented for this function- it's supposed to be a 3-argument funciton
with a 4-tuple as the 3rd
argument.

Does anybody have an idea what those extra args are supposed to be?  It
seems like the
pygtk wrapper function calls gobject::py_param_spec_from_object wiht the
arguments, and passes any extra
args to gobject::create_property as the 'args' parameter.  From there I
can infer that the 3 values should be the minimum, maximum and default
values of the property, but if I add those to the args:

 gtk.container_class_install_child_property( \
            TestContainer,
            1,
            ("x", gobject.TYPE_INT, "X position", "X position of child
widget"),
            0,0,0)
then the check for number of arguments for the wrapper function
_wrap_gtk_container_class_install_child fails,
because it expects exactly 3 args, not 6.


It seems like the wrap_gtk_container_class_install_child_property
function check is buggy, because it should allow a variable number of
arguments after the third.

Dave


More information about the pygtk mailing list