http://www.perlmonks.org?node_id=285058

CPAN modules Tcl-0.72.tar.gz and TclTk-0.72.tar.gz allow connecting to existing Tcl/Tk installation and these modules are able to provide syntax very similar to perl/Tk.
I wrote this announcement here because of two main reasons:
  1. to let people try those modules and may be they will provide useful feedback and further ideas.
  2. (most improtant item) may be volunteers could help me improving documentation of modules
    I need help in preparing better and cleaner phrases.

These newly released modules allow Perl users to use newest available Tcl/Tk features plus pure-Tcl widgets but still remaining in usual perlTk syntax.
Usually the only distinction is using use Tcl::Tk qw(:perlTk); instead of use Tk;.
(sometimes several modifications of perlTk code still necessary, but I hope this will be improved in the future)

Here is an example:

use Tcl::Tk qw(:perlTk); $mw = MainWindow->new; $mw->Label(-text => "Hello world")->pack; $btn = $mw->Button(-text => "test", -command => sub { $btn->configure(-text=>"[". $btn->cget('-text')."]"); })->pack; $edt = $mw->Text()->pack; $edt->insert('end',"\x{2456}\x{2457}"); MainLoop;

While there are still some places to improve and even DEBUG information appearing, there's not much work remains to do, and I am planning finishing it within couple of weeks.

Actually size of Tcl::Tk is rather small, and most of actual processing is performed on Tcl side.
Examples occupy a lot of space inside distribution, but module itself is small.

Courage, the Cowardly Dog
PS. I am also thinking about allowing to use pure-perl widgets in Tcl::Tk, but currently I can't guarantee anything on this.

Replies are listed 'Best First'.
Re: Tcl, Tcl::Tk now much better, but need documentation improvements
by batkins (Chaplain) on Aug 19, 2003 at 22:09 UTC
    Looks interesting. I wish someone would update Perl/Tk, though - I really can't have users of my scripts download an entire Tcl/Tk distribution just to use Tcl::Tk.
      As far as I know perl/Tk will be updated soon to support Unicode in perl-5.8.x

      But this is entirely different approach.

      Normally you do not need Tcl::Tk when you are satisfied with perlTk, but here are cases when I use it and advice it to use for others:

      1. sometimes Perl somes without perl/Tk (Linux, FreeBSD and probably other distribution do not have it unless you managed to build perlTk) and compiling perlTk is much more consuming task than Tcl::Tk, because usually Tcl/Tk already exist in system and Tcl::Tk as a glue is really lightweight
        Being lightweight, it is much easier to port it to another OS, and, as a bright example, currently Tcl::Tk is the only way to get GUI for perl-5.8.x on WinCE, yet the only way to get Unicode-aware GUI for perl-x.x.x on WinCE.
        (OT: FreeBSD has rather old Perl and rather new Tcl/Tk after installing of OS. Why?)
      2. You need some feature that exists in Tcl/Tk but not available in perlTk. Mostly these are Unicode and large set of widgets available in Tcl/Tk.
      3. Not only widgets, but some parts of ready-to-use Tcl/Tk code could be used from Perl, as long as perl has full access to all widgets created in Tcl/Tk.
        (I use this approach quite often)
      4. Elder perls could have Unicode-enabled GUI this way.
        (I'm still using perl-5.6.1 and really will migrate to perl-5.8.1 soon, but until that I have ability to create Unicode-aware GUI)
      Also, Tcl/Tk is updated more frequently than perlTk do.

      Courage, the Cowardly Dog

        OT: FreeBSD has rather old Perl and rather new Tcl/Tk after installing of OS. Why?

        What do you mean? FreeBSD's core containts rather old Perl but you are welcome to install latest Perl from ports collection. On the other hand Tcl/Tk is available from ports collection only.

        --
        Ilya Martynov, ilya@iponweb.net
        CTO IPonWEB (UK) Ltd
        Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
        Personal website - http://martynov.org

Re: Tcl, Tcl::Tk now much better, but need documentation improvements
by Anonymous Monk on Aug 27, 2003 at 11:40 UTC
    exception number: c0000005 (access violation)
    get this in an error log when i do
    $interp->Eval($fileName)
      in windows 2000 sp2 ...
      Need more information: what version of Tcl/Tk installed, whether it is seen in PATH (actually it is possible to "bring" Tcl/Tk dictribution and have it together with perl, but anyway it should find correct tclXXX.dll)

      What is inside that variable $fileName?

      Note that you probably should do

      $interp->Eval("source $fileName");

      Courage, the Cowardly Dog

        actually its tcl::0.72 (not tcl::tk) perl 5.8 tcl 8.4 ... i started with $interp->evalfile("source $fileName") but changed to Eval because this was happening ... also it happens of i to $interp->Eval("set fh open $fileName").... basically what is happening is that wimdows os throwing a protection error when the Tcl process is trying to open a file