[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby Cookbook - problem recipe

Len Lawrence

1/21/2007 9:14:00 PM

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