如何禁用 ttk::notebook 中的特定选项卡

问题描述:

当用户选择另一个选项卡时,需要禁用特定选项卡.我无法使用以下代码实现它.

Need to disable particular tab, when user select the other one. I am not able to achieve it using following code.

选项卡仍保持启用状态.也试过 configure -state disabled 但抛出错误.

Tab still remains enabled. also tried configure -state disabled but throwing error.

ttk::notebook .top.d -padding 5
ttk::frame .top.d.f1;
ttk::frame .top.d.f2;
.top.d add .top.d.f2 -text "East" -padding 5
.top.d add .top.d.f1 -text "West" -padding 5
.top.d select .top.d.f1
ttk::notebook::enableTraversal .top.d
.top.d index .top.d.f2
##set vf [ttk::frame .top.d.f1]
bind .top.d <<NotebookTabChanged>> {
    if {[.top.d select] == ".top.d.f2"} {
        set flag 2
        .top.d.f1  state disabled
        puts $flag
    }
}

请建议正确的语法.

尝试

.top.d tab .top.d.f1 -state disabled

(路径名是标识选项卡的一种方式;也可以使用索引号.)

(The path name is one of the ways to identify a tab; index number could be used as well.)

文档:ttk::notebook