tags:

views:

70

answers:

2

The following code works fine. It displays a panedwindow, with a blue box on top and a green box below:

panedwindow .root -orient vertical -showhandle true -background red
frame .top -background blue -width 100 -height 100
frame .bot -background green -width 100 -height 100
.root add .top .bot
pack .root -expand true -fill both

However, when I move the panedwindow command down, things stop working. The top, blue box is not shown. Instead, the red of the panedwindow itself shines through:

frame .top -background blue -width 100 -height 100
panedwindow .root -orient vertical -showhandle true -background red
frame .bot -background green -width 100 -height 100
.root add .top .bot
pack .root -expand true -fill both

Why does this happen? Can a panedwindow really only manage widgets that were created after it? I've seen similar behavior with the packer, where it will refuse to pack widgets -in widgets that came later.

+2  A: 

Wow, it's been a while since I've even thought about Tcl/Tk. Thanks for the trip down memory lane. :)

According to this link, the default stacking order of sibling widgets is the order in which they were created, not the order they are packed. In essence, .top, .bot, and .root are all siblings of each other because they are at the same level in the widget hierarchy, i.e., they all 'hang' off the same parent ('.' in this case). I expect if you move the panedwindow command down one more line, you won't see the green box either. I think if you were to rename .top and .bot to .root.top and .root.bot, respectively, that might fix the issue you're seeing because that would make them children of the .root parent.

Hope this helps.

Matt Davis
Thanks for the very concise, very useful response! I'm just getting started with Tcl/Tk, and it's great to get help from somebody who knows what they're doing.
Daniel Yankowsky
+7  A: 
Eric Melski
It seems obvious now that I look at it. Thanks for the help!
Daniel Yankowsky