# GUI Designer for GTK? / Resizing widgets in table

**URL:** <https://www.ruby-forum.com/t/gui-designer-for-gtk-resizing-widgets-in-table/142501>\
**Category:** Ruby-Gnome 2\
**Created:** [July 8, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/gui-designer-for-gtk-resizing-widgets-in-table/142501 "2008-07-08T17:00:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![avery663](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3d9bf3/32.png) [@avery663](https://www.ruby-forum.com/u/avery663)\
**Post date:** [July 8, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/gui-designer-for-gtk-resizing-widgets-in-table/142501/1 "2008-07-08T17:00:00Z")

</div>

Hello-  
First, I would like to ask if there is a GUI Designer for GTK that works  
with Ruby. I DO NOT MEAN GLADE. I hate Glade. I do NOT want to use some  
annoying xml files, even if they are ‘easier’. I would need a NORMAL GUI  
Designer, as in something that gives me the RAW RUBY code for the GUI as  
output.

Question 2:  
So, I have a table widget.(Because of course, GTK has this  
useless/insane/awful ‘container’ format, which means that it hates  
something called SPACE, and forces you to put everything into  
tables/boxes)

Inside a part of the table(table.attach) I have a toolbar. On the  
toolbar, I have a button.

Of course, GTK HATES SPACE. So, of course, the toolbar takes up as much  
space as possible until it bumps into other widgets.

Then, the button takes up as much space as possible on the toolbar.

So then, I use this:  
button.set\_size\_request(x, y)

Now. The x value ACTUALLY RESIZES THE WIDGET’s WIDTH! Hurray!

However, the y value does not resize the button’s height! It STILL  
stretches ALL the way down the toolbar until the toolbar and the button  
smash into other widgets.

How would I resize the button height? What about the toolbar’s?

Basically, I want to go against everything GTK tries to do and actually  
CREATE SOME SPACE inbetween the toolbar/button cell(By making this a  
NORMAL SIZED toolbar, instead of half the freaking window).

How would I do this? How would I resize any part of the table or  
widget??

---

<div class="post-metadata">

**Author:** ![avery663](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3d9bf3/32.png) [@avery663](https://www.ruby-forum.com/u/avery663)\
**Post date:** [July 8, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/gui-designer-for-gtk-resizing-widgets-in-table/142501/2 "2008-07-08T20:15:30Z")

</div>

Avery W. wrote:

> Hello-  
> First, I would like to ask if there is a GUI Designer for GTK that works  
> with Ruby. I DO NOT MEAN GLADE. I hate Glade. I do NOT want to use some  
> annoying xml files, even if they are ‘easier’. I would need a NORMAL GUI  
> Designer, as in something that gives me the RAW RUBY code for the GUI as  
> output.

Glade appears as a “normal gui designer” for me. I don’t undestand why  
you want raw ruby code from a gui designer. This would most probably  
only work as a code generator, which can write the code once, but  
read/modify never.

I’m not a fan of XML files, too, but glade just works for me.

> Of course, GTK HATES SPACE. So, of course, the toolbar takes up as much  
> space as possible until it bumps into other widgets.

Well that’s how GTK works.

> How would I do this? How would I resize any part of the table or  
> widget??

Can you post an example? Your uppercase text doesn’t improve  
readability…

---

<div class="post-metadata">

**Author:** ![avery663](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3d9bf3/32.png) [@avery663](https://www.ruby-forum.com/u/avery663)\
**Post date:** [July 8, 2008, 10:46pm UTC](https://www.ruby-forum.com/t/gui-designer-for-gtk-resizing-widgets-in-table/142501/3 "2008-07-08T22:46:42Z")

</div>

Sorry. I was frustrated when I wrote that…

OK, here we go.

Mytable = Gtk::Table.new(3, 1, false)  
window.add(Mytable)

toolbar1 = Gtk::Toolbar.new  
bnt1 = Gtk::Button.new(“hello”)  
toolbar1.append(bnt1)  
bnt1.set\_size\_request(40,10)  
toolbar1.set\_size\_request(100,30)  
Mytable.attach\_defaults(toolbar1, 0, 1, 0, 1)

toolbar2 = Gtk::Toolbar.new  
bnt2 = Gtk::Button.new(“Hello2”)  
toolbar2.appen(bnt2)  
table.attach\_defaults(toolbar2, 0, 1, 2, 3)

When I run this, I get both of the buttons/toolbars/table cells  
stretching out to meet each other in the middle. I would just like to  
understand how to fix this.  
toolbar1.set\_size\_request() seems to do nothing.  
bnt1.set\_size request can change the width of the button, but not the  
height.

Thanks for your time,  
Avery

---

<div class="post-metadata">

**Author:** ![avery663](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3d9bf3/32.png) [@avery663](https://www.ruby-forum.com/u/avery663)\
**Post date:** [July 9, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/gui-designer-for-gtk-resizing-widgets-in-table/142501/4 "2008-07-09T16:35:16Z")

</div>

Hey Avery,

A few comments:

1. The GTK layout system is one of the best I’ve seen around. You only  
need to get the hang of it.

2. You don’t wanna use set\_size\_request. This defeats the whole porpouse  
of the layout system. Use it only on very specific things.

3. You don’t wanna use a Gtk::Table for something like this. Use a  
Gtk::VBox.

The secret is in the “expand” and “fill” properties of the VBox.  
“Expand” means that the widget will try to occupy all space in the  
window, pushing all other widgets aside. “Fill” means the widget will  
occupy all space reserved for it.

So, first add a vbox to that window. Then you add a toolbar to the vbox.  
To add the toolbar, use vbox.pack\_start(toolbar, false). The ‘false’  
means that expand is false, that is, the toolbar will occupy smallest  
space possible. If you were to put expand as true, the toolbar would  
occupy the whole screen.

1. To add a button to a toolbar, don’t use a Gtk::Button. Use  
Gtk::Toolbar#append.

2. Criticizing the tool that the members of the group are developing and  
working with is rarely good politics. Next time try to wait until  
frustration passes, then post. You might get more prompt answers.

3. Try taking a look at the samples directory that is packed with GTK.  
Studying those simple examples can teach you a lot about Ruby-Gnome.

Best regards and good luck.

André

On Tue, 8 Jul 2008 22:46:42 +0200  
Avery W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> toolbar1.set\_size\_request(100,30)  
> toolbar1.set\_size\_request() seems to do nothing.  
> Studies have shown that voting for your favorite open source project,  
> along with a healthy diet, reduces your potential for chronic lameness  
> and boredom. Vote Now at [http://www.sourceforge.net/community/cca08](http://www.sourceforge.net/community/cca08)
> 
> * * *
> 
> ruby-gnome2-devel-en mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

–  
Lamentação sem gratidão é murmuração. (Howard Hendricks)

---

<div class="post-metadata">

**Author:** ![avery663](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3d9bf3/32.png) [@avery663](https://www.ruby-forum.com/u/avery663)\
**Post date:** [October 1, 2008, 6:45pm UTC](https://www.ruby-forum.com/t/gui-designer-for-gtk-resizing-widgets-in-table/142501/5 "2008-10-01T18:45:59Z")

</div>

AndrÃ© Wagner wrote:

> 1. Try taking a look at the samples directory that is packed with GTK.  
> Studying those simple examples can teach you a lot about Ruby-Gnome.

Hey there, are you referring to the GTK2 samples, located at  
‘[http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk](http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk)’? If you are - great  
minds think alike. If not, that tutorial is helpful, too.
