notebook - create and manipulate notebook widgets
notebook pathName ?options?
itk::Widget <- notebook
options.
rithm of the notebook. A value of true indicates that page frames will be unpacked and packed acoording to the algorithm described in the select command. A value of false leaves the current page packed and subsequent selects, next, or previous commands do not switch pages automatically. In either case the page's associated command (see the add command's description of the command option) is invoked. The value may have any of the forms accepted by the
certain display configurations of a graphical display, the -auto
flag could be used. By setting it, the -command procs could do
the appropriate reconfiguring of the page when the page is
switched.
_________________________________________________________________
argument) and makes it into a notebook widget. Additional options, described above may be specified on the command line or in the option database to configure aspects of the notebook such as its colors, font, and text. The notebook command returns its pathName argument. At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist.
one page from the set as the selected page. When a page is selected, the page's contents are displayed in the page area.
deleted using widget commands described below.
a new page is created it is a child of this frame. The page's child site frame serves as a geometry container for applications to pack widgets into. It is this frame that is automatically unpacked or packed when the auto option is true. This creates the effect of one page being visible at a time. When a new page is selected, the previously selected page's child site frame is automatically unpacked from the notebook's child site frame and the newly selected page's child site is packed into the note- book's child site frame.
different manner. By specifying the auto option as false, child site packing can be disabled and done differently. For example, all widgets might be packed into the first page's child site frame. Then when a new page is selected, the application can reconfigure the widgets and give the appearance that the page was flipped.
mand to execute when the page is selected. In the case of auto being true, it is called between the unpacking of the previously selected page and the packing of the newly selected page.
pathName. This command may be used to invoke various operations on the widget. It has the following general form:
pathName option ?arg arg ...?
option and the args determine the exact behavior of the command.
an indicator of which page of the notebook to operate on. These
indicators are called indexes and may be specified in any of the
following forms:
number
sponds to the left-most menu of the menu bar. For entries, 0 cor-
responds to the top-most entry of the menu. number Specifies the
page numerically, where 0 corresponds to the first page in the
notebook, 1 to the second, and so on.
select
rently selected, the value -1 is returned.
end
is empty this will return -1.
pattern
is used. Pattern is pattern-matched against the label of each
page in the notebook, in order from the first to the last page,
until a matching entry is found. The rules of Tcl_StringMatch are
used.
pathName add ?option value?
is created. Returns the child site pathName. If additional argu-
ments are present, they specify any of the following options:
-background value
frame of this page. If this option is specified as an empty
string (the default), then the background option for the overall
notebook is used.
-command value
selected. This allows the programmer a hook to reconfigure this
page's widgets or any other page's widgets.
selected this command will be called immediately after the previ- ously selected page is unpacked and immediately before this page is selected. The index value select is valid during this Tcl com- mand. `index select' will return this page's page number.
unpack and pack calls are bypassed. This Tcl command is still
called.
-foreground value
when tabs are in their normal unselected state. If this option is
specified as an empty string (the default), then the foreground
option for the overall notebook is used.
-label value
as an additional identifier used to reference the page. This
label may be used for the index value in widget commands.
pathName childSite ?index?
pages in the notebook. If the notebook is empty, an empty list is
returned
site frame specified by index. Widgets that are created with this pathName will be displayed when the associated page is selected.
pathName cget option
option.
pathName configure ?option? ?value option value ...?
option is specified, returns a list describing all of the avail-
able options for pathName (see Tk_ConfigureInfo for information
on the format of this list). If option is specified with no
value, then the command returns a list describing the one named
option (this list will be identical to the corresponding sublist
of the value returned if no option is specified). If one or more
option-value pairs are specified, then the command modifies the
given widget option(s) to have the given value(s); in this case
the command returns an empty string. Option may have any of the
values accepted by the notebook command.
pathName delete index1 ?index2?
index2 is omitted then it defaults to index1. Returns an empty
string.
pathName index index
pathName insert index ?option value?
index. A new child site frame is created. See the add command
for valid options. Returns the child site pathName.
pathName next
by insertion order). If the currently selected page is the last
page in the notebook, the selection wraps around to the first
page in the notebook.
is unpacked from the notebook's child site frame. Then the next page's child site is packed into the notebooks child site frame.
between these two operations.
the command option will be invoked.
pathName pagecget index ?option?
option for the page specified by index. The valid available options are the same as available to the add command. pathName pageconfigure index ?option? ?value option value ...?
applies to the options for an individual page, whereas configure applies to the options for the notebook. Options may have any of the values accepted by the add widget command. If options are specified, options are modified as indicated in the command and the command returns an empty string. If no options are specified, returns a list describing the current options for page index (see
pathName prev
by insertion order). If the currently selected page is the first
page in the notebook, the selection wraps around to the last page
in the notebook.
is unpacked from the notebook's child site frame. Then the
previous page's child site is packed into the notebooks child
site frame. The Tcl command given with the command option will be
invoked between these two operations.
the command option will be invoked.
pathName select index
page.
is unpacked from the notebook's child site frame. Then the index page's child site is packed into the notebooks child site frame.
between these two operations.
the command option will be invoked.
pathName view
bility with the scrollbar widget.
pathName view index
page. This command is for compatibility with the scrollbar wid-
get.
pathName view moveto fraction
move to. This command is for compatibility with the scrollbar
widget.
pathName view scroll num what
backward (num can be negative or positive). The what argument is ignored. This command is for compatibility with the scrollbar widget.
book widget.
# Create the notebook widget and pack it.
notebook .nb -width 100 -height 100
pack .nb -anchor nw \
-fill both \
-expand yes \
-side left \
-padx 10 \
-pady 10
# Add two pages to the notebook, labelled
# «Page One» and «Page Two", respectively.
.nb add -label «Page One"
.nb add -label «Page Two"
# Get the child site frames of these two pages.
set page1CS [.nb childsite 0]
set page2CS [.nb childsite «Page Two"]
# Create buttons on each page of the notebook
button $page1CS.b -text «Button One"
pack $page1CS.b
button $page2CS.b -text «Button Two"
pack $page2CS.b
# Select the first page of the notebook
.nb select 0
# Create the scrollbar and associate teh scrollbar
# and the notebook together, then pack the scrollbar
ScrollBar .scroll -command «.nb view"
.nb configure -scrollcommand «.scroll set"
pack .scroll -fill y -expand yes -pady 10
notebook page