in reply to Re^2: Perl Tk label references
in thread Perl Tk label references
I was able to fix one problem. the Label reference syntax was wrong. The correct way was \$$ref_hash{'VM-1'}. But the clear of the hash when I click on the "clear" button still does not update my Label??
use Tk; require Tk::Entry; require Tk::Button; 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} = (); $mw -> update; }] )->pack(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl Tk label references
by pryrt (Abbot) on Nov 10, 2016 at 22:17 UTC | |
by pryrt (Abbot) on Nov 10, 2016 at 22:20 UTC | |
by thimes (Acolyte) on Nov 10, 2016 at 22:41 UTC | |
|
Re^4: Perl Tk label references
by Marshall (Canon) on Nov 10, 2016 at 22:52 UTC |