contact@solamen.fr has asked for the wisdom of the Perl Monks concerning the following question:
The following code leads to a strange behavior.
First pressing "Calculate" button prints the expected result: Uw=2.6.
Then if I press "Characteristics" button and close the Characteristics window, pressing again "Calculate" button leads to Uw=0 for the same values of independent variables! I tend to conclude that $window{xAf} is somehow considered as a character...
Could somebody please tell me what I am doing wrong?
use strict; use warnings; use Tk; my $roomTl; my %window = (xAf=>0.20); my $mw = new MainWindow( ); $mw->Button( -text => "\n Characteristics \n", -command => \&roomSub, )->pack(-fill => "x"); $mw->Button( -text => "\n Calculate \n", -background => "red", -command => \&designSub, )->pack(-fill => "x"); MainLoop; sub roomSub { if (! Exists ($roomTl)) { $roomTl = $mw->Toplevel( ); $roomTl->Entry( -textvariable => \$window{xAf}, )->pack(-fill => 'x'); } else { $roomTl->deiconify(); $roomTl->raise(); } } sub designSub { my $Uf = 13; my $Uw = $window{xAf} * $Uf; print "Uf = $Uf \t xAf = $window{xAf} \t Uw = $Uw \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl/Tk Problem with referenced variable in Entry
by choroba (Cardinal) on Nov 05, 2013 at 21:47 UTC | |
|
Re: perl/Tk Problem with referenced variable in Entry (bug)
by Anonymous Monk on Nov 05, 2013 at 23:34 UTC | |
by contact@solamen.fr (Novice) on Nov 06, 2013 at 13:06 UTC | |
by choroba (Cardinal) on Nov 06, 2013 at 13:55 UTC | |
|
Re: perl/Tk Problem with referenced variable in Entry
by eserte (Deacon) on Nov 06, 2013 at 17:15 UTC | |
by eserte (Deacon) on Nov 15, 2013 at 10:21 UTC |