2
votes

I'm having the following issue with GTK2:

I created two buttons with labels inside an horizontal box. (I intend to pile several hboxes) However there's an issue: When I make the box_pack functions they go like this:

gtk_box_pack_start(GTK_BOX(hbox1), button1, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), button2, FALSE, FALSE, 0);

Despite putting them both false, the buttons still expand vertically, making the "hbox1" ocupy all the space that is left on the parent box. I want the buttons to expand only to the minimum height required for the label to be displayed properly (like it usually happens on vertical boxes).

I heard that in GTK3 you could use the gtk_widget_set_vexpand and gtk_widget_set_hexpand functions. However, these do not seem to exist in GTK2, as they are on recognized....

Any solution for this? (Not just this case with horizontal boxes, but with the respective case in vertical boxes)

2
Did you ever find a solution to this?user7537486
That was a long time ago... I tried to look for the variable (hbox1) and it was not on my code anymore... Maybe you can try to put another horizontal box in the same container as that one, and make that box fully expand by default?Kelthar
I ended up using alignments, thank you :)user7537486

2 Answers

0
votes

This is an older question, but an important one. In short, set the valign property of the problematic widget to Gtk.Align.CENTER, just as @user7537486's comment on the original question said. Hope that solves it!

-1
votes

If I understood correctly, you need another hbox to behave like a expander, more or less like this:

|button|spander|

so, when you expand:

|button|            spander|

button still at its minimum size....

is that what you asking for?