Reputation: 175
I wanted to set a variable value based on tab switching in tkk:notebook
. Is there any options that can help me to achieve this?
I wanted to keep flag as 0 for default tab, and when user switches another tab make it flag as 1.
Here is my code, but didn't helped me:
ttk::notebook .top.d -padding 5
ttk::frame .top.d.f1;
ttk::frame .top.d.f2;
.top.d add .top.d.f2 -text "Tab A" -padding 5
.top.d add .top.d.f1 -text "TAB B" -padding 5
.top.d select .top.d.f1
ttk::notebook::enableTraversal .top.d
if {.top.d select .top.d.f2 } {
set flag 2
}
Thanks
Upvotes: 1
Views: 326
Reputation: 71558
I feel like you are trying to get the index of the current tab, and if that's so, then you can use:
.top.d index current
To get the index of the tab at any point in time (index is 0 based).
But if you really want to change the value of a variable upon tab change, you can use the virtual event <<NotebookTabChanged>>
:
bind .top.d <<NotebookTabChanged>> {
if {[.top.d select] == ".top.d.f2"} {set flag 2}
}
Everything above is on the manual.
Upvotes: 2