From: Gregory Millam Date: 2004-04-07T22:58:19+09:00 Subject: Re: Idea: Simplified GTK Of the two: > require 'ez-gtk' > include EZ_GTK > > def App.logic > @main.title = "My window" > @hb = HBox.new do > @vb1 = VBox.new do > @btn1 = Button.new("Do it") { puts "pressed btn1" } > @btn2 = Button.new("This too") { puts "pressed btn2" } > end > @vb2 = VBox.new do > @btn3 = Button.new("Third button") { puts "pressed btn3" } > end > end > end > > App.run Or - > def app_logic > main { > hbox { > vbox { > button("Do it") { puts "pressed btn1" } > button("This too") { puts "pressed btn2" } > } > vbox { > button("Third button") { puts "pressed btn3" } > } > } > } > end The second one looks much more to-the-point. And in fact, wouldn't be that hard to do. The first (original poster) attempts to go halfway between Gtk and the rapidity of the second. The following code implements the second bit. Just hbox, vbox, and buttons, though ;). I do like this idea, for fairly rapid prototyping. # Begin code require 'gtk2' class EzGtkWindow def main @window = Gtk::Window.new @addfunc = lambda { |item| @window.add(item) } yield @window @window.show_all end def hbox hbox = Gtk::HBox.new(false) @addfunc.call( hbox ) storefunc = @addfunc @addfunc = lambda { |item| hbox.pack_start( item ) } yield hbox @addfunc = storefunc end def vbox vbox = Gtk::VBox.new(false) @addfunc.call( vbox ) storefunc = @addfunc @addfunc = lambda { |item| vbox.pack_start( item ) } yield vbox @addfunc = storefunc end def button(string,&block) button = Gtk::Button.new(string) button.signal_connect("clicked",block) @addfunc.call( button ) end end class MyWindow < EzGtkWindow def initialize main { hbox { vbox { button("Do it") { puts "pressed btn1" } button("This too") { puts "pressed btn2" } } vbox { button("Quit") { puts Gtk.main_quit } } } } end end Gtk.init c = MyWindow.new Gtk.main # End code - Greg Millam