Exasperated with ruby/tk - anybody successfully using it?

General question: Is ruby/tk still being maintained in 1.7/1.8 or is it
dead? There is no documentation that I can find, and almost everything I try
results in a ruby error/bug. For example:

  • Attempt to use TkSpinbox result in ‘tk_call’: invalid command name
    `spinbox’

  • Attempt to use TkOptionMenubutton results in `__invoke’: unknown option
    "-kind_of"

  • The event with TkOptionMenubutton does not work properly

  • Attempt to use the -command option with TkOptionMenubutton results in
    `__invoke’: unknown option “-command”

  • I upgraded to ruby180-9 from http://rubyinstaller.sourceforge.net/, and
    after doing so the Tk.mainloop call never even returns!!

Is anybody using ruby/tk successfully?

In article 017401c33860$ff13a800$0200a8c0@hal9000,

General question: Is ruby/tk still being maintained in 1.7/1.8 or is it
dead? There is no documentation that I can find, and almost everything I try
results in a ruby error/bug. For example:

  • Attempt to use TkSpinbox result in ‘tk_call’: invalid command name
    `spinbox’

  • Attempt to use TkOptionMenubutton results in `__invoke’: unknown option
    “-kind_of”

  • The event with TkOptionMenubutton does not work properly

  • Attempt to use the -command option with TkOptionMenubutton results in
    `__invoke’: unknown option “-command”

  • I upgraded to ruby180-9 from http://rubyinstaller.sourceforge.net/, and
    after doing so the Tk.mainloop call never even returns!!

Is anybody using ruby/tk successfully?

For some very small projects , yes, I’ve had some success. However, I
suspect that Tk might not be the best option for larger projects - I’d
probably look at FxRuby (FOX) for larger projects.

As far as docs go, I’ve found the following links:

http://www.approximity.com/ruby/rubytk.html (Ruby/Tk FAQ)
http://httpd.chello.nl/k.vangelder/ruby/learntk/index.html (Ruby/Tk
tutorial)

However, these generally don’t go into as much detail as is needed and not
all widgets are covered. I found myself doing a lot of searching on
Perl/Tk sites for more of the arcane details.

I do tend to like Tk’s canvas widget (because you can tag any object drawn
on it) and Tk does have the advantage (at least on Linux) that it will
most likely already be installed so users will tend to already have it.
However,I think Tk is starting to show it’s age and I’m wanting to learn
some of the newer GUI toolkits out there like FOX, FLTK and WxWindows
(wish WxRuby was done). I will miss the TkCanvas widget, though.

Phil

···

Richard Browne richb@timestone.com.au wrote:

Message-ID: 017401c33860$ff13a800$0200a8c0@hal9000

  • Attempt to use TkSpinbox result in ‘tk_call’: invalid command name
    `spinbox’

‘spinbox’ is the feature of Tk8.4.
If your Ruby/Tk doesn’t link the Tk8.4 library,
cannot use TkSpinbox on your Ruby/Tk.

  • Attempt to use TkOptionMenubutton results in `__invoke’: unknown option
    “-kind_of”
  • The event with TkOptionMenubutton does not work properly
  • Attempt to use the -command option with TkOptionMenubutton results in
    `__invoke’: unknown option “-command”

Probably you didn’t write with Ruby/Tk notation.
On Ruby/Tk, each option doesn’t have ‘-’ on its head.
Please see the sample script for menubuttons on this mail.

I’m sorry, but I don’t know about the package.
I have no answer about this.

                              Hidetoshi Nagai (nagai@ai.kyutech.ac.jp)
···

From: “Richard Browne” richb@timestone.com.au
Subject: Exasperated with ruby/tk - anybody successfully using it?
Date: Sun, 22 Jun 2003 10:53:37 +0900

#!/usr/bin/env ruby

menubutton sample : based on sample menubuttons on the Tcl/Tk demo script

require ‘tk’

TkLabel.new(:text=>‘Sample of TkMenubutton’).pack(:side=>:top)

TkFrame.new{|f|
pack(:side=>:top)

TkMenubutton.new(:parent=>f, :text=>‘Right’, :underline=>0,
:direction=>:right, :relief=>:raised){|mb|
menu TkMenu.new(:parent=>mb, :tearoff=>0){
add(:command, :label=>‘Right menu: first item’,
:command=>proc{print ‘You have selected the first item’ +
" from the Right menu.\n"})
add(:command, :label=>‘Right menu: second item’,
:command=>proc{print ‘You have selected the second item’ +
" from the Right menu.\n"})
}
pack(:side=>:left, :padx=>25, :pady=>25)
}

TkMenubutton.new(:parent=>f, :text=>‘Below’, :underline=>0,
:direction=>:below, :relief=>:raised){|mb|
menu(TkMenu.new(:parent=>mb, :tearoff=>0){
add(:command, :label=>‘Below menu: first item’,
:command=>proc{print ‘You have selected the first item’ +
" from the Below menu.\n"})
add(:command, :label=>‘Below menu: second item’,
:command=>proc{print ‘You have selected the second item’ +
" from the Below menu.\n"})
})
pack(:side=>:left, :padx=>25, :pady=>25)
}

TkMenubutton.new(:parent=>f, :text=>‘Above’, :underline=>0,
:direction=>:above, :relief=>:raised){|mb|
menu TkMenu.new(:parent=>mb, :tearoff=>0){
add(:command, :label=>‘Above menu: first item’,
:command=>proc{print ‘You have selected the first item’ +
" from the Above menu.\n"})
add(:command, :label=>‘Above menu: second item’,
:command=>proc{print ‘You have selected the second item’ +
" from the Above menu.\n"})
}
pack(:side=>:left, :padx=>25, :pady=>25)
}

TkMenubutton.new(:parent=>f, :text=>‘Left’, :underline=>0,
:direction=>:left, :relief=>:raised){|mb|
menu(TkMenu.new(:parent=>mb, :tearoff=>0){
add(:command, :label=>‘Left menu: first item’,
:command=>proc{print ‘You have selected the first item’ +
" from the Left menu.\n"})
add(:command, :label=>‘Left menu: second item’,
:command=>proc{print ‘You have selected the second item’ +
" from the Left menu.\n"})
})
pack(:side=>:left, :padx=>25, :pady=>25)
}
}

############################
TkFrame.new(:borderwidth=>2, :relief=>:sunken,
:height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
############################

TkLabel.new(:text=>‘Sample of TkOptionMenu’).pack(:side=>:top)

colors = %w(Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50
Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet)

TkFrame.new{|f|
pack(:side=>:top)

b1 = TkOptionMenubutton .
new(:parent=>f, :values=>%w(one two three)) .
pack(:side=>:left, :padx=>25, :pady=>25)

b2 = TkOptionMenubutton.new(:parent=>f, :values=>colors) {|optMB|
colors.each{|color|
no_sel = TkPhotoImage.new(:height=>16, :width=>16){
put ‘gray50’, *[ 0, 0, 16, 1]
put ‘gray50’, *[ 0, 1, 1, 16]
put ‘gray75’, *[ 0, 15, 16, 16]
put ‘gray75’, *[15, 1, 16, 16]
put color, *[ 1, 1, 15, 15]
}
sel = TkPhotoImage.new(:height=>16, :width=>16){
put ‘Black’, *[ 0, 0, 16, 2]
put ‘Black’, *[ 0, 2, 2, 16]
put ‘Black’, *[ 2, 14, 16, 16]
put ‘Black’, *[14, 2, 16, 14]
put color, *[ 2, 2, 14, 14]
}
optMB.entryconfigure(color, :hidemargin=>1,
:image=>no_sel, :selectimage=>sel)
}
optMB.menuconfigure(:tearoff, 1)
%w(Black gray75 gray50 White).each{|color|
optMB.entryconfigure(color, :columnbreak=>true)
}
pack(:side=>:left, :padx=>25, :pady=>25)
}

TkButton.new(:parent=>f){
text ‘show values’
command proc{p [b1.value, b2.value]}
pack(:side=>:left, :padx=>25, :pady=>5, :anchor=>:s)
}
}

############################
TkFrame.new(:borderwidth=>2, :relief=>:sunken,
:height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
############################

root = TkRoot.new(:title=>‘menubutton samples’)

TkButton.new(root, :text=>‘exit’, :command=>proc{exit}){
pack(:side=>:top, :padx=>25, :pady=>5, :anchor=>:e)
}

VirtualEvent <> on Tcl/Tk ==> ‘’ on Ruby/Tk

( remove the most external <, > for Ruby/Tk notation )

TkMenu.bind(‘’, proc{|widget|
p widget.entrycget(‘active’, :label)
}, ‘%W’)

############################

Tk.mainloop

Richard Browne wrote:

General question: Is ruby/tk still being maintained in 1.7/1.8 or is it
dead? There is no documentation that I can find, and almost everything I
try
results in a ruby error/bug. For example:

  • Attempt to use TkSpinbox result in ‘tk_call’: invalid command name
    `spinbox’

  • Attempt to use TkOptionMenubutton results in `__invoke’: unknown option
    “-kind_of”

  • The event with TkOptionMenubutton does not work properly

  • Attempt to use the -command option with TkOptionMenubutton results in
    `__invoke’: unknown option “-command”

  • I upgraded to ruby180-9 from http://rubyinstaller.sourceforge.net/, and
    after doing so the Tk.mainloop call never even returns!!

Hidetoshi Nagai may be unfamiliar with Ruby on Win32.

That installer comes with both Ruby/Tk and the raw binary Tk underneath it.
So if it can’t do these simple things, complain to the installer’s mailing
lists.

Is anybody using ruby/tk successfully?

I’m making an excellent example of it.

Especially the TkCanvas. It’s better than other wrappers on the TCL/TK
Canvas.

···


Phlip
http://www.c2.com/cgi/wiki?TestFirstUserInterfaces

I am using it for small things and didn´t find problems.
Have you seen rtkdemos? Should give you a quick idea what
works.

Richard

···

On Sun, Jun 22, 2003 at 10:53:37AM +0900, Richard Browne wrote:

Is anybody using ruby/tk successfully?

Message-ID: 20030623.012709.74733836.nagai@ai.kyutech.ac.jp

Please see the sample script for menubuttons on this mail.

The script is written by using new notation of Ruby/Tk on Ruby1.8.x.
If based on the notation,

  • You can give the options and values by Symbols.
  • You can give the parent widget on the Hash argument of ‘new’ method.
···

From: Hidetoshi NAGAI nagai@ai.kyutech.ac.jp
Subject: Re: Exasperated with ruby/tk - anybody successfully using it?
Date: Mon, 23 Jun 2003 01:27:10 +0900

                              Hidetoshi Nagai (nagai@ai.kyutech.ac.jp)

Probably you didn’t write with Ruby/Tk notation.
On Ruby/Tk, each option doesn’t have ‘-’ on its head.
Please see the sample script for menubuttons on this mail.

Hidetoshi, thanks for the reply. I can’t run your script tho. Using
ruby-1.8.0-20030515-i386-mswin32 I get errors:

C:/ruby/lib/ruby/1.8/tk.rb:3661:in configure': wrong number of arguments(3 for 2) (ArgumentError) from C:/ruby/lib/ruby/1.8/tk.rb:3661:in menuconfigure’
from /t.rb:80
from /t.rb:61:in new' from /t.rb:61:in new’
from /t.rb:61
from /t.rb:54:in new' from /t.rb:54:in new’
from /t.rb:54

Richard Zidlicky wrote:

···

On Sun, Jun 22, 2003 at 10:53:37AM +0900, Richard Browne wrote:

Is anybody using ruby/tk successfully?

I am using it for small things and didn´t find problems.
Have you seen rtkdemos? Should give you a quick idea what
works.

Richard

I like the ruby-tk demos. Is there any plan to release something
similar in the new Ruby-Tk notation for 1.8 which was mentioned in this
thread?

Thanks

John

Message-ID: 014801c33900$f9754020$0200a8c0@hal9000

Hidetoshi, thanks for the reply. I can’t run your script tho. Using
ruby-1.8.0-20030515-i386-mswin32 I get errors:

C:/ruby/lib/ruby/1.8/tk.rb:3661:in configure': wrong number of arguments(3 for 2) (ArgumentError) from C:/ruby/lib/ruby/1.8/tk.rb:3661:in menuconfigure’
from /t.rb:80
from /t.rb:61:in new' from /t.rb:61:in new’
from /t.rb:61
from /t.rb:54:in new' from /t.rb:54:in new’
from /t.rb:54

Sorry. It depends on the fixed bug.
Old ‘menuconfigure’ method has a meaningless argument.
I removed it before sending the refered mail.
Please get the newest version of Ruby/Tk libraries from CVS.
Some changes of the libraries depend on the patch of tcltklib.c.
But others are closed into the libraries.
Probably, you can test the script by replacing tk*.rb to newer files.

Now I’m trying to make Ruby/Tk on Ruby1.8.x better.
So, there are many differences before 2003/06/10 and now.
Bug reports and new feature requests are welcome. :slight_smile:

···

From: “Richard Browne” richb@timestone.com.au
Subject: Re: Exasperated with ruby/tk - anybody successfully using it?
Date: Mon, 23 Jun 2003 05:58:56 +0900

                              Hidetoshi Nagai (nagai@ai.kyutech.ac.jp)

Message-ID: 3EF6BB63.F241A6DC@aston.ac.uk

I like the ruby-tk demos. Is there any plan to release something
similar in the new Ruby-Tk notation for 1.8 which was mentioned in this
thread?

Ruby/Tk on 1.8 accepts both of old and new notation.
So, for example, all of followings are valid to create a button widget.

  • TkButton.new(parent, ‘text’=>‘XXX’, ‘anchor’=>‘e’, …) { … }
  • TkButton.new(parent, :text=>‘XXX’, :anchor=>:e, …) { … }
  • TkButton.new(parent, ‘text’=>‘XXX’, :anchor=>‘e’, …) { … }
  • TkButton.new(‘parent’=>parent, ‘text’=>‘XXX’, :anchor=>‘e’, …) { … }
  • TkButton.new(:parent=>parent, :text=>‘XXX’, :anchor=>:e, …) { … }
···

From: John Fletcher J.P.Fletcher@aston.ac.uk
Subject: Re: Exasperated with ruby/tk - anybody successfully using it?
Date: Mon, 23 Jun 2003 18:14:59 +0900


Hidetoshi Nagai (nagai@ai.kyutech.ac.jp)