Hi, 

# Still my eye's status is not so good. 
# But I'm back momentary, because no one describes proper explanation. :-)

From: ts <decoux / moulon.inra.fr>
Subject: Re: question about 'configure' with tk
Date: Fri, 30 Aug 2002 20:14:44 +0900
Message-ID: <200208301109.g7UB90p22031 / moulon.inra.fr>
> >>>>> "M" == MENON Jean-Francois <jean-francois.menon / meteo.fr> writes:
> M> works under tcl). Under Ruby, it is not possible. I would like to know
> M> if it is a Ruby limitation or if it is possible to add this feature.
decoux>  Try this
decoux> pigeon% ruby -rtk -e 'a = TkButton.new(nil, "text" => "a"); p a.configure({})'

Use 'configinfo' method.
On Ruby/Tk, 'configure' method is the method for setting properties, 
and 'configinfo' method for getting. 
the followings are the way of getting configure informations. 

  (1) widget.property
  (2) widget['property']
  (3) widget.cget('property')
  (4) widget.configinfo('property')
  (5) widget.configinfo

From (1) to (3) return current value of the property. 
(4) returns an array [property, resource-name, resource-class, 
default-value, current-value], and (5) returns an array of all properties. 
For example, 

b = TkButton.new
p b.padx          #==> 12
p b['padx']       #==> 12
p b.cget('padx')  #==> 12
p b.configinfo('padx') 
    #==> ["padx", "padX", "Pad", "3m", 12]
p b.cinfiginfo       
    #==> [["activebackground", "activeBackground", "Foreground", "#ececec", 
         "#ececec"], ["activeforeground", "activeForeground", "Background", 
         "Black", "Black"], ["anchor", "anchor", "Anchor", "center", 
         "center"], ["background", "background", "Background", "#d9d9d9", 
         "#d9d9d9"], ["bd", "borderWidth"], ["bg", "background"], ["bitmap", 
         "bitmap", "Bitmap", [], []], ["borderwidth", "borderWidth", 
         "BorderWidth", 2, 2], ["command", "command", "Command", [], []], 
             ... (snip)

A known problem of configinfo method is that 
it cannot distinguish a string and a value. 
Tcl/Tk expresses a string with spaces and an array of strings 
as a same string. It cannot be distinguished by Ruby. 
Therefore, on the result of configinfo, 
a null string is converted to a null array. 

By the way, the followings are the way for setting properties. 

  (1) widget.property(value)
  (2) widget['property'] = value
  (3) widget.configure('property', value)
  (4) widget.configure('property'=>value, 'property'=>value, ...)

Each method calls Tcl interpreter once. 
So, if you want to set some properties for one widget, 
(4) is faster than others. 

# If there is a book such as O'REILLY's "Perl/Tk Pocket Reference", 
# how many people will want it ? 
-- 
                                  Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)