morgon has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I am trying to hack a script using Gtk2 but unfortunately I have very little understanding about Gtk (so it's mainly trial and error that I do), so sorry for maybe asking something trivial, but I did not find any clue in the man-pages.

What I want to do is to dynamically add and remove Gtk2::Buttons to a GTK2::VFrame.

My first question:

When I add a button at runtime via $vbox->add($button) the button does not become visible until I also do a $toplevel->show_all.

Is this the way to do it or is there a better way?

Second question:

When I add buttons and to a vframe and later remove one via $vbox->remove($button), the button disapears but the vframe keeps the previous height and the remaining buttons are resized to fill the available space.

What I want are buttons of a pre-determined size that never resize.

How can I do that?

Many thanks!

Replies are listed 'Best First'.
Re: buttons in Gtk2
by Anonymous Monk on Jun 15, 2016 at 22:56 UTC

    ..add button ... show_all... Is this the way to do it or is there a better way?

    That is the only way :)

    buttons that don't resize

    Button options/attributes, like width/height/resizable, reference the docs

      Unfortunately I could not find any way to specify width/height of buttons in the docs.

      This is why I ask...