#!/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