[Glade-users] how to allow widgets to be added to custom widgets

Tristan Van Berkom tristanvb at openismus.com
Mon Feb 28 09:14:45 EST 2011


On Mon, 2011-02-28 at 18:05 -0800, Tom Vaughan wrote:
> I've been very successful in creating custom widgets. I'd like to add
> the ability to allow users to add more widgets to my custom widgets.
> For example, I'd like my widget to have a "placeholder" that will
> allow users to add any other widget, VBox, Button, etc. to my custom
> widget.
> 
> This:
> 
>     http://www.pygtk.org/articles/custom-widgets-glade/Custom_PyGTK_Widgets_in_Glade3-part-2.html
> 
> is what I've attempted to follow. However, the methods described here
> appear to be obsolete. "import glade" no longer exists. "import
> gtk.glade" does not have get_adaptor_for_type.
> gobject.new('GladePlaceholder') fails.
> 
> What's the right way to do this today? This is on an up-to-date Ubuntu
> Maverick box.

Hi, 
   I dont know that it's possible to do with python, I doubt it.

However libgladeui-2 (the new core for Glade 3.10/GTK+ 3.x) will be
coming with gir data, meaning it should not be too hard to generate
python bindings to the Glade core library, which should make this
kind of interaction possible.

Note that until now, python widgets have been implemented in a one-way
fashion, Glade invokes the python interpreter and introspects properties
and the like from python widgets... those python widgets until now dont
have any way to interact with the Glade core.

I suppose it would still be possible to implement the Glue for your
python widgets in a C module, might be tricky though (I suppose the
C module would have to act like libgladepython.so and invoke the
interpreter manually as well)... sounds quite tricky but possible.

Cheers,
        -Tristan




More information about the Glade-users mailing list