Microcebus has asked for the wisdom of the Perl Monks concerning the following question:
#! /usr/bin/perl -w use Tk; $mw=MainWindow->new(); @type_of_processing=("type1","type2","type1","type1","type2"); $step_no=0; foreach(@type_of_processing) { $step_no++; if($_ eq "type1") { type1_settings(); } elsif($_ eq "type2") { type2_settings(); } } MainLoop; sub type1_settings { $label{$step_no}=$mw->Label(-text=>"This is processing step no. $s +tep_no. (type1)")->pack; $entry{$step_no}=$mw->Entry(-width=>20,-state=>'disabled')->pack; $checkbutton{$step_no}=$mw->Checkbutton ( -text=>"export results to: ", -variable=>\$status, -command=>sub { if($status==1) { $entry{$step_no}->configure(-state=>'normal') } else { $entry{$step_no}->configure(-state=>'disabled') } } )->pack(-before=>$entry{$step_no}); } sub type2_settings { $label{$step_no}=$mw->Label(-text=>"This is processing step no. $s +tep_no. (type2)")->pack; $entry{$step_no}=$mw->Entry(-width=>20,-state=>'disabled')->pack; $checkbutton{$step_no}=$mw->Checkbutton ( -text=>"export results to: ", -variable=>\$status, -command=>sub { if($status==1) { $entry{$step_no}->configure(-state=>'normal') } else { $entry{$step_no}->configure(-state=>'disabled') } } )->pack(-before=>$entry{$step_no}); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl::Tk Problems with creating widgets using a loop
by kcott (Archbishop) on Oct 14, 2010 at 10:30 UTC | |
|
Re: Perl::Tk Problems with creating widgets using a loop
by thundergnat (Deacon) on Oct 14, 2010 at 14:56 UTC | |
by Microcebus (Beadle) on Oct 15, 2010 at 09:16 UTC |