On Nov 22, 2006, at 5:50 PM, Len Lawrence wrote:

> I have just started using ruby after 15 years with Tcl/Tk/C/C++
> and have encountered a problem trying to create a second
> toplevel window.  This was trivial in tcl.  In ruby the second
> window has the same object reference as the first, so everything
> gets packed together.
>
> Is this a bug or a feature of the ruby Tk implementation?
>
> This is the extract:
>
> $window['root'] = TkRoot.new { title "ttlog : version 2.2" }
> puts $window['root']
>
> $window['today'] = TkRoot.new { title "Todays news" }
> puts $window['news']

AFAIK, you can't have two root windows in Ruby/Tk. However, you can  
put up two windows by creating a toplevel window as the second window.

<code>
#! /usr/bin/env ruby -w

require "tk"

root = TkRoot.new { title "ttlog : version 2.2" }
p root
second = TkToplevel.new(root) { title "Todays news" }
p second

Tk.mainloop
</code>

<results>
#<TkRoot:0x502adc @path=".">
#<TkToplevel:0x5025dc @classname="Toplevel", @screen=nil,  
@path=".w00000", @db_class=TkToplevel>
</results>

Hope this helps.

Regards, Morton