in reply to Re: Array of TK::Checkbuttons not acting appropriately
in thread Array of TK::Checkbuttons not acting appropriately
Alternatively, use the form of Tk::callback that lets you provide arguments to a sub. Here our anonymous sub takes two args -- a reference to a scalar which is the checkbox value, and a scalar which is the text of the checkbox.my $i=$t; $bill_table->Button(-text=>'Submit', -command=>sub{if ($checkboxvalue[$i] ==1){prin +t $f}}, )->pack;
Now, there's the issue of your Use of uninitialized value in numeric eq (==) .. That is because the checkbox values are either 1 or undef, so when you check <thecheckboxvalue>==1 it'll do either 1==1 (ok) or undef==1 (warning).$bill_table->Button(-text=>'Submit', -command=>[ sub{ my $valref = shift; my $valname=shift; if ($$valref ==1){print $valname} }, \$checkboxvalue[$t], $f, ], )->pack;
if( $foo ){ print $f } if( defined $foo ){ print $f } if( $foo && $foo==1){ print $f } if( defined $foo && $foo==1){ print $f }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Array of TK::Checkbuttons not acting appropriately
by rcseege (Pilgrim) on Oct 02, 2006 at 14:24 UTC | |
|
Re^3: Array of TK::Checkbuttons not acting appropriately
by mikasue (Friar) on Oct 02, 2006 at 13:23 UTC |