From: wbh Date: 2002-01-25T09:40:48+09:00 Subject: Re: Ruby/Gtk : question on menus On Fri, 25 Jan 2002, Markus Jais wrote: > first is the output of "print_and_quit" function. > how can I define a function within the "items" array????? > ("print_and_quit" and &print_and_quit and { print_and_quit } do not work ) It's invoking the call method of the object passed in. > why does the app crash?? The order of the parameters seems to be different from C Accellerators need some playing with still... require "gtk" class SampleWindow < Gtk::Window def pn(msg) return Proc.new {puts msg,"\n"} end def initialize super items=[ ["/_File", nil, "", nil, nil], ["/File/_New", "N", "", pn("New"), nil], ["/File/_Quit", "Q", "", pn("Quit"),nil], ["/_Edit", nil, "", nil, nil], ["/_Help", nil, "", nil, nil], ["/Help/_About","A", "", pn("H/A"), nil] ] accel=Gtk::AccelGroup.new fact=Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_MENU_BAR,"
",accel) fact.create_items(items) menu_bar=fact.get_widget("
") vbox=Gtk::VBox.new vbox.add(menu_bar) add(vbox) show_all end end SampleWindow.new Gtk::main