Mega Code Archive

 
Categories / Perl / GUI
 

Link a subroutine with a button action

#!/usr/local/bin/perl -w use Tk; use strict; my %info; my $mw = MainWindow->new; $mw->title("Data Entry"); my $f = $mw->Frame->pack(-side => 'bottom'); $f->Button(-text => "Exit",             -command => sub { exit; })->pack(-side => 'left'); $f->Button(-text => "Save",            -command => sub {             print "asdf";           })->pack(-side => 'bottom'); MainLoop;