From: Aamer Akhter Date: 2003-10-02T10:02:53+09:00 Subject: Re: tcltklib and not init'ing tk On 10/1/03 3:32 PM, in article 3F7B2BC9.A06E6B27@engard.hu, "Ferenc Engard" wrote: > "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... It looks like 1.8 has this. Your example does bring up a problem that I'll probably have to deal with pretty quickly if this transition is going to work. Is there any work done with regards to converting tcl hashes to ruby hashes (probably not), tcl "lists" to ruby array's and tclX keyedlists to ruby hashes. > > -------------------------------------------------------------------- > --- 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 > --------------------------------------------------------------------