Hi there,
I am trying to learn how to glue tk with a scripting language, and have
several things that I cannot figure out.
I have understand that in tcltklib.c a tcl command ‘ruby’ is defined,
which executes it’s argument as a ruby command. In tk.rb, a
TkCore.callback method is defined, which is not clear for me. I see that
there is some Tk_CMDTBL and ‘rb_out …’ magic strings, but it is a bit
messy for me.
In practice, I would like to know that the callbacks I define, in what
context will run?
I have tried to figure it out:
···
irb(main):001:0> require "tk"
true
irb(main):004:0> Tk::INTERP._invoke “ruby”,"id"
TypeError: failed to convert Fixnum into String
from /usr/lib/ruby/1.6/tk.rb:889:in _invoke' from /usr/lib/ruby/1.6/tk.rb:889:in
_invoke’
from (irb):4
irb(main):002:0> Tk::INTERP._invoke “ruby”,“id.to_s”
"538134128"
irb(main):003:0> self.id
538134128
irb(main):005:0> a=“blah”
"blah"
irb(main):007:0> Tk::INTERP._invoke “ruby”,"a"
NameError: (eval):889:in _invoke': undefined local variable or method
a’ for #Object:0x40268ce0
from (eval):889:in _invoke' from /usr/lib/ruby/1.6/tk.rb:889:in
_invoke’
from (irb):7
irb(main):008:0> Tk::INTERP._invoke “ruby”,“a=‘blahblah’”
"blahblah"
irb(main):009:0> Tk::INTERP._invoke “ruby”,“a"
NameError: (eval):889:in _invoke': undefined local variable or method
a’ for #Object:0x40268ce0
from (eval):889:in _invoke' from /usr/lib/ruby/1.6/tk.rb:889:in
_invoke’
from (irb):9
irb(main):010:0> a
"blah”
In short, it look like the string is evaled in the context of main, but
the local variables are not seen.
Could somebody help to clear it out to me?
Thanks:
Circum