
=head1 NAME

B<wptk> - a poor man's windowing shell (wish) for Perl/Tk

=head1 SYNOPSIS

=over 4

=item B<wptk> I<pTk-program-file> [ Tk options ]

Run the Perl/Tk program contained in the file I<pTk-program-file>, 
passing it optional Tk options.

=item I<pTk-program-file> [ Tk options ]

Run an executable Perl/Tk program file as above with its first line
in standard "shebang" format:

#!/usr/local/bin/wptk -perlargs

=back

=head1 DESCRIPTION

B<wptk> obviates the need to write standard Perl/Tk boiler-plate code.  Every
pTk program starts with:

 use Tk;
 ...
 $mw = Mainwindow->new;
 ...
 MainLoop;

B<wptk> provides this template code for you automatically, then sources
your pTk code just before the MainLoop statement.

By default, -w is enabled.  You can change this in I<wptk.c.template>.

The default Perl/Tk template is this:

 ---
 use Carp;
 use Tk;
 use vars qw/ $mw /;
 use strict;

 if ( $ARGV[0] eq '-' ) {
     my $stdin = "/tmp/wptk.$$";
     open F, ">$stdin" or die "wptk.template: cannot write '$stdin': !";
     while ( $_ = <STDIN>  ) {
         print F $_;
     }
     close F or die "wptk.template: cannot close $stdin: $!";
     $ARGV[0] = $stdin;
 }
 if ( not (-s $ARGV[0]) ) {
     print STDERR "wptk: No such file '$ARGV[0]'.\n";
     exit 1;
 }

 $mw = MainWindow->new;
 $mw->title($ARGV[0]);
 $mw->waitVisibility;

 my $stat = do $ARGV[0];
 if ( not defined $stat and $@) {
     print "$@\n";
     $mw->destroy;
     exit 2;
 };

 MainLoop;
---

By default the MainWindow is B<$mw>, which can be changed in the
above template.

=head1 EXAMPLE

 #!/usr/local/bin/wptk

 use Tk::widgets qw/Trace TraceText/;
 use strict;

 my $tt = $mw->Scrolled( 'TraceText', -textvariable => \my $frog )->grid;
 $tt->focus;

 $mw->traceVariable( \$frog, 'wu', [ \&tracefrog, $mw, \$frog ] );

 $frog = "Frogs lacking lipophores are blue.";

 my $d =  $mw->Button( -text => 'Destroy', -command => [ destroy => $tt ] );
 my $q =  $mw->Button( -text => 'Quit',    -command => \&exit );
 $d->grid( $q );

 sub tracefrog {

     my( $index, $value, $op ) = @_;

     print "Final " if $op eq 'u';
     print "User trace: $value";
     return $value;

 }

=head1 BUGS

 . Doesn't search PATH for the Perl/Tk input file.
 . Leaves scratch files in /tmp IFF input is standard input.

=head1 AUTHOR

sol0@Lehigh.EDU

Copyright (C) 2003 - 2004, Steve Lidie. All rights reserved.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=head1 KEYWORDS

wish, Perl/Tk, Tcl/Tk, windowing shell

=cut
