From: Marcin Simonides <marcin / studio4plus.com>
Subject: Tk: setting window class
Date: Wed, 1 Aug 2007 06:09:47 +0900
Message-ID: <5e0a5efdd2d9eb4334c51c94b16debdb / ruby-forum.com>
> In documentation that I found:
> http://www.jbrowse.com/text/rubytk_en.html#label:18
> there is a definition:
> 
> TkToplevel.new(parent=nil, keys=nil)
> TkToplevel.new(parent=nil, screen=nil, classname=nil, keys=nil)
> 
> but calling TkToplevel.new(@parent, nil, 'MyClass') doesn't set the
> window's class.

I'm very sorry. That is a bug. The 'classname' argument doesn't work.
Instead of that argument, please use one of the followings: 

(1) t = TkToplevel.new(parent, :class=>'MyClass')
      or
    t = TkToplevel.new(parent, :classname=>'MyClass')

(2) class MyClass < TkToplevel; end; t = MyClass.new(@parent)

If you want to use the widget name on the resource DB, 
please use 'widgetname' option. 
For example, 

  TkOptionDB.add('*mytop*background', 'yellow')
  t = TkToplevel.new(parent, :widgetname=>'mytop')

'classname' option and 'widgetname' option are available only on the 
Hash argument of TkToplevel.new or TkFrame.new method.
Those cannot be changed after construction. 
It means that those option cannot be set in the block argument of 
'new' method.

Please see also an example of TkOptionDB (ext/tk/sample/tkoptdb.rb 
on the Ruby source tree). 
That includes how to give and treat procedures on the resource DB.
-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)