in reply to text parser TkGUI ActiveState

Step 1) use Tk, Tkx is a headache,

Tk tips :)

perl Tk help, RFC: Learning Perl/Tk, Perl/Tk: For Beginners, Re^3: Tkx Search for dialog box for text input , Re: TclTk interface with Perl code, is it possible? , Re^2: GUI toolkit+designer for the perl newbie , Re: Easier GUI, Re: Should I use Perl/TK?, Re^2: need a popup gui stdin, Tk Tree Tutorial ( http://www.rtapo.com/tutorials/tk_tree.html ), some Tkx tutorial links, Tutorial http://theoryx5.uwinnipeg.ca/perltk/ and http://www.perl.com/pub/1999/10/perltk/, http://perltk.org/, http://web.archive.org/web/20100310202528/http://theoryx5.uwinnipeg.ca/perltk/, How to RTFM Tk Tutorials

#!/usr/bin/perl -- use strict; use warnings; use Tk; Main( @ARGV ); exit( 0 ); sub Main { return MainTk( @_ ); } sub MainTk { my $mw = Tk::MainWindow->new( -title => "Log Viewer", ); $mw->Label( -text => "DEVICE:" )->grid( -column => 1, -row => 1, -sticky => "e", -padx => 5, -pady => 5, ); $mw->Label( -text => "START TIME:" )->grid( -column => 1, -row => 2, -sticky => "e", -padx => 5, -pady => 5, ); $mw->Label( -text => "END TIME:" )->grid( -column => 3, -row => 2, -sticky => "e", -padx => 5, -pady => 5, ); $mw->Label( -text => "VALUE" )->grid( -column => 1, -row => 3, -sticky => "e", -padx => 5, -pady => 5, ); my( $device, $stime, $etime, $value ) = 1 .. 10; $mw->Entry( -width => 14, -textvariable => \$device, )->grid( -column => 2, -row => 1, -sticky => "we", -padx => 5, -pady => 5, ); $mw->Entry( -width => 10, -textvariable => \$stime, )->grid( -column => 2, -row => 2, -sticky => "we", -padx => 5, -pady => 5, ); $mw->Entry( -width => 10, -textvariable => \$etime )->grid( -column => 4, -row => 2, -sticky => "we", -padx => 5, -pady => 5, ); $mw->Entry( -width => 50, -textvariable => \$value, )->grid( -column => 2, -row => 3, -columnspan => 3, -sticky => "we", -padx => 5, -pady => 5 ); #~ $mw->Button( -text => "RUN", -command => [ \&onRun, \$etime, \$ +stime, \$value, \$device ] )->grid( my $onRun = sub { print "$etime $stime $value $device\n"; }; $mw->Button( -text => "RUN", -command => $onRun, )->grid( -column => 1, -row => 5, -columnspan => 4, -sticky => "we", -padx => 5, -pady => 5, ); $mw->MainLoop; } ## end sub MainTk sub onRun { my( $etimeref , $stimeref, $valueref, $deviceref ) = @_; use Data::Dump qw/ dd /; dd( { map {; "$_" => "$$_" ;} @_ }); } ## end sub onRun

Replies are listed 'Best First'.
Re^2: text parser TkGUI ActiveState
by jasonwolf (Sexton) on Aug 12, 2015 at 12:46 UTC

    Thank you for your post, and suggestions on my code. I am able to understand most of the code; however, what does the following do?

    my( $device, $stime, $etime, $value ) = 1 .. 10;

      jasonwolf:

      You can normally answer a question like this yourself, simply by trying it:

      $ cat x.pl use strict; use warnings; my ($m,$n,$o,$p) = 1 .. 10; print "m=$m, n=$n, o=$o, p=$p\n"; $ perl x.pl m=1, n=2, o=3, p=4

      So, it assigns 1 to the first variable, 2 to the second, ... up through the fourth. Then it throws the rest of the list items away.

      By playing with the program (changing the number of variables, and the size of the list), you could then deduce the general behavior.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.