From: Hidetoshi NAGAI Date: 2004-04-08T12:03:53+09:00 Subject: Re: Assorted Ruby/Tk Questions/Comments Hi, From: dejaspam@batkins.com (Bill Atkins) Subject: Assorted Ruby/Tk Questions/Comments Date: Thu, 8 Apr 2004 05:24:18 +0900 Message-ID: > The block is being called twice. This can be prevented with the (snip) > This looks like a bug to me. Yes. It's a bug. Thank you for your report. This problem will be fixed by the following patch. --- tk.rb.orig 2004-04-08 11:49:48.000000000 +0900 +++ tk.rb 2004-04-08 11:50:01.000000000 +0900 @@ -4532,7 +4532,7 @@ def TkRoot.new(keys=nil, &b) unless TkCore::INTERP.tk_windows['.'] TkCore::INTERP.tk_windows['.'] = - super(:without_creating=>true, :widgetname=>'.') + super(:without_creating=>true, :widgetname=>'.'){} end root = TkCore::INTERP.tk_windows['.'] if keys # wm commands > 2. Do I have to install Tcl on *NIX boxes to use Ruby/Tk? I know I > can just redistribute the DLL's on Windows, but how does this work on > NIX? Does Ruby/Tk come with everything it needs to run right out of > the box? Yes. You must install Tcl/Tk libraries. Ruby/Tk calls functions of Tcl/Tk library. The Ancient Ruby/Tk used interp process communication between Ruby and Wish. It's too slow!! But current Ruby/Tk loads Tcl/Tk libraries into Ruby. It's an important difference between Ruby/Tk and Perl/Tk. Because of controlling pure Tcl/Tk libraries, Ruby/Tk can use almost all of Tcl/Tk extentions. Of course, before using a extention from Ruby, you must make your Tcl/Tk can use the extention. However, to control Tcl/Tk extentions conveniently, you will define classes and methods for the extentions. The 'tcltk-ext' library creates the base of definition automatically. > 3. How can I use TkTree? It looks like it's in the tcltk-ext > package, but I'm not sure how to use this on Windows. Or Linux for > that matter. Does this also require Tcl to be installed? Do you say about TixTree? If you want to use TixTree class, your Tcl/Tk must be able to use Tix extention. > 4. pack doesn't accept a block, even though Programming Ruby implies > that this is so. I've written the following code to allow pack to > accept a block. It's hackish, so maybe someone more familiar with the > Ruby/Tk internals can improve it: (snip) > Then you can do things like > > label.pack do > expand 1 > fill "both" > end > > which is kind of useful to me. Hmmm... Do you want the feature strongly? Cannot a Hash parameter satisfy you? (e.g label.pack(:expand=>true, :fill=>'both') ) -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)