The following methods deal with the
ancestors or children of widgets and how they were created:
These methods tend to return either a widget reference or a string. A string is the Tcl-like name of a widget. Tcl uses string pathnames to reference widgets, with periods as pathname separators, and is how Tcl’s widget hierarchy is defined. This is analogous to how Unix uses a forward slash as its pathname separator.
In Tcl, the MainWindow is always
“.”. From that point on, it’s the
programmer’s job to name widgets that reflect the
application’s widget hierarchy. So,
might refer to the first Frame widget created as a child of the
.frame1 might refer to the second, and
so on. The programmer might call the first Button under the first
.frame.quit_button; this is the fully
qualified pathname. The name its parent knows this Button by is
quit_button. This name is the leaf part of
the pathname, or, in Unix terminology, the basename.
As Perl/Tk programmers, we seldom explicitly assign a pathname to our widgets, but pTk does so on our behalf. Now you know what’s happening when you see string pathnames. Ideally, we like to see real Perl object references, but sometimes Perl/Tk’s Tcl underpinnings peek through.
To determine the children of a widget
(usually a Toplevel or a Frame), use the
childrenmethod, which returns a list of widget references: ...