From: "greg.rb" <ghalsey / yahoo.com> Subject: is GUI a weak point? Date: Wed, 5 Apr 2006 05:23:59 +0900 Message-ID: <1144181980.267658.187480 / j33g2000cwa.googlegroups.com> > Are there any good examples of getting tk widget data to ruby? > > Here is a simple example where I try to build an interface for the user > to pick information which will then be sent to ruby to process. I couldn't understand what you want to ask. Although the following is one of the samples rewriting yours, it may not be able to answer your question. =================================================================== require 'tk' cash_locs=['NONE','NY1','NY2','NJ1','ETC.'] #-------------------------------- # callback function def put_picked_value(s) puts 'USER PICKED: ' + s end #-------------------------------- # GUI part Tk.root.title 'PICK LOCATION' TkButton.new(:text=>'Quit', :command=>proc{exit}).pack(:side=>:bottom, :fill=>:x) f = TkFrame.new.pack(:fill=>:both, :expand=>true) list = TkListbox.new(f) list.yscrollbar(TkScrollbar.new(f).pack(:side=>:right, :fill=>:y)) list.pack(:side=>:left, :fill=>:both, :expand=>true) list.insert(:end, *cash_locs) list.bind('ButtonPress-1', proc{|y| put_picked_value(list.get(list.nearest(y))) }, '%y') Tk.mainloop() =================================================================== -- Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)