ptkFAQ
view release on metacpan or search on metacpan
----------------------
Guy Decoux <decoux@moulon.inra.fr> has ported the popular BLT_Table Tcl/Tk
tabular geometry manager to perl/Tk. It was known to work with Tk-b8. You may
obtain the latest version of it either from
ftp://moulon.inra.fr/pub/pTk/
or from a CPAN site in the authors/id/GUYDX/ directory. You may also browse
the perl BLT_Table man page on the web at
http://w4.lns.cornell.edu/~pvhp/ptk/etc/Table.html
______________________________________________________________________
16. Programming/development tools.
There are a number of tools and methods to help you with your perl/Tk scripting and
development. It is worthwhile to note here that the -w switch is recommended as is
the use strict; statement near the top of your script/program. If it dies and you
still cannot decrypt the error message that these generate take a look though man
perldiag(1).
______________________________________________________________________
16.1 Is there a Tcl/Tk to perl/Tk translator?
Nick Ing-Simmons has written a (rather lengthy) tcl2perl script. It is being
distributed with the perl/Tk code as of Tk-b9.01. Please handle carefully! (translation:
do not expect it to translate arbitrary tcl code accurately nor even into the most
efficient perl/Tk equivalent. Do go over the converted script with care - and do not
forget -w and use strict;.) Thanks Nick :-)
______________________________________________________________________
16.2 Is there something equivalent to wish in perl/Tk?
The answer is yes.
The idea of wish is that you read from <STDIN> and evaluate each statement. The
standard way to do this in perl/Tk is to use the tkpsh script that comes in your
Tk-b#/ distribution. Another elegant way to get wish like behavior in perl/Tk is to
use rmt which you can find in perl5/Tk/demos in your Tk-b# distribution.
When you run rmt you already have Tk.pm set up for you so you can start typing
things like $mmm = new MainWindow; etc. at the rmt: prompt. (This use belies
the power of rmt which is derived from Ousterhout's Tcl/Tk version of rmt [see
section 27.2 of his book]. rmt is capable of "inserting Tk code" into simultaneously
running Tk applications.)
A cruder way to get wish-like behaviour with perl/Tk is to run a "perl shell" and
type in your usual commands, including use Tk; etc. There is a script distributed
with perl called perlsh which is written quite simply as:
#!/usr/bin/perl
$/ = ''; # set paragraph mode
$SHlinesep = "\n";
while ($SHcmd = <>) {
$/ = $SHlinesep;
eval $SHcmd; print $@ || "\n";
$SHlinesep = $/; $/ = '';
}
You can use this during code development to test out little snippets of code. It helps to
be an accurate typist and the use strict; is optional here :-)
Hiroaki Kobayasi has a more sophisticated wish like perl/Tk "shell" that is called
EVA. It is available from:
ftp://ftp.sowa.is.uec.ac.jp/pub/Lang/perl5/Tk/eva-*.tar.gz
______________________________________________________________________
16.3. Is there a debugger specifically for perl/Tk?
Not for the latest version - but the -w switch and use strict; are always helpful
with debugging as they provide informative error messages. You can, of course, run
under the regular debugger using:
perl -d myscript
Gurusamy Sarathy <gsar@engin.umich.edu> has built a PERL5DB file called
Tkperldb (which despite the name is for pTk not Tk/perl). One must install an early
de-bugger then apply a patch to bring the debugger up to date. The early debugger kit
is available from:
ftp://ftp.perl.com/pub/perl/ext/TK/Tkperldb-a1.tar.gz
And Gurusamy Sarathy notes that the patch to bring the debugger up to date is
available at:
You need a post 5.001m perl that has support for debugging closures.
Or you can simply apply:
http://www-personal.umich.edu/~gsar/perl5.001m-bugs.patch
to 5.001m. (5.002beta includes all the fixes in the above patch).
Note that a perl debugger may be invoked within your script with a line like:
$ENV{'PERL5DB'} = 'BEGIN { require Tkperldb }';
See man perldebug(1) for more help.
Keep in mind that you are programming in perl after all. The perl debug line mode is
available to you through executing the following from your shell:
perl -de 0
Whereupon you must enter all the lines of a script including use Tk;. (Fancier file
reads & evals are possible - but if you are getting that sophisticated why not create
your own custom PERL5DB file?) When using perl -dwe 0 beware of the emacs
like line editing under this debugger, and be forewarned that as soon as you type in the
MainLoop; statement perl will no longer read from <STDIN>.
Ilya Zakharevich <ilya@math.ohio-state.edu> points out that very recent perldb
versions will allow for simultaneous X and STDIN reads. He also points out:
Note that you may use
( run in 1.028 second using v1.01-cache-2.11-cpan-8dfa8b56332 )