I am wondering if the following is possible.
I have a frame widget which contains some other widgets. I hope that by
clicking on some button, I can move the frame between two top-level
windows.
Basically, I can see that there are quite application GUIs which
provide docking/undocking capablity for their windows. I am trying to
see how it can easily be implemented in Tk.
Any reference or sample code (however simple it is) are highly
appreciated.
Thanks a lot!
Best regards,
Jingzhao
At present, no, it is not possible.
You used to be able to do this with $mw->Capture and $mw->Release (to
swap a frame between being a frame and a toplevel) but newer versions of
perl/Tk have borken this (it's still there, it just crashes instead of
working).
In fact, the only reference to it left in the source code is in Tk::Menu
for cloning, but its wrapped in an impossible if so never gets used.
Unfortunately now you have to make copies of everything all over the
place. Not very pretty.
MB
Chengye Mao
Would you please give me some more details on how to make copies of the
stuffs in a frame?
It seems to me that I can find out what are contained by a frame using
"winfo". Can you tell me what I should do after that? I am wondering if
I can unpack these widgets (using "pack forget"), change the paths of
the widgets (how?), and pack them again using "pack".
That is great news. I am using Tcl8.5 on WinXP boxes. Can you tell me
where I can find out the information about "embedded windows"?
Below are a few lines of testing scripts for creating a frame container
to embed a toplevel window:
# creating a frame container
frame .f -container 1
pack .f -expand 1 -fill both
# creating a toplevel
toplevel .s -bg red
# find id of the container
set id [winfo id .f]
# embed the toplevel into the container
.s config -use $id
# unembed the toplevel
.s config -use {}
Regards,
Chengye Mao
http://www.geocities.com/~chengye
Thanks a lot for your kindly reply. I have tried your code on
ActiveTcl8.5.0.0beta-3 on WinXP. Embeddeding the toplevel works fine,
which is perfect. However, unembedding does not work. Also, I need to
change the code like to the following into to make it work:
==========================
# creating a toplevel
toplevel .s -bg red -use $id
==========================
I checked out the Tk manual and found the following:
==========================
Command-Line Name: -use
......
This option may not be changed with the configure widget command.
==========================
Can you telll me what I am missing here? I am so close already.
Thanks a lot!
Best regards,
Jingzhao
PS: I have checked out XBit, which is very impressive!
Chengye
I am using ActiveTcl8.5.0.0beta-3. I tried the "-use" option. It
doesn't seem to be quite stable in this version. Other widgets will
also report error when I use this option.
I will try the same version as you mentioned.
> Basically, I can see that there are quite application GUIs which
> provide docking/undocking capablity for their windows. I am trying to
> see how it can easily be implemented in Tk.
Check out the -container option for frame. It is available already in
Tk-8.4, and it seems like this is what you need.
The only problem is, that it can not be configure'd later... So if you
are seeking for this, you will have to do it manually, e.g. by creating
and managing/destroying toplevels and pack/"pack forget" etc.
Eckhard
uwe
It does seem that the -container option for frame is what I am looking
for. However, I cannot find out any example on "creating and
managing/destroying toplevels and pack/"pack forget" etc. I tried the
following as suggested by Chengye. For Tk-8.4, it does not work at all.
For Tk-8.5, I don't know how to turn .s back to a toplevel window.
Also, when I click the button, I get the following error in a pop-up
window. :-(
Fatal Error in Wish
TkpGetOtherWindow couldn't find window
=========================
# creating a frame container
frame .f -container 1
pack .f -expand 1 -fill both
# find id of the container
set id [winfo id .f]
button .b -text Ok -command exit
pack .b -side bottom
Chengye Mao
I just compiled the latest Tcl and Tk. It works very well and is
exactly what I am looking for.
Thanks for all the replied.
Best regards,
Jingzhao
I just checked out BLT. It is so powerful! I just cannot understand
quite well why such a great project is not very active recently. A huge
pity!
Best regards,
Jingzhao
I love BLT for the vector and graph stuff, the [table] packer was my
preferred way of placing widgets.
uwe
PS: I never understood why especially the vector (arithmethic) stuff
was never taken into tcl.
My assumption was that there where historic/personal reasons?
Ahhiia - my fault... for the -in option to pack, the widgets have to be
created as childs of the widgets where they are to be pack'ed. Okay,
this is not sufficient for clipping/unclipping a frame to/from the main
application.
With the -container option, a frame can serve as container for a
toplevel. The option exists already in Tk8.4 and is described in
"Practical Programming..". The only problem is, that the frame has to be
*constructed* already with -container, and the toplevel has as well to
be *constructed* with the -use option. It is - at least in Tk8.4 - not
possible to configure the frame's -container or the toplevel's -use
option later. So it is not possible to do clipping/unclipping at runtime
with that in Tk8.4.
But this might have been changed in Tk8.5
Eckhard
Can you solve it with Xnest? It would be simple to add the -in
to the source code if it didn't already have it.
--
.-. .-. .---. .---. .-..-.|Experts in Linux: www.WildOpenSource.com
| |__ / | \| |-< | |-< > / |"Making the bazaar more commonplace"
`----'`-^-'`-'`-'`-'`-' `-' |Check out my new novel: "Cloud Realm" at:
home:www.smith-house.org:8000|<-this url + /books/list.html