From: Ferenc Engard Date: 2003-10-02T04:42:18+09:00 Subject: Re: tcltklib and not init'ing tk "Brett H. Williams" wrote: > > On Oct 1, Aamer Akhter wrote: [...] > > 2) Is there a japanese to english translation of > > ext/tcltklib/MANUAL.euc? Or can somebody point to a tool that I may > > use to do the translation? babelfish.altavista does not appear to > > work. I have some hungarian notes about its work... :)) Sorry. :-/ > for Ruby/Tk. Access to the Tcl interpreter through it is a side effect--a > highly useful side effect for me and you, but nevertheless not really And me :) > > 3). Are there any examples of ruby methods being called from the tcl > > code running inside the interpreter? You can register ruby proc objects into tcl and use it. However, it is a bit though to understand. Actually, there is a ruby_fmt proc which is buggy, but it is extensively used by tcltklib. Here is a patch for 1.6.7, but I do not think that it has changed since then... -------------------------------------------------------------------- --- tcltk.old.rb 2002-02-07 02:53:30.000000000 +0100 +++ tcltk_jav.rb 2003-01-07 02:36:04.000000000 +0100 @@ -93,9 +93,9 @@ # ruby_fmt command format arguments by `format' and call `ruby' command # (notice ruby command receives only one argument) if $DEBUG - @ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt $args\" ; ruby [format $fmt $args] }") + @ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt $args\" ; set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }") else - @ip._eval("proc ruby_fmt {fmt args} { ruby [format $fmt $args] }") + @ip._eval("proc ruby_fmt {fmt args} { set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }") end # @ip._get_eval_string(*args): generate string to evaluate in tcl interpreter -------------------------------------------------------------------- Here I post a testprog of mine, ask if you cannot figure out what is going on... -------------------------------------------------------------------- require "tcltk" $DEBUG=1 ip=TclTkInterpreter.new pr=proc { |*args| puts "args: #{args}" puts "valami" } # megold�s param�ter�tad�sra # cb.to_eval: {ruby_fmt {TclTk._callcallback("c_1", "%%s")} %s} cb=TclTkCallback.new(ip,pr,"%s") puts "cb to_eval: #{cb.to_eval}" # a [format] a %%s hely�re %s-t, %s hely�re pedig param1-et helyettes�t, azaz: # ... -command {ruby_fmt {TclTk._callcallback("c_1", "%s")} param1} btn1=TclTkWidget.new(ip,".","button","-text valami","-command [format ", cb,"param1]") ip.pack(btn1) TclTk.mainloop --------------------------------------------------------------------