ptkFAQ

 view release on metacpan or  search on metacpan

ptkFAQ.html  view on Meta::CPAN

    <a href="ftp://moulon.inra.fr/pub/pTk/">ftp://moulon.inra.fr/pub/pTk/</a>
</pre>
or from a <a href="#CPAN">CPAN site</a> in the <KBD>authors/id/GUYDX/</KBD>
directory. You may also browse the perl BLT_Table man page on the web at
<pre>
    <a href="etc/Table.html">http://w4.lns.cornell.edu/~pvhp/ptk/etc/Table.html</a>
</pre>

	<p>Return to <a href="#TOC15.6">table of contents</a>

</p><hr><p>
<a name="A16">16. Programming/development tools.</a>
</p><p>
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 
<KBD>-w</KBD> switch is recommended as is the 
<KBD>use strict;</KBD> 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 
<a href="http://www.metronet.com/0/perlinfo/perl5/manual/perldiag.html">
<KBD>man perldiag(1)</KBD></a>.

	<p>Return to <a href="#TOC16">table of contents</a>

</p><hr><p>
<a name="A16.1"> 16.1 Is there a Tcl/Tk to perl/Tk translator?</a>
</p><p>
Nick Ing-Simmons has written a (rather lengthy) <CODE>tcl2perl</CODE> 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 <kbd>-w</kbd> and 
<kbd>use strict;</kbd>.) Thanks Nick :-)

	<p>Return to <a href="#TOC16.1">table of contents</a>

</p><hr><p>
<a name="A16.2"> 16.2 Is there something equivalent to <CODE>wish</CODE> in perl/Tk?</a>
</p><p>
The answer is yes.
<p>
The idea of <CODE>wish</CODE> is that you read from <KBD>&lt;STDIN&gt;</KBD> 
and evaluate each statement. The standard way to do this in perl/Tk is to use
the <KBD>tkpsh</KBD> script that comes in your <KBD>Tk-b&#35;/</KBD>
distribution. Another elegant way to get <KBD>wish</KBD> like behavior in 
perl/Tk is to use <b>rmt</b> which you can find in <kbd>perl5/Tk/demos</kbd> 
in your Tk-b&#35; distribution. 
When you run <b>rmt</b> you already have Tk.pm set up for you so
you can start typing things like <KBD>$mmm = new MainWindow;</KBD> <i>etc.</i>
at the <KBD>rmt:</KBD> prompt.  (This use belies the power of <b>rmt</b> which
is derived from Ousterhout's Tcl/Tk version of <b>rmt</b> [see section 27.2 of
his book]. <b>rmt</b> is capable of &quot;inserting Tk code&quot; into
simultaneously running Tk applications.)
<p>
A cruder way to get <CODE>wish</CODE>-like behaviour with perl/Tk is to run a 
&quot;perl shell&quot; and type in your usual commands, including 
<KBD>use Tk;</KBD> <i>etc.</i>  There is a script distributed with perl called 
<CODE>perlsh</CODE> which is written quite simply as:
<pre>
    #!/usr/bin/perl
     $/ = '';        # set paragraph mode
     $SHlinesep = "\n";
     while ($SHcmd = &lt;&gt;) {
         $/ = $SHlinesep;
         eval $SHcmd; print $@ || "\n";
         $SHlinesep = $/; $/ = ''; 
     }
</pre>
You can use this during code development to test out little snippets of code.
It helps to be an accurate typist and the <KBD>use strict;</KBD> is optional
here :-)
<p>
Hiroaki Kobayasi has a more sophisticated <kbd>wish</kbd> like perl/Tk
&quot;shell&quot; that is called EVA. It is available from:
<pre>
    <a href="ftp://ftp.sowa.is.uec.ac.jp/pub/Lang/perl5/Tk/">ftp://ftp.sowa.is.uec.ac.jp/pub/Lang/perl5/Tk/eva-*.tar.gz</a>
</pre>

	<p>Return to <a href="#TOC16.2">table of contents</a>

</p><hr><p>
<a name="A16.3"> 16.3. Is there a debugger specifically for perl/Tk?</a>
</p><p>
Not for the latest version - but the <KBD>-w</KBD> switch and <KBD>use
strict;</KBD> are always helpful with debugging as they provide informative
error messages. You can, of course, run under the regular debugger using:
<pre>
    perl -d <i>myscript</i>
</pre>
Gurusamy Sarathy 
<a href="mailto:gsar@engin.umich.edu">&lt;gsar@engin.umich.edu&gt;</a> 
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:
<pre>
    <a href="ftp://ftp.perl.com/pub/perl/ext/TK/Tkperldb-a1.tar.gz">ftp://ftp.perl.com/pub/perl/ext/TK/Tkperldb-a1.tar.gz</a>
</pre>
And Gurusamy Sarathy notes that the patch to bring the debugger up to date is 
available at:
<pre>
 You need a post 5.001m perl that has support for debugging closures. 
 Or you can simply apply:

   <a href="http://www-personal.umich.edu/~gsar/perl5.001m-bugs.patch">http://www-personal.umich.edu/~gsar/perl5.001m-bugs.patch</a>

 to 5.001m. (5.002beta includes all the fixes in the above patch).
</pre>
Note that a perl debugger may be invoked within your script with a line like:
<pre>
    $ENV{'PERL5DB'} = 'BEGIN { require Tkperldb }';
</pre>
See <a href="http://www.metronet.com/0/perlinfo/perl5/manual/perldebug.html">
<KBD>man perldebug(1)</KBD></a> for more help.
<p>
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:
<pre>
    perl -de 0
</pre>
Whereupon you must enter all the lines of a script including 
<KBD>use Tk;</KBD>. (Fancier file reads &amp; <KBD>eval</KBD>s are 
possible - but if you are getting that sophisticated why not 
create your own custom PERL5DB file?)
When using <KBD>perl -dwe 0</KBD> beware of the <i>emacs</i> like 



( run in 2.067 seconds using v1.01-cache-2.11-cpan-364913b4093 )