O'Reilly logo

Sams Teach Yourself Ruby in 21 Days by Mark Slagell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

More Widget Types

As mentioned earlier, this chapter does not attempt to document every feature of Gtk or Ruby/Gtk, but there are several other fundamental Gtk classes that you are likely to find useful, and we would be remiss not to mention them. They will be introduced in the following four sample scripts.

Sample 1: CheckButton and RadioButton

Listing 18.8 lets the user configure a burger for lunch.

Listing 18.8. The Burger Stand
 01: #!/usr/bin/env ruby 02: 03: require 'gtk'; include Gtk 04: 05: class BurgerSelector < Window 06: def initialize 07: super() 08: add(vb = VBox.new) 09: vb.add(hb = HBox.new) 10: 11: hb.add(meats = VBox.new) 12: meats.add(rb_beef = RadioButton.new(nil,'Beef')) 13: meats.add(rb_turkey = RadioButton.new(rb_beef,'Turkey')) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required