Only one root window in RubyTk

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’]

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

$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.

#! /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

# #

Hope this helps.

Regards, Morton

On Thu, 23 Nov 2006 09:41:27 +0900, Morton G. wrote:

second = TkToplevel.new(root) { title “Todays news” }

Hope this helps.

Regards, Morton

Thanks Morton; just what I was looking for. In Tcl you use toplevel
to create what I call a “root” window. The Pickaxe does not go
into much detail - perlTk book in the post.

Thanks again, and apologies for the elementary question.

Len

On Nov 24, 2006, at 2:51 PM, Len L. wrote:

Thanks Morton; just what I was looking for. In Tcl you use toplevel
to create what I call a “root” window. The Pickaxe does not go
into much detail - perlTk book in the post.

I must say, despite the advice in the Pickaxe book, I have not found
perl/Tk documentation to be all that useful – that may be because I
don’t know zip about perl. What I rely on, besides the Tcl/Tk man
pages and the Tk documentation available on the web, are:

http://raa.ruby-lang.org/project/rubytk_en/
http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/ext/tk/sample/

I recommend you look at these sites.

Thanks again, and apologies for the elementary question.

No need for apologies. We all start from square one. I’m no Ruby/Tk
expert. I’m on square two. I’ve asked even more elementary Ruby/Tk
questions on this list myself and quite recently at that.

Regards, Morton

On Sat, 25 Nov 2006 11:48:49 +0900, Morton G. wrote:

------ text excised -------------
I must say, despite the advice in the Pickaxe book, I have not found
perl/Tk documentation to be all that useful – that may be because I
don’t know zip about perl. What I rely on, besides the Tcl/Tk man
pages and the Tk documentation available on the web, are:

http://raa.ruby-lang.org/project/rubytk_en/
http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/ext/tk/sample/

I recommend you look at these sites.

Right, I have them bookmarked now. Will check them out later.

I am impressed with the ease and speed of development in ruby. It has
taken about 12 days to to learn the basics and rewrite a user interface
which needs to be in production by Tuesday. Bullet-proofing comes
later.

The only outstanding problem is how to get BLT to work (for xy plots)
but
those websites above may have some answers.

1.upto(1000) { puts “Thanks” }

Len

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs