Re: Pass Perl functions to Tcl interpreter
[email protected] (Eric Windisch) Mon, 20 Aug 2012 10:41:31 -0400
| Newsgroups | perl.tcltk |
|---|---|
| Message-ID | <[email protected]> |
On Sunday, August 19, 2012 at 13:19 PM, Kevin Walzer wrote:
> Hello all,
>
> I'm learning Perl and Tkx and am wondering if it is possible to pass
> Perl functions to the Tcl interpreter in a manner similar to Python's
> "register" method in the Tkinter module. In Python, you can call
> register("mypythonfunction"), which is then passed to the Tcl
> interpreter as though it were a Tcl procedure. This functionality is
> useful when interacting wtih the Tcl interpreter at a low level.
I've used CreateCommand in the past:
$name="new_cmd_name_in_tcl";$tcl->CreateCommand($name, sub {
> my $clientdata=shift; # this is set to "a_string_here"
> my $interp=shift;
> my $argc=shift;
> # @_ will contain argv
> call_some_perl_sub(@_);
}, "a_string_here");
You can use the $argc and $clientdata strings in interesting ways...
--
Eric Windisch