From: Hidetoshi NAGAI Date: 2005-08-02T18:20:44+09:00 Subject: Re: Tk - Ruby/Tk core library design questions From: David Tran Subject: Tk - Ruby/Tk core library design questions Date: Tue, 2 Aug 2005 06:53:52 +0900 Message-ID: <91b08b8a050801145327f672a4@mail.gmail.com> > (1) Layout Manager: > there are: > widget.pack ; TkPack.pack ; Tk.pack > widget.grid ; TkGrid.grid ; Tk.grid > widget.place ; TkPlace.place > methods, why there is no Tk.place method ? 'tk.rb' on CVS already has the method. # committed at 2005/03/02 > (2) Since we try to wrap Tcl/Tk on OO, why some Tcl commands are not > treat like options ? (snip) > Now, for example, root.title and root.iconbitmap ... etc are command > but not options on Tcl/Tk language. > But, I feel this will be nice if we "wrap" them like options, so we > can write something like: > TkRoot.new(:title=>'Hello') or > TkButton.new(:text=>'set title').command { Tk.root.title = "some title" } > For me, it seems title is just like an option for TkRoot. > (But in current version, it is not, so I cannot use :title=>... or > root.title = ... syntax ) Hmmm... On CVS, "TkRoot.new(:title=>'Hello')" works, but "Tk.root.title = 'some title'" doesn't. If you want 'title=' method only, that is very easy. ----------------------------------------- module Tk::Wm alias title= title end ----------------------------------------- However, it is not so simple to supprt :title=>"..." on configure method. To do it, we must check all keys of the configure argument, and select to call 'wm' command or 'configure' command. If you request it strongly, I'll try to implement. > (3) (snip) > Why should I reference TkCanvas ( at least class ) first ? Probably you can find the reason on 'tk/autoload.rb' Definitions for canvas widgets and canvas items are witten on 'tk/canvas.rb'. If you don't need a canvas widget on your application, you don't need to require 'tk/canvas.rb'. So, Ruby/Tk uses autoload mechanism to load the necessary library. Current Ruby/Tk doesn't define autoload for canvas items. I thought that is enough because canvas items needs a parent canvas widget. Don't you think so? -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)