[gtkada] adding and removing widgets in a container
Preben Randhol
randhol at pvv.org
Thu Nov 29 12:17:09 CET 2001
Torsten Leistikow <leistikow at stn-atlas.de> wrote on 29/11/2001 (10:41) :
>
> Now I get the error message
>
> gtk-CRITICAL **: file gtkcontainer.c: line 714 (gtk_container_add):
> assertion `GTK_IS_WIDGET (widget)´ failed
>
> and Label is not added to Frame.
This is because the reference counter for Label becomes 0 and it is
destroyed. After making the label add this:
Gtk.Object.Ref (Label);
this will ensure that it isn't destroyed. You can use Gtk.Object.Unref
(Label); to reduce the ref counting later when you want it destroyed.
I did this too with frames that had a content in them, but I got a
problem. If I pressed a button in the frame and this resulted in the
frame being removed, I noticed that when I later Added the frame the
button was still highlighted. It doesn't seem to be a solution to this
as I didn't get any answers even on the Gtk+ mailinglist on how to solve
this problem. So I went back to simply destroying the widget and creating
a new every time I need it.
But for your use it should work fine.
Preben
--
() Join the worldwide campaign to protect fundamental human rights.
'||}
{||' http://www.amnesty.org/
More information about the gtkada
mailing list