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')) ...

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.