I am using Active State Perl on Win7, and would like to run Canvas under Tkx.
The Active State build is a total kloodge of mutually incompatible Tk and Tkx modules in similar but not identical folders, and example programs that won't run because they can't find modules in the referenced libraries.
Can anyone direct me to a sample perl program using Canvas under Tkx which runs on an Active State perl system in Windows?
Here are the Tk and Tkx folders Active State installed on my disc:
Edit: OK! No one has a Canvas program under Tkx which runs on an Active State perl system in Windows. I guess that tells me what I need to know. It can't be done.
What about Raspberry Perl. Can it be done there?
============== Tk ===========================
C:\Perl\Documentation\Tk Manual.htm
C:\Perl\Documentation\Tk Manual_files
C:\Perl\lib\Tk.pm
C:\Perl\Tk-804.028
C:\Perl\Tk-804.028\demos\Tk.pm
C:\Perl\Tk-804.028\Documentation\Tk Manual.htm
C:\Perl\Tk-804.028\Documentation\Tk Manual_files
C:\Perl\Tk-804.028\Good online Tk Tutorial.url
C:\Perl\Tk-804.028\pod\Tk.cmd
C:\Perl\Tk-804.028\pTk\bitmaps\tk.bmp
C:\Perl\Tk-804.028\pTk\mTk\generic\tk.decls
C:\Perl\Tk-804.028\pTk\mTk\generic\tk.h
C:\Perl\Tk-804.028\pTk\mTk\unix\tk.spec
C:\Perl\Tk-804.028\pTk\mTk\win\rc\tk.ico
C:\Perl\Tk-804.028\pTk\mTk\win\rc\tk.rc
C:\Perl\Tk-804.028\pTk\tk.exc
C:\Perl\Tk-804.028\pTk\tk.m
C:\Perl\Tk-804.028\pTk\tk.t
C:\Perl\Tk-804.028\Tixish\lib\Tk
C:\Perl\Tk-804.028\Tk
C:\Perl\Tk-804.028\Tk-804.028.tar
C:\Perl\Tk-804.028\Tk.pm
C:\Perl\Tk-804.028\Tk.pod
C:\Perl\Tk-804.028\Tk.xs
C:\Perl\Tk-804.028\Tk\Tk.xbm
C:\Perl\Tk-804.028\Tk\Tk.xpm
C:\Perl\Tkx\TkDocsTutorial_files\tk.css
========== Tkx ======
C:\Perl\Active Perl\bin\tkx-ed.html
C:\Perl\Active Perl\html\bin\tkx-ed.html
C:\Perl\Active Perl\html\lib\ActiveState\Tkx
C:\Perl\Active Perl\html\lib\Tkx
C:\Perl\Active Perl\html\lib\Tkx.html
C:\Perl\Active Perl\lib\Tkx
C:\Perl\Active Perl\lib\Tkx.html
C:\Perl\bin\tkx-ed
C:\Perl\bin\tkx-ed.bat
C:\Perl\bin\tkx-prove
C:\Perl\bin\tkx-prove.bat
C:\Perl\html\bin\tkx-ed.html
C:\Perl\html\lib\ActiveState\Tkx
C:\Perl\html\lib\Tkx
C:\Perl\html\lib\Tkx.html
C:\Perl\lib\ActiveState\Tkx
C:\Perl\lib\ActiveState\Tkx.pm
C:\Perl\lib\auto\Tkx
C:\Perl\lib\Tkx
C:\Perl\lib\Tkx.pm
C:\Perl\Tkx
C:\Perl\Tkx\Perl-lib-Tkx.lnk
C:\Perl\Tkx\Tkx Reference Manual.html.lnk
C:\Perl64\bin\tkx-ed
C:\Perl64\bin\tkx-ed.bat
C:\Perl64\bin\tkx-prove
C:\Perl64\bin\tkx-prove.bat
C:\Perl64\html\bin\tkx-ed.html
C:\Perl64\html\lib\ActiveState\Tkx
C:\Perl64\html\lib\Tkx
C:\Perl64\html\lib\Tkx.html
C:\Perl64\lib\ActiveState\Tkx
C:\Perl64\lib\ActiveState\Tkx.pm
C:\Perl64\lib\auto\Tkx
C:\Perl64\lib\Tkx
C:\Perl64\lib\Tkx.pm
Canvas is a part of Tcl/Tk, so it's available via Tkx. Here's a trivial example:
use strict;
use warnings;
use Tkx;
my $mw = Tkx::widget->new('.');
my $canvas = $mw->new_canvas();
$canvas->g_pack();
$canvas->create_text(100, 10, -text => "Hello, world!");
$canvas->create_rectangle(25, 25, 50, 50, -fill => 'red');
$canvas->create_oval(40, 40, 80, 80, -fill => 'green');
$canvas->create_line(20, 20, 100, 100);
Tkx::MainLoop();
TkDocs has a canvas tutorial that includes sample code in Perl with Tkx.
Note that Tkx is a very thin layer over Tcl/Tk. The Tkx documentation describes how that layer works but for most tasks you'll need to consult the Tk documentation and translate the commands into Perl. e.g. pathName create line x1 y1...
becomes $canvas->create_line(x1, y1, ...)
Using Tkx is easiest under ActivePerl because it bundles the requisite Tcl/Tk libraries. To use Tkx under a different Perl distribution you'll need to install Tcl/Tk separately and configure your environment so that Tkx can find it.