hwtk::notebook

Multi-pane container widget.

Format

hwtk::notebook - pathName ?option value? …

Description

A hwtk::notebook widget manages a collection of windows and displays a single one at a time. Each secondary window is associated with a tab, which the user may select to change the currently-displayed window.

Standard Options

-clientdata
Database name: clientData
Database class: ClientData
Acts as a data storage for a widgets. User can store any data and this will not have any effect on widget property.
-cursor
Database name: cursor
Database class: Cursor
Specifies the mouse cursor to be used for the widget. See Tk_GetCursor and cursors(n) in the Tk reference manual for the legal values. If set to the empty string (the default), the cursor is inherited from the parent widget.
-height
Database name: height
Database class: Height
If specified, the widget’s requested height in pixels.
-helpcommand
Database name: helpcommand
Database class: Command
Dynamic help which calls an assigned -helpcommand when the user moves the mouse on the widget. The text which is returned by the -helpcommand will be in turn be displayed on the tooltip.
-takefocus
Database name: takeFocus
Database class: TakeFocus
Determines whether the window accepts the focus during keyboard traversal. Either 0, 1, a command prefix (to which the widget path is appended, and which should return 0 or 1), or the empty string. See options(n) in the Tk reference manual for the full description.
-width
Database name: width
Database class: Width
Specifies the width of a widget.

Widget-Specific Options

-padding
Database name: padding
Database class: Pad
Specifies the amount of extra space to allocate for the widget. The padding is a list of up to four length specifications left, top, right, bottom. If fewer than four elements are specified, bottom defaults to top, right defaults to left, and top defaults to left.

Tab Options

The following options may be specified for individual notebook panes:
-state
Database name: state
Database class: State
Either normal, disabled or hidden. If disabled, then the tab is not selectable. If hidden, then the tab is not shown.
-sticky
Database name: sticky
Database class: Sticky
Specifies how the secondary window is positioned within the pane area. Value is a string containing zero or more of the characters n, s, e, or w. Each letter refers to a side (north, south, east, or west) that the secondary window will stick to, as per the grid geometry manager.
-padding
Database name: padding
Database class: Padding
Specifies the amount of extra space to add between the notebook and this pane. Syntax is the same as for the widget -padding option.
-text
Database name: text
Database class: Text
Specifies a string to be displayed in the tab.
-image
Database name: image
Database class: Image
Specifies an image to display in the tab. See widget(n) for details.
-compound
Database name: compound
Database class: Compound
Specifies how to display the image relative to the text, in the case both -text and -image are present. See label(n) for legal values.
-underline
Database name: underline
Database class: Underline
Specifies the integer index of a character to underline in the widget. This option is used by the default bindings to implement keyboard traversal for menu buttons and menu entries. 0 corresponds to the first character of the text displayed in the widget, 1 to the next character, and so on.

Widget Command

pathName configure ?option? ?value option value …?
Query or modify the configuration options of the widget. 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. If option is specified with no value, then the command returns a list describing the named option: the elements of the list are the option name, database name, database class, default value, and current value. If no option is specified, returns a list describing all of the available options for pathName.
pathName cget option
Returns the current value of the configuration option given by option.
pathName identify element x y
Returns the name of the element under the point given by x and y, or an empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget. Some widgets accept other identify subcommands.
pathName instate statespec ?script?
Test the widget’s state. If script is not specified, returns 1 if the widget state matches statespec and 0 otherwise. If script is specified, equivalent to
if{[pathNameinstatestateSpec]}script
pathName state ?stateSpec?
Modify or inquire widget state. If stateSpec is present, sets the widget state: for each flag in stateSpec, sets the corresponding flag or clears it if prefixed by an exclamation point. Returns a new state spec indicating which flags were changed:
setchanges[pathNamestatespec]
pathNamestate$changes
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.
pathName add window ?options?
Adds a new tab to the notebook. See Tab Options above for the list of available options. If window is currently managed by the notebook but hidden, it is restored to its previous position.
pathName forget window
Removes the tab specified by window, unmaps and unmanages the associated window.
pathName hide window
Hides the tab specified by window. The tab will not be displayed, but the associated window remains managed by the notebook and its configuration remembered. Hidden tabs may be restored with the add command.
pathName insert pos subwindow options...
Inserts a pane at the specified position. pos is either the string end, an integer index, or the name of a managed subwindow. If subwindow is already managed by the notebook, moves it to the specified position. See Tab Options above for the list of available options.
pathName select tabid
Selects the specified tab. The associated secondary window will be displayed, and the previously-selected window (if different) is unmapped. If tabid is omitted, returns the widget name of the currently selected pane.
pathName tab tabid?-option?value…
Query or modify the options of the specific tab. If no -option is specified, returns a dictionary of the tab option values. If one -option is specified, returns the value of that option. Otherwise, sets the -option to the corresponding value. See Tab Options above for the available options.
pathName tabs
Returns the list of windows managed by the notebook.

Example

hwtk::dialog .d -title "::hwtk::notebook"
set d [.d recess]

pack [hwtk::notebook $d.nb] -fill both -expand true
$d.nb add[frame $d.nb.f1] -text "First tab"
$d.nb add[frame $d.nb.f2] -text "Second tab"
$d.nb select $d.nb.f2

.d post