From: Ferenc Engard Date: 2003-10-03T05:07:52+09:00 Subject: Re: tcltklib and not init'ing tk > I end up having a current_obj variable or something which can be gotten at > with a class method at the Tcl level, i.e.: > > proc some_proc {} { > set somevar [ruby {SomeClass.current_obj.do_something()}] > } > > #and... > class SomeClass > def SomeClass.current_obj > return @@current_obj > end > > ... > > def some_instance_method() > @@current_obj = self > TclUtils.eval("some_proc") > end > end > > Ugly. Sinfully ugly. Luckily, I try to keep Ruby in control of most > everything, and the Tcl is a configuration file, so I don't need to do this > that often. Or you can use the TclTkCallback class as I have shown in my previous post: class SomeClass ... def do_something ... return some_str end def some_instance_method() pr=proc {do_something} cb=TclTkCallback.new(ip,pr,"%s") $interpreter._eval(cb.to_eval) # or something to eval cb.eval in the tcl interpreter end end