在 tcl tk gui 中隐藏和显示框架
我想制作一个可以隐藏和显示交替的框架。问题是 Tk 不提供任何隐藏/解包命令。我使用 vtcl,有一个选项“Window hode”,它仅隐藏顶层窗口。现在我想隐藏一个框架,然后再次显示同一框架。它可以被认为是拆开一帧并显示另一帧。我的代码可以是这样的:
proc show1hide2 { } {
global i top
if {$i == 1} {
unpack $top.frame1
pack $top.frame2
set i 0
} else {
unpack $top.frame2
pack $top.frame1
set i 1
}
}
在此过程中,$top.frame1
和$top.frame2
之前已填充,$i
的值为因此,当调用此过程时,$top.frame1
和 $top.frame2
会交替显示。我想知道是否存在像 unpack
这样的命令可以帮助我做到这一点?顺便说一下,这里的unpack
只是一个想法。
I want to make a frame that can be hidden and shown alternatively. The problem is Tk does not provide any hide/unpack command. I use vtcl and there is an option "Window hode" which only hides the window at top level. Now I want to hide a frame and later show the same frame again. It can be thought of as unpacking one frame and showing the other. My code can be like this:
proc show1hide2 { } {
global i top
if {$i == 1} {
unpack $top.frame1
pack $top.frame2
set i 0
} else {
unpack $top.frame2
pack $top.frame1
set i 1
}
}
In this procedure, $top.frame1
and $top.frame2
were previously filled and value of $i
is toggled hence $top.frame1
and $top.frame2
are shown alternatively when this proc is called. All, I want to know is that does there exists and command like unpack
which can help me do this? By the way, unpack
here is just an idea.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 packforget 命令可能就是您正在寻找的:
I think that the pack forget command might be what you are looking for: