Bintuch has asked for the wisdom of the Perl Monks concerning the following question:

Kind Monks, I'm using Perl/Tk. How can iterate (for example, in order to configure their state) all the widgets in a specific Frame, for example? Thanks.

Replies are listed 'Best First'.
Re: Loop Widgets in Container
by choroba (Cardinal) on Apr 27, 2010 at 19:17 UTC
    Use $Frame->children.
      It does not operate as expected. My code:
      my $FG_FrameInit = $PageFG -> LabFrame( -label=>"In +itialize Device", -labelside=>"acrosstop", -borderwidth=>1, -relief=>"raised"); my $entry_FGDeviceAddress = $FG_FrameInit -> LabEntry( -lab +el=>"Address:", -background=>"white", -width=>15, -text=>"ASRL7::INSTR", -labelPack=>[-side=>"left"]); $balloon->attach($entry_FGDeviceAddress, -balloonmsg => "Device Addres +s"); my $btn_FGInitDevice = $FG_FrameInit -> Button( -text=> +"Init", -command=>\&InitFG); my @a = $FG_FrameInit->children(); print "$_," for(@a);
      Output:
      Tk::Frame=HASH(0x2228e0c),Tk::Label=HASH(0x221f384),
      What am I doing wrong?
        You do not use a Frame, but a LabFrame, which is a Label + a Frame.
Re: Loop Widgets in Container
by ~~David~~ (Hermit) on Apr 27, 2010 at 21:28 UTC
    You could store the children in an array instead of a scalar, and then iterate through the array.