Chapter 6. Widget Overview

The general steps to creating a widget in Ruby-GNOME2 are:

  1. Gtk::Widget.new to create a new widget, where Widget is the type (class) of widget you wish to create.
  2. Connect all the signals and events we wish to use to the appropriate handlers.
  3. Set the attributes of the widget.
  4. Pack the widget into a container using the appropriate methods such as Gtk::Box#pack_start or Gtk::Table#attach
  5. Gtk::Widget#show to show the widget.

Gtk::Widget#show lets GTK know that we are done setting the attributes of the widget, and it is ready to be displayed. You may also use Gtk::Widget#hide to make it disappear again. The order in which you show the widgets is not important, but I suggest showing the main window last so the whole window pops up at once rather than seeing the indvidual widgets come up on the screen as they're formed. The children of a widget (a window is a widget too) will not be displayed until the window itself is hsow using the Gtk::Widget#show or Gtk::Widget#show_all methods.


Prev Next