From: Lionel MAIAUX <lionel.maiaux / st.com>
Subject: Incorrect return of the TkFont configure instance method when no value
Date: Thu, 31 Aug 2006 17:09:14 +0900
Message-ID: <44F6990D.1010002 / st.com>
> I would like to get the size of a TkFont.
> It could be done with something like ...
> 
> require 'tk'
> font = TkFont.new...
> ...
> size = font.configure :size
> 
> ... as it is descibed in the Tk documentation (configure with an 
> attribute without a value get the value of this attribute).

On Ruby/Tk, you can use 'configure' methods only to set attibutes.
When you want the attibute value of the font, 
please use one of the followings.

  font.configinfo(:size) or font.configinfo('size')
  font[:size] or font['size']
  font.size

And when you want to set a value, 

  font.configure(:size, value) or font.configure('size', value) # pair
  font.configure(:size=>value) or font.configure('size'=>value) # Hash
  font[:size] = value or font['size'] = value
  font.size(value) or font.size = value

So, for example, you can control the buttons' font size 
by something like as the following. ;-)

  b1 = TkButton.new(:text=>'FOO').pack
  f = b1.font
  b2 = TkButton.new(:text=>'BAR', :font=>f).pack
  lbl = TkButton.new(:text=>'Label', :font=>f).pack
  p f.size         # e.g. fontsize == 9
  f.size -= 3      # fontsize == 6 on the label and both buttons
  f.size *= 2      # fontsize == 12 on the label and both buttons

-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)