Forum: Ruby Ruby Cookbook - problem recipe

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community 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
the
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
to
a string by the Gtk::ItemFactory create_items method.

Extract from the initialize method of the Stopwatch class:

    menu_factory = Gtk::ItemFactory.new(
Gtk::ItemFactory::TYPE_MENU_BAR,
                                         '<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
be
looking for version mismatches in GTK2 perhaps?

Len
This topic is locked and can not be replied to.