Dear Monks, I want to create a GUI allowing the user to apply several different processing steps to a string. For each step, there are some settings to adjust (in this simple example the option to export the data after the processing step). My general proble is caused by the fact, that the widgets are created in a loop. I don't know how to do specific callbacks to other widgets also created in this loop. You may understand my problem better by running this code:
#! /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}); }

In reply to Perl::Tk Problems with creating widgets using a loop by Microcebus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.