Re: BWidget::NoteBook and binding to the 'tab-raise' event




Hi,

You can use the '-raisecmd' and '-leavecmd' options when inserting a new page
like this to call a proc when entering or leaving a page:

package require BWidget

set nb [NoteBook .nb]
pack .nb -fill both -expand true

proc my_raise_cmd { nb page } {
set ctxt [$nb itemcget $page -text]
$nb itemconfigure $page -text [string toupper $ctxt]
}

proc my_leave_cmd { nb page} {
set ctxt [$nb itemcget $page -text]
$nb itemconfigure $page -text [string tolower $ctxt]
}

$nb insert end tab_one -text tab_one \
-raisecmd [list my_raise_cmd $nb tab_one] \
-leavecmd [list my_leave_cmd $nb tab_one]
$nb insert end tab_two -text tab_two \
-raisecmd [list my_raise_cmd $nb tab_two] \
-leavecmd [list my_leave_cmd $nb tab_two]
$nb insert end tab_three -text tab_three \
-raisecmd [list my_raise_cmd $nb tab_three] \
-leavecmd [list my_leave_cmd $nb tab_three]
$nb insert end tab_four -text tab_four \
-raisecmd [list my_raise_cmd $nb tab_four] \
-leavecmd [list my_leave_cmd $nb tab_four]
.