Re: automatically resizing widgets properly

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

 



>I'm in the middle of porting my gtk app to gtk2, and have been replacing 
>set_usize calls to set_size_request, but I'm left thinking that there has 
>to be a better way to do this...? the docs talk about the inherent 
>duffness of forcing a widget size (i'm using lots of small gtk_entry's and 
>want them between 20 and 50px wide as part of a table). Is there any way 
>to make them automatically use any available space? if i don't set the 
>size of the widget, they naturally come out at full default size, completely 
>distorting the main UI.
>
>for example, I have a table like this:
>
>+-------------+--------+
>| <--entry--> | toggle |
>+-------------+--------+
>| <-------entry------> |
>+----------------------+
>
>the lower entry is full size, and the toggle will naturally shrink, but i 
>then want the top entry to use all the remaining space in that table row.

the trick i generally use, and yes, i do consider it a trick, is to
put elements that you don't want to expand beyond their normal size
into a box of the correct orientation. in the above case:

     <--- entry -------><-hbox[toggle]->
     <---------  entry ---------------->

for vertical layouts, use a vbox. if you'd grown up with TeX as your
typesetting system of choice, this would all make sense :)

even so, i still have to use set_usize/set_size_request quite often,
particularly to size any kind of textual display widget so that its
wide enough to show the largest string i will ever put there without
resizing dynamically, which looks really, really stupid in my
programs. this also applies to compound widgets like spinbuttons. 

--p


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux