Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Move a frame between top-level windows

13 views
Skip to first unread message

Jingzhao Ou

unread,
Sep 19, 2005, 1:08:18 AM9/19/05
to
Dear all,

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

Bryan Oakley

unread,
Sep 19, 2005, 1:12:03 AM9/19/05
to
Jingzhao Ou wrote:
> Dear all,
>
> 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.
>

At present, no, it is not possible.

Matthew Braid

unread,
Sep 19, 2005, 2:47:42 AM9/19/05
to

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

cheng...@yahoo.com

unread,
Sep 19, 2005, 9:31:38 AM9/19/05
to
Could be done with embedded windows (Tcl8.5/Windows)

Chengye Mao

Jingzhao Ou

unread,
Sep 19, 2005, 9:29:02 PM9/19/05
to
Dear Mathew,

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".

Jingzhao Ou

unread,
Sep 19, 2005, 9:30:30 PM9/19/05
to
Dear Chengye,

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"?

cheng...@yahoo.com

unread,
Sep 20, 2005, 12:32:28 PM9/20/05
to
Take a look at the Tk helps on Wish, Frame and Toplevel and pay
attention on -use and -container options. Please also take a look at
tkFrame.c, tkWinEmbed.c and tkWinWm.c for the embeding implementation.
You may find additional info by searching "embedded" in this news
group.

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

Jingzhao Ou

unread,
Sep 20, 2005, 1:30:14 PM9/20/05
to
Dear 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!

cheng...@yahoo.com

unread,
Sep 20, 2005, 2:50:34 PM9/20/05
to
I'm using the latest Tcl8.5a4. What Tcl version are you using?

Chengye

Jingzhao Ou

unread,
Sep 20, 2005, 4:04:45 PM9/20/05
to
Dear 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.

Eckhard Lehmann

unread,
Sep 21, 2005, 4:06:01 PM9/21/05
to
Jingzhao Ou wrote:

> 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 Klein

unread,
Sep 21, 2005, 4:03:45 PM9/21/05
to
the [tabset] widget from blt allow reparenting.
i.e you can rip single tabs from the tabset and
display them as toplevel windows and back again
into the tabset.

uwe


Jingzhao Ou

unread,
Sep 22, 2005, 5:35:35 AM9/22/05
to
Hi, Eckhard,

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

cheng...@yahoo.com

unread,
Sep 22, 2005, 11:29:43 AM9/22/05
to
Copied your scripts and tested in my Tcl85, it worked as expected. My
windows is XP/SP2 and tcl_patchLevel is 8.5a4. You may get the latest
source from sourceforge.net.

Chengye Mao

ouj...@gmail.com

unread,
Sep 22, 2005, 2:21:06 PM9/22/05
to
Dear Chengye,

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

Jingzhao Ou

unread,
Sep 23, 2005, 1:06:51 AM9/23/05
to
Hi, Uwe,

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

Uwe Klein

unread,
Sep 23, 2005, 3:30:49 AM9/23/05
to
Jingzhao Ou wrote:
> Hi, Uwe,
>
> 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!

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?

Eckhard Lehmann

unread,
Sep 24, 2005, 10:15:20 AM9/24/05
to
Jingzhao Ou wrote:
> Hi, Eckhard,
>
> 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

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

Larry Smith

unread,
Sep 25, 2005, 1:42:53 PM9/25/05
to
Eckhard Lehmann wrote:
> So it is not possible to do clipping/unclipping at runtime
> with that in Tk8.4.

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

0 new messages