Hi Kevin,

The binding for Tkx is much more efficient than Tkinter, and does allow for 2 
way communication and command binding in the interface.

Alexander noted you have ::perl::Eval in Tcl, but there are more ways to bind 
the 2 pieces together.  I would recommend looking at the code for ppm in 
ActivePerl, which uses Tkx in various elaborate ways (blending Tcl and Perl in 
interesting ways), for lots of good code examples.  See
  /usr/local/ActivePerl-<ver>/bin/ppm
  /usr/local/ActivePerl-<ver>/lib/ActivePerl/PPM/*

Note that ActivePerl uses Tkx via tkkits (baseballs with extended 
functionality).  These can be extended (see archives of this list), but you can 
use external packages as needed.

Jeff

On 2012-08-19, at 10:19 AM, Kevin Walzer wrote:
> 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.
> 
> Let me explain my interest in this issue. I'm working on Mac OS X and am 
> trying to build a Perl/Tkx application that supports responding to 
> AppleEvents, i.e.  you can script the Perl-based application via AppleScript 
> just like you can script Safari, iTunes, Photoshop, and other apps. Perl, 
> though, lacks up-to-date methods for integrating with AppleScript; its 
> current methods, such as 
> http://search.cpan.org/~cnandor/Mac-AppleEvents-Simple-1.18/Simple.pm, are 
> based on deprecated functions that don't work in a 64-bit context, which is 
> essential.
> 
> I've investigated alternative approaches for adding such functionality, such 
> as creating a SWIG-based extension, but SWIG doesn't allow callbacks into the 
> Perl interpreter. Another approach I've researched is using SWIG to call out 
> to a helper Perl application that would then call the main Perl application 
> via some sort of RPC mechanism, but all the RPC mechanisms I've tried 
> (numerous links at 
> http://search.cpan.org/~powerman/JSON-RPC2-0.1.1/lib/JSON/RPC2.pm#RATIONALE) 
> are all half-baked in some way. (If someone can point me to an RPC module 
> they've had success with, I'd be grateful. Ruby's "druby" module is elegant 
> and simple, but its lack of desktop app deployment tools for the Mac make 
> Ruby unsuitable.)
> 
> So the approach I'd like to try is installing AppleEvent handlers via Tcl's 
> TclAE package: this is a powerful package that can install the appropriate 
> AppleEvents and then execute event handlers in the Tcl interpreter. 
> Integrating this with Perl would, ideally, involve some sort of mechanism 
> where I can "register" a Perl function that is passed to the Tcl interpreter 
> and executed as if it were Tcl code.
> 
> Advice is appreciated.

Reply via email to