in reply to Re^3: Perl Tk label references
in thread Perl Tk label references
use Tk; use strict; use warnings; use Data::Dumper; my $mw = MainWindow->new(); my %work = ( "VM-1" => "da923", "VM-2" => "dz427"); main_display(\%work); MainLoop; # ----------------------------------------------------- sub main_display { my $ref_hash = shift(@_); my $lab1 = $mw->Label(-textvariable => \$ref_hash->{'VM-1'}, -relief => 'sunken', -width => 10, )->pack(); my $lab2 = $mw->Label(-textvariable => \$ref_hash->{'VM-2'}, -relief => 'sunken', -width => 10, )->pack(); my $but = $mw->Button(-text=>'clear', -command=> sub{ $ref_hash->{'VM-1'}=""; $ref_hash->{'VM-2'}=""; $mw -> update; } )->pack(); }
|
|---|