Re: reparent a widget




anguila wrote:
Yes, but I can't create a new widget over them.. If I create a vbox in a
place I can't (i don't know how) create a new widget at the same place to
toggle with other widget. I know the visibility option, the idea is switch
with widgets, but if I can't create new widgets at the same spot i can't
hide those widgets.

Try this:

* create a new window
* put a vbox in it
* put a toggle button in vbox
* put a new vbox (vbox1) inside vbox, with some stuff inside
* put another new vbox (vbox2) also inside vbox, with different stuff inside
* set vbox1 visible
* set vbox2 !visible
* in the handler for the togglebutton's toggled signal, toggle the visible
properties of both vbox1 and vbox2.
* do *not* use show_all() on the toplevel window!


I've done that before, and it works just fine.  Specifically, i've used that
to temporarily "replace" the complex contents of a status bar with a progress
meter and "Cancel" button.



How can I create two widgets at the same place (in glade3)?

That's the trick, you don't create them at the *same* *place*.  You put them
both in the same container, and manage which one is visible at runtime.  The
confusing bit is that the view in glade does not represent what you'll see at
runtime.


Or i should
create the second widget in a new window and reparent this new widget with
the other? If it is the last case, isn't works the old widget it hides but
the new doesn't appears.. and I don't know what is wrong.

Reparenting can be tricky, and from what i can tell isn't necessary for what
you're talking about.


Another option, of course, is to create a named container in your glade file,
and just not put anything in it.  Then, create and destroy the contents of
that container at runtime.  The hide/show stuff is nicer if the contents are
really complicated or are supposed to retain their values, but if there are
lots of different children possible, then something like

    $old = $container->remove ($container->child);
    $old->destroy ();
    $new = build_new_thing ();
    $container->add ($new);
    $new->show ();

will be a bit easier.


-- 
muppet <scott at asofyet dot org>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]