Reputation: 1860
I am trying to bind an event to a tab opening in a tcl tk application. I've gotten the virtual event NotebookTabChanged to bind to anytime a tab is changed, however I do not know how to get the tab that was selected.
Below is the idea of what I want to do. Obviously, its not real tcl tk code.
ttk::notebook .gui.tframe3.tpanedwindow4.notebook0
bind .gui.tframe3.tpanedwindow4.notebook0 <<NotebookTabChanged>> {GUITabOpen %w}
ttk::frame .gui.tframe3.tpanedwindow4.notebook0.tframe1 -borderwidth {0} -relief {flat} -width {30} -height {30}
...
proc GUITabOpen { {w 0} } {
if {##The tab selected is tframe1###} {
#do some action related to tframe1
}
Upvotes: 1
Views: 927
Reputation: 137637
The only useful information in the <<NotebookTabChanged>>
virtual event is what ttk::notebook
widget it is talking about (the %W
substitution, capital W). To find out what tab is the new current tab, you've got to ask the widget in the event.
$theNotebookWidget index current
Though to get the name of the widget associated with the current tab, you actually use the select
method without further arguments:
$theNotebookWidget select
From the manual:
pathname select ?tabid?
Selects the specified tab. The associated slave window will be displayed, and the previously-selected window (if different) is unmapped. If tabid is omitted, returns the widget name of the currently selected pane.
Upvotes: 3