Embedded Toplevels

Tk has the ability to embed a toplevel inside another, or inside a frame. The -use and -container options are used for this, along with winfo id. For example:

 toplevel .top -container true
 toplevel .embed -use [winfo id .top]

or:

 frame .f -container true
 toplevel .embed -use [winfo id .f]

This can also work across processes on UNIX (and possibly Windows). The wish application also takes a -use option which works in the same way (the root "." window becomes embedded). On MacOS X, however, this embedding is only supported within a single process (so, for instance the -use option to wish will not work). Jim Ingham writes on the tcl-mac mailing list:

"So I talked with some folks who work on the MacOS X WindowServer, and they said that there is currently no way to get a window ID that will work across processes. So -use will only work in one process on OS X."

NEM.


An interesting question is: Can this mechanism allow a widget hierarchy created under toplevel a to be moved under a different toplevel? An example would be a complex app main window which includes a frame holding a text widget and a bunch of other controls where you want the ability to pull that frame into its own toplevel. If I make the frame a toplevel can I do it? RT

NEM I don't think you can change the -use option of a toplevel after creation. It would be neat to have frames which you could "tear-off" from an application into a separate window, but I can't immediately see how to do it. Problem is that you would (currently) have to destroy the toplevel, and then recreate it without the -use (or with a different id). This would destroy all the sub-widgets though, so doesn't gain anything on other methods.

... how does BLT do this in their 'tabnotebook1.tcl' demo?

NEM See TIP 125: Adding wm toplevel command: [L1 ]


XAN: Both the BLT "container" documentation and this page seem to suggest the ability to embed toplevels on Microsoft Windows. However, there is a dearth of information on how to do this successfully. In fact, it doesn't appear at all clear that it is possible to do so unless you're embedding another TK application that you've created.

I kmow that you can "host" application windows with optcl if the target application provides a COM component to do so. But the waters are murkier when it comes to reparenting a "dumb" toplevel. If anyone that either knows about this or has tried this can comment, it would be greatly appreciated and probably helpful to others. Is it possible to take, say, calc.exe and embed the toplevel window into a TK window? If not, why not?