#! /usr/bin/perl -w use strict; use Tk; # Create the main window my $w; $w->{main} = MainWindow->new; $w->{mb} = $w->{main}->Menubutton( -text => 'Menu' )->pack; $w->{mb}->command( -label => 'print kids', -command => [ \&find_kids, $w ] ); $w->{main}->Button( -text => 'print kids', -command => [ \&find_kids, $w ] )->pack; sub find_kids { my $w = shift; # Find all the children of main. print "***** new report *****\n"; foreach ($w->{main}->children) { print "1) $_\n"; # find all the grandchildren foreach ($_->children) { print "2)\t$_\n"; # find the great grand kids... foreach ($_->children) { print "3)\t\t$_\n"; } } } } MainLoop;