From: Hidetoshi NAGAI Date: 2006-09-17T00:54:10+09:00 Subject: Re: Looking for reference for Ruby/Tk and Ruby/MySQL From: Patrick Lynch Subject: Looking for reference for Ruby/Tk and Ruby/MySQL Date: Fri, 15 Sep 2006 09:08:06 +0900 Message-ID: <0614bffdd5890f8da4ed004250eddc0a@ruby-forum.com> > I'm going thru the "Pickaxe" book...and it contains a chapter on Tk - On "Pickaxe" book, "command" option of TkScrollbar and yscrollcommand option of the scrolled widget are used for scrolling. Of course, that has no problem except bothering you. However, Ruby/Tk supports "xscrolbar" method and "yscrollbar" method for scrollable widgets. Those methods make such relationship between a widget and a scrollbar. ------------------------------------------------- list_w = TkListbox.new(frame, 'selectmode' => 'single') scroll_bar = TkScrollbar.new(frame, 'command' => proc { |*args| list_w.yview *args }) scroll_bar.pack('side' => 'left', 'fill' => 'y') list_w.yscrollcommand(proc { |first,last| scroll_bar.set(first,last) }) --------------------------------------------------------------------- | v ---------------------------------------------- list_w = TkListbox.new(frame, 'selectmode'=>'single') list_w.yscrollbar(TkScrollbar.new(frame).pack('side'=>'left', 'fill'=>'y')) --------------------------------------------------------------------- If you want to scroll simultaneously some listboxes by one scrollbar, TkScrollbar#assign method may help you. Please see the example "ext/tk/sample/tkmultilistframe.rb" on your Ruby source tree. > I'll be doing a lot of mathematical curve drawing [ie, plotting > some statistical functions]. Ruby/Tk can support many (almost all) of graph libraries which can work with Tcl/Tk. Even if there is no Ruby/Tk's wrapper for such graph library, Ruby/Tk can call Tcl/Tk's commands to control the library with Tk.tk_call. If 2D graphs are enough for your purpose, BLT extension may be suitable. -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)