Simple Widget Layout

You learned yesterday about the idea of packing in Ruby/Tk. A widget needs to be packed before it can be seen, and the way a thing is packed determines its location within its parent.

The process is slightly different in Ruby/Gtk. Placement and visibility are achieved separately. Making things visible is very simple, because you can wait until everything in the window is set up, then invoke Gtk::Window#show_all. Placement is mostly a matter of understanding the roles of the Gtk::Bin, Gtk::Box, and Gtk::Table classes, so let's look at them next.

Bin Containers

A Bin is a special kind of container that has room for only one occupant. Descendant classes of Gtk::Bin include Gtk::Window and Gtk::Button. The Gtk::Bin#child method ...

Get Sams Teach Yourself Ruby in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.