http://purl.org/tcl/home/man/tcl8.4/TkCmd/toplevel.htm
DKF notes that, "toplevels on UNIX/X are really a collection of several windows; the window you draw on (which is what winfo id will tell you), another window for a menubar (if you've installed one) and a third one to contain the other two. If you do 'xwininfo -tree' you should be able to find out what's *really* going on."
Martin Lemburg: How can I detect if a widget is a toplevel? If I ask a widget for its class, this will fail e.g. at the root widget, because it doesn't return "Toplevel", but "Wish83". And toplevels could be given a class differing from "Toplevel" during their creation. So ... how can I detect a toplevel?
[winfo toplevel .]
returns . whereas
[winfo toplevel .someothertoplevel]
returns .someothertoplevel
MGS - In other words:
proc istoplevel {W} { return [string equal [winfo toplevel $W] $W] }
MGS [2003/05/08] - Actually, does a menu count as a toplevel? Probably not (in many cases). So how about this? Toplevels can have a -menu option ...
proc isToplevel {W} { return [expr {[string equal [winfo toplevel $W] $W] && ![catch {$W cget -menu}]}] }
Category Widget | Category Command | Tk syntax help | Arts and Crafts of Tcl-Tk Programming