wm title . "Notebook Example" set chapters [list introduction chapter_1 chapter_2] ## ## Create a scrollbar to scroll through ## the notebook pages. ## scrollbar .sb \ -orient horizontal \ -command ".nb view" pack .sb \ -fill x \ -side bottom ##========================================================= ## Create a Notebook iwidget ## ## Note: that the -height and -width ## should be specified to get the ## desired results (notebook visible) ##========================================================= ## iwidgets::notebook .nb \ -scrollcommand ".sb set" \ -height 100 \ -width 200 pack .nb \ -fill both \ -expand true \ -side bottom ## ## Fill in the different pages with ## a text widget, and some text. The ## pages can be filled in with any ## widget. ## foreach p $chapters { ## ## Contruct the page ## set page($p) [.nb add -label $p] text $page($p).text \ -setgrid 1 pack $page($p).text \ -fill both \ -expand true $page($p).text tag configure $p \ -underline 1 \ -foreground blue regsub -all {_} $p { } t ## ## Insert some text into ## the page ## $page($p).text insert end \ "Here is where you will find all the info for " $page($p).text insert end [string totitle $t] $p }; ## end foreach chapters pages ## ## Select the first page; zero based ## .nb select 0 ## ## Create a mechanism to page ## through the notebook. Will create ## some labels that represent chapters ## in a book, and bind these to page ## through the notebook ## frame .topframe \ -relief groove \ -bd 4 pack .topframe \ -fill x ## ## Loop through the chapters list ## and create a label for each chapter ## foreach c $chapters { regsub -all {_} $c { } t label .topframe.$c \ -text [string totitle $t] \ -font {helvetica 12 underline} \ -justify left pack .topframe.$c \ -fill x \ -expand true \ -anchor s bind .topframe.$c <1> ".nb select $c" }; ## end foreach label chapters