当使用panedwindow时,您应该能够在内容窗格之间切换,方法是删除一个框架并添加一个新框架来替换它。有关ttk :: panedwindow的forget
和add
/insert
命令的说明,请参见this manual page。
示例代码:
package require Ttk
# Create a panedwindow
ttk::frame .f
ttk::panedwindow .f.pane -orient vertical
# Create three panes
ttk::frame .f.pane.one -height 50 -width 50
ttk::label .f.pane.one.l -text "Number one"
pack .f.pane.one.l
ttk::frame .f.pane.two -height 50 -width 50
ttk::label .f.pane.two.l -text "Number two"
pack .f.pane.two.l
ttk::frame .f.pane.three -height 50 -width 50
ttk::label .f.pane.three.l -text "Number three"
pack .f.pane.three.l
# Add frames one and two to the panedwindow
.f.pane add .f.pane.one
.f.pane add .f.pane.two
pack .f.pane -expand 1 -fill both
pack .f -expand 1 -fill both
# Replace pane one with pane three
.f.pane insert 1 .f.pane.three
.f.pane forget 2
您可以修改这个代码,根据自己的需要。只需创建您可能需要的所有视图,然后根据需要将其交换出来。
来源
2010-09-03 20:33:38
bta
+1用于阅读其他SO答案和跟进 – 2010-09-06 08:47:30