Python has a “register” function that wraps a Python function into a Tcl
function and returns the new Tcl function’s name. This is sometimes used
in Python-Tk applications for functions that need to be attached to Tk
widgets in some complex way. Does Ruby-Tk have any similar
functionality?
My use case is a native widget that is called via Tcl/Tk and exposed via
Tk bindings–there is no easy way to pass Python or Ruby calls to this
widget. “Register” allows me to pass a Python function that is executed
as if it were Tcl code. I would love similar functionality in Ruby.
From: Kevin W. [email protected]
Subject: “Register” Ruby function as Tcl function in Ruby-Tk?
Date: Sat, 30 Jun 2012 22:19:54 +0900
Message-ID: [email protected]
Ruby.
There are some ways of interaction betwenn Ruby and Tcl.
Followings are some of useful methods to do that.
Tk.install_cmd(proc_or_method)
: get Tcl-command string to call Ruby’s proc (or method) from Tcl
interp.
: ruby_proc must be an object of Proc, Method, or TkCallbackEntry.
Tk.ip_eval(tcl_script_string)
: eval Tcl’s script on Tcl interp.
Tk.ip_invoke(tcl_cmd_name, tcl_cmd_arg, …)
: call Tcl command with args.