background foreground scrollCommand width cursor height
See the options manual entry for details on the standard options.
Name: auto Class: Auto Command-Line Switch: -auto
The notebook command creates a new window (given by the pathName 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.
A notebook is a widget that contains a set of pages. It displays one page from the set as the selected page. When a page is selected, the page's contents are displayed in the page area. When first created a notebook has no pages. Pages may be added or deleted using widget commands described below.
A notebook's pages area contains a single child site frame. When 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 notebook's child site frame.
However, sometimes it is desirable to handle page changes in a 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.
In both cases the command option for a page specifies a Tcl Command 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.
The notebookfR command creates a new Tcl command whose name is 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.
Many of the widget commands for a notebook take as one argument 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:
The following commands are possible for notebook widgets:
Following is an example that creates a notebook with two pages. In this example, we use a scrollbar widget to control the notebook 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