Forum: Ruby Ruby Cookbook - problem recipe

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Len L. (Guest)
on 2007-01-21 23:16
(Received via mailing list)
Skipping through the Ruby Cookbook (Carlson & Richardson) I tried out
rubyTk stopwatch program, which worked fine, then tried the GTK version.
I typed it in more or less verbatim but could not run it because the
menuspec which is given as an array (see below) could not be converted
a string by the Gtk::ItemFactory create_items method.

Extract from the initialize method of the Stopwatch class:

    menu_factory =
                                         '<main>', nil )
    menuspec = [
                   [ '_Program' ],
                   [ '/Program/_Start', '<Item>', nil, nil, lambda {
start } ],
                   [ '/Program/S_top', '<Item>', nil, nil, lambda { stop
} ],
                   [ '/Program/_Exit', '<Item>', nil, nil,
                     lambda { Gtk.main_quit } ]
                   [ '_Reset' ],
                   [ '/Reset/_Reset Stopwatch', '<Item>', nil, nil,
                     lambda { reset } ]

    menu_factory.create_items( menuspec )

The error message specifies the last line here as the problem.  Have I
missed something obvious?  The OReilly website lists errata for the book
but nothing for page 806 where this code snippet comes from.  Should I
looking for version mismatches in GTK2 perhaps?

This topic is locked and can not be replied to.