solved: GtkVBox: How to delete widgets?

From: Date: Tue, 26 Feb 2002 09:50:53 +0000
Subject: solved: GtkVBox: How to delete widgets?
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-1339@lists.php.net to get a copy of this message
Sebastian G. wrote: > > I have a GtkVBox with a number of labels in it. I need to change the > > number of the labels in that box depending on what data I am collecting. > > -> How can I delete all the labels in that GtkVBox like I do reset a > > GtkCTree with > > | $ctree -> clear(); Christoph Muehlmann wrote: > I think there is no function like that, but you can make your own: > > create an new Class like myGtkVBox which extends GtkVBox with a function > clear(). In this function you can use the Array containing the childs of > the GtkVBox ($gtkvbox->children) and the remove()-function of the > parent-parent-class of GtkVBox (GtkContainer is parent of GtkBox is p. of > GtkVBox) Alan Knowles wrote: > have a look at the container::children() > | $array = $vbox->children() > | for ($i=0;$i<count($array);$i++) { > | $vbox->remove($array[$i]); > | $array[$i]->destroy(); > | } > then you can just add back to the vbox Hi folks, well, I finally understood how this works. You people are quiet in this material, huh? :) Here is what I did: | $label_status = &new GtkLabel(); | $hbox_status = &new GtkHBox(); | $vbox_status_collector = &new GtkVBox(); | | function init_status() { | global $vbox_status_collector, | $hbox_status, $label_status; | | foreach ($vbox_status_collector -> children() as $box) { | $vbox_status_collector -> remove($box); | // We don't actually want to delete that widget, cause we still might need it | // $box -> destroy(); | } | | $label_status -> set_text("Status-text 1"); | $hbox_status -> pack_start($anlagen_label); | $box_anlagen -> pack_start($hbox_status); | $box_anlagen -> show(); | } Well, this still isn't working, it says | Gtk-CRITICAL **: file gtkbox.c: line 332 (gtk_box_pack_start): assertion `child->parent == NULL' failed , but I think it's because I use the same $label_status and $hbox_status over and over again. If you'd like, you might tell me how to copy widgets, cause I can't find that information in the manuals of phpGTK and GTK+. -- MfG, Sebastian G. <: mailseppel@gmx.de : germany-HH :>

« previous php.gtk.general (#1339) next »