|
Tabset
The tabset iwidget contains a set of tab buttons. It displays the tabs in a row or column, depending on the-tabpos option. When a tab is click, it is brought forward, and the other tabs are set behind the active tab. This is seen in many tabnotebook type widgets, and in fact this iwidget is used in the Tabnotebook iwidget. This iwidget is not a general purpose widget, but is used to construct other iwidgets.
For further information, see the Tabset
manpage
Components: canvas hull
|
wm title . "Tabset Example"
set chapters [list introduction chapter_1 chapter_2]
##
## Supporting procedure to show
## the different pages
##
proc showTab {item} {
.nb select $item
}; # end proc showTab
##=========================================================
## Create a Tabset iwidget.
##
## This will control the paging. This
## is basically constructing a tabnotebook,
## and is easier to implement using the
## tabnotebook iwidget, but this example
## is used for illustration purposes.
##=========================================================
##
iwidgets::tabset .ts \
-equaltabs 0 \
-tabpos n \
-backdrop gray \
-raiseselect 1 \
-start 1 \
-angle 0 \
-bevelamount 6 \
-command {showTab}
pack .ts \
-fill both \
-expand true \
-side top
##
## Create a Notebook iwidget
##
##
iwidgets::notebook .nb \
-height 200 \
-width 300
pack .nb \
-fill both \
-expand true \
-side top
##
## Fill in the different pages with
## a text widget, and some text. The
## pages can be filled in with any
## widget.
##
foreach p $chapters {
##
## Construct the page
##
set page($p) [.nb add -label $p]
text $page($p).text \
-setgrid 1 \
-background black \
-foreground green
pack $page($p).text \
-fill both \
-expand true
$page($p).text tag configure $p \
-underline 1 \
-foreground yellow
regsub -all {_} $p { } t
set t [string totitle $t]
##
## Add a tab for this page to the
## tabset iwidget
##
.ts add \
-label $t
##
## Insert some text into the
## the pages
##
$page($p).text insert end \
"Here is where you will find all the info for "
$page($p).text insert end $t $p
}; ## end foreach chapters
##
## Select the first page; zero based
##
.ts select 0
|
Download this sample code |
|