Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Tk tearoff toplevel IDs

by {NULE} (Hermit)
on Jun 07, 2002 at 21:21 UTC ( [id://172676]=note: print w/replies, xml ) Need Help??


in reply to Tk tearoff toplevel IDs

Hey cadphile,

Regardless of why you want to be able to find children of a given widget the children method of a widget can provide interesting information about how Tk's heirarchies work.

Included here is an example of how to tell exactly how a tear off menu is parented. You can see that when you have the menu torn off an additional child of the main window becomes available that is of type Tk::Menu.

#! /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;
Good luck,
{NULE}
--
http://www.nule.org

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://172676]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2024-04-16 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found