iwidgets::tabnotebook(1)

πŸ’– iwidgets::tabnotebook πŸ’–

okay bestie, so this page is from the [incr Widgets] manual, section 1, and it's all about iwidgets::tabnotebook β€” the widget that makes and manipulates tabnotebook widgets. yes the whole page. sit down, grab a snack, we're doing this. ✨


🌸 NAME 🌸

iwidgets::tabnotebook β€” create and manipulate tabnotebook widgets πŸŽ€


✨ SYNOPSIS ✨

iwidgets::tabnotebook pathName ?options?

πŸ¦‹ INHERITANCE πŸ¦‹

itk::Widget <- iwidgets::Tabnotebook

(so it's got that itk::Widget bloodline, and it's giving main character energy from day one πŸ‘‘)


πŸ’… STANDARD OPTIONS πŸ’…

these are the hand-me-downs from the family, the classics:

  • background
  • disabledForeground
  • foreground
  • scrollCommand
  • cursor
  • font
  • height
  • width
heads up bestie: go peep the "options" manual entry for the deets on all the standard options. not my job to re-explain the family lore here πŸ’€

πŸŽ€ WIDGET-SPECIFIC OPTIONS πŸŽ€

this is the good part. this is where the tabnotebook really becomes her. 🫢

  • -angle (Name: angle, Class: Angle) β€” specifies the angle of slope from the inner edge to the outer edge of the tab. an angle of 0 gives you square tabs (no slope, very blunt, very honest). valid ranges are 0 to 45 degrees inclusive. default is 15 degrees. but β€” if tabPos is e or w, this option is just ignored. sorry, it said what it said. πŸ™ˆ
  • -auto (Name: auto, Class: Auto) β€” specifies whether to use the automatic packing/unpacking algorithm of the notebook. a value of true means page frames will be unpacked and packed according to the algorithm described in the select command. a value of false leaves the current page packed, and subsequent select, 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 Tcl_GetBoolean, such as true, false, 0, 1, yes, or no. 🌈
  • -backdrop (Name: backdrop, Class: Backdrop) β€” specifies a background color to use when filling in the backdrop area behind the tabs. the vibes layer, if you will. ✨
  • -background (Name: background, Class: Background) β€” specifies a background color to use for displaying a page and its associated tab. think of this as the selected tab background color, since the tab associated with the selected page is the selected tab. πŸ’–
  • -bevelamount (Name: bevelAmount, Class: BevelAmount) β€” specifies the size of tab corners. a value of 0 with angle set to 0 results in square tabs. a bevelAmount of 4 means the tab will be drawn with angled corners that cut in 4 pixels from the edge of the tab. the default is 0. πŸŽ€
  • -borderwidth (Name: borderWidth, Class: BorderWidth) β€” specifies the width of shadowed border to place around the notebook area of the tabnotebook. the default value is 2. πŸ–€
  • -disabledforeground (Name: disabledForeground, Class: DisabledForeground) β€” specifies a foreground color to use for displaying a tab's label when its state is disabled. the sad grey era. 😭
  • -equaltabs (Name: equalTabs, Class: EqualTabs) β€” specifies whether to force tabs to be equal sized or not. a value of true means constrain tabs to be equal sized. a value of false allows each tab to size based on the text label size. the value may have any of the forms accepted by Tcl_GetBoolean, such as true, false, 0, 1, yes, or no.
    • for horizontally positioned tabs (tabpos is either s or n), true forces all tabs to be equal width β€” the width being equal to the longest label plus any padX specified. horizontal tabs are always equal in height.
    • for vertically positioned tabs (tabpos is either w or e), true forces all tabs to be equal height β€” the height being equal to the height of the label with the largest font. vertically oriented tabs are always equal in width.

no cap, it's an equalizer either way. πŸ’…

  • -foreground (Name: foreground, Class: Foreground) β€” specifies a foreground color to use for displaying a page and its associated tab label. this can be thought of as the selected tab background color, since the tab associated with the selected page is the selected tab. (yes bestie, the page literally says "background color" here, i'm just the messenger 😭)
  • -gap (Name: gap, Class: Gap) β€” specifies the amount of pixel space to place between each tab. value may be any pixel offset value. in addition, a special keyword overlap can be used as the value to achieve a standard overlap of tabs. this value may have any of the forms acceptable to Tk_GetPixels. πŸ¦‹
  • -Bmargin (Name: margin, Class: Margin) β€” specifies the amount of space to place between the outside edge of the tabnotebook and the outside edge of its tabs. and it's giving situational, because:
    • if tabPos is s, this is the amount of space between the bottom edge of the tabnotebook and the bottom edge of the set of tabs.
    • if tabPos is n, this is the amount of space between the top edge of the tabnotebook and the top edge of the set of tabs.
    • if tabPos is e, this is the amount of space between the right edge of the tabnotebook and the right edge of the set of tabs.
    • if tabPos is w, this is the amount of space between the left edge of the tabnotebook and the left edge of the set of tabs.

this value may have any of the forms acceptable to Tk_GetPixels. πŸ‘‘

  • -padx (Name: padX, Class: PadX) β€” specifies a non-negative value indicating how much extra space to request for a tab around its label in the X-direction. when computing how large a window it needs, the tab will add this amount to the width it would normally need. the tab will end up with extra internal space to the left and right of its text label. this value may have any of the forms acceptable to Tk_GetPixels. ✨
  • -pady (Name: padY, Class: PadY) β€” specifies a non-negative value indicating how much extra space to request for a tab around its label in the Y-direction. when computing how large a window it needs, the tab will add this amount to the height it would normally need. the tab will end up with extra internal space to the top and bottom of its text label. this value may have any of the forms acceptable to Tk_GetPixels. ✨
  • -raiseselect (Name: raiseSelect, Class: RaiseSelect) β€” specifies whether to slightly raise the selected tab from the rest of the tabs. the selected tab is drawn 2 pixels closer to the outside of the tabnotebook than the unselected tabs. a value of true says to raise selected tabs, a value of false turns this feature off. the default is false. the value may have any of the forms accepted by Tcl_GetBoolean, such as true, false, 0, 1, yes, or no. it's the "pick me" option but for tabs and honestly? iconic. 🌟
  • -start (Name: start, Class: Start) β€” specifies the amount of space to place between the left or top edge of the tabnotebook and the starting edge of its tabs.
    • for horizontally positioned tabs, this is the amount of space between the left edge of the notebook and the left edge of the first tab.
    • for vertically positioned tabs, this is the amount of space between the top of the notebook and the top of the first tab.
⚠️ heads up: this value may change if the user performs a MButton-2 scroll on the tabs. not your fault, bestie, it's just the widget doing its thing. 😭

this value may have any of the forms acceptable to Tk_GetPixels. 🌸

  • -state (Name: state, Class: State) β€” sets the active state of the tabnotebook. specifying normal allows all pages to be selectable. specifying disabled disables the notebook, causing all page tabs to be drawn in the disabledForeground color. choose your fighter. πŸ’€
  • -tabbackground (Name: tabBackground, Class: TabBackground) β€” specifies a background color to use for displaying tab backgrounds when they are in their unselected state. this is the background associated with tabs on all pages other than the selected page. the unselected girlies, we see them too. πŸ’œ
  • -tabborders (Name: tabBorders, Class: TabBorders) β€” specifies whether to draw the borders of tabs that are not selected. specifying true (the default) draws these borders, specifying false draws only the border around the selected tab. the value may have any of the forms accepted by Tcl_GetBoolean, such as true, false, 0, 1, yes, or no. πŸŽ€
  • -tabforeground (Name: tabForeground, Class: TabForeground) β€” specifies a foreground color to use for displaying tab labels when they are in their unselected state. this is the foreground associated with tabs on all pages other than the selected page. πŸ’–
  • -tabpos (Name: tabPos, Class: TabPos) β€” specifies the location of the set of tabs in relation to the notebook area. must be n, s, e, or w. defaults to s. that's it, that's the whole thing. ✨

okay that's part 1 bestie, more is coming, don't go anywhere πŸ’…

✨ DESCRIPTION ✨

okay so iwidgets::tabnotebook makes a brand new window (you hand it the pathName argument, bestie) and turns it into a tabnotebook widget. πŸ’– You can also toss in extra options β€” the ones we talked about up above β€” either on the command line or in the option database, to configure stuff like its colors, font, and text. The command hands you back its pathName argument, easy peasy.

Now, heads up: when you invoke this command, there must not already be a window named pathName β€” but pathName's parent must exist. No orphans allowed. πŸ‘‘

A tabnotebook is that iconic widget that holds a whole set of tabbed pages. It shows one page from the set as the selected page. A Tab displays the label for the page it's attached to and acts as a page selector. When a page's tab gets selected, that page's contents show up in the page area. The selected tab gets a three-dimensional effect so it looks like it's floating above all the other tabs β€” main character energy, fr. ✨ The tabs are displayed as a group along either the left, top, right, or bottom edge.

When it's first created, a tabnotebook has no pages β€” it's a beautiful empty little vessel. πŸŽ€ Pages get added or deleted using the widget commands described below.

A special option may be provided to the tabnotebook: the -auto option. It says whether the tabnotebook will automatically handle the unpacking and packing of pages when pages are selected. A value of true means the notebook manages it automatically β€” and that's the default value, no cap. A value of false means the notebook will not perform automatic switching of pages.


πŸ¦‹ NOTEBOOK PAGES πŸ¦‹

A tabnotebook's pages area contains a single child site frame. When a new page is created, it's a child of this frame. The page's child site frame serves as a geometry container for applications to pack widgets into. It's this frame that gets 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 tabnotebook's child site frame, and the newly selected page's child site is packed into the tabnotebook's child site frame. Switching, but make it seamless. πŸ’…

However β€” sometimes you wanna handle page changes a different way. 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. Sneaky? No, genius. 🧠

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 happens between the unpacking of the previously selected page and the packing of the newly selected page.

Notebook pages can also be controlled with scroll bars or other widgets that obey the scrollcommand protocol. By giving a scrollbar a -command to call the tabnotebook's select method, the tabnotebook can be controlled with a scrollbar. iykyk. 🎒

The notebook area is implemented with the notebook mega widget.


πŸŽ€ TABS πŸŽ€

Tabs appear along the edge of the notebook area. Tabs are drawn to appear attached to their associated page. When a tab is clicked on, the associated page is selected and the tab is drawn as raised above all other tabs and as a seamless part of its notebook page. The way that a tab just becomes the page… obsessed. πŸ’–

Tabs can be controlled in their location along the edges, the angle tab sides are drawn with, gap between tabs, starting margin of tabs, internal padding around text labels in a tab, the font, and its label.

The Tab area is implemented with the tabset mega widget. See tabset(1).

Tabs may be oriented along either the north, south, east, or west sides with the tabPos option. North and south tabs may appear as angled, square, or bevelled. West and east tabs may appear as square or bevelled. By changing tab gaps, tab angles, bevelling, orientations, colors, fonts, start locations, and margins, tabs may appear in a wide variety of styles. For example, it's possible to implement Microsoft-style tabs, Borland property tab styles, or Borland Delphi style tabs β€” all with the same tabnotebook. Versatile icon behavior. 🌈


⭐ WIDGET-SPECIFIC METHODS ⭐

The iwidgets::tabnotebook 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:

  • number β€” Specifies the page numerically, where 0 corresponds to the first page in the notebook, 1 to the second, and so on.
  • select β€” Specifies the currently selected page's index. If no page is currently selected, the value -1 is returned.
  • end β€” Specifes the last page in the tabnotebook's index. If the notebook is empty this will return -1.
  • pattern β€” If the index doesn't satisfy any of the above forms, then this form 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.

The following commands are possible for tabnotebook widgets:

  • pathName add ?option value option value ...? β€” Add a new page at the end of the tabnotebook. A new child site frame is created. Returns the child site pathName. If additional arguments are present, they specify any of the following options:
    • -angle value β€” Specifes the angle of slope from the inner edge to the outer edge of the tab. An angle of 0 specifies square tabs. Valid ranges are 0 to 45 degrees inclusive. Default is 15 degrees. If this option is specified as an empty string (the default), then the angle option for the overall tabnotebook is used. This is generally only set at the tabnotebook level. Tabs normally will want to share the same angle value.
    • -background value β€” Specifies a background color to use for displaying tabs when they are selected and for displaying the current page. If this option is specified as an empty string (the default), then the background option for the overall tabnotebook is used.
    • -bevelamount value β€” Specifes the size of tab corners. A value of 0 with angle set to 0 results in square tabs. A bevelAmount of 4 means that the tab will be drawn with angled corners that cut in 4 pixels from the edge of the tab. The default is 0. This is generally only set at the tabnotebook level. Tabs normally will want to share the same bevelAmount.
    • -bitmap value β€” If label is a non-empty string, specifies a bitmap to display in this page's tab. Bitmap may be of any of the forms accepted by Tk_GetPixmap.
    • -command value β€” Specifies a Tcl command to be executed when this page is selected. This allows the programmer a hook to reconfigure this page's widgets or any other page's widgets.

If the tabnotebook has the auto option set to true, when a page is selected this command will be called immediately after the previously selected page is unpacked and immediately before this page is selected. The index value select is valid during this Tcl command. index select will return this page's page number.

If the auto option is set to false, when a page is selected the unpack and pack calls are bypassed. This Tcl command is still called.

  • -disabledforeground value β€” Specifies a foreground color to use for displaying tab labels when tabs are in their disable state. If this option is specified as an empty string (the default), then the disabledforeground option for the overall tabnotebook is used.
  • -font value β€” Specifies the font to use when drawing a text label on a page tab. If this option is specified as an empty string then the font option for the overall tabnotebook is used..
  • -foreground value β€” Specifies a foreground color to use for displaying tab labels when they are selected. If this option is specified as an empty string (the default), then the foreground option for the overall tabnotebook is used.
  • -label value β€” Specifies a string to display as an identifying label for a notebook page. This label serves as an additional identifier used to reference the page. This label may be used for the index value in widget commands.
  • -tabbackground value β€” Specifies a background color to use for displaying a tab when it is not elected. If this option is specified as an empty string (the default), then the tabBackground option for the overall tabnotebook is used.
  • -tabforeground value β€” Specifies a foreground color to use for displaying the tab's text label when it is not selected. If this option is specified as an empty string (the default), then the tabForeground option for the overall tabnotebook is used.
  • -padx value β€” Specifies a non-negative value indicating how much extra space to request for a tab around its label in the X-direction. When computing how large a window it needs, the tab will add this amount to the width it would normally need. The tab will end up with extra internal space to the left and right of its text label. This value may have any of the forms acceptable to Tk_GetPixels. If this option is specified as an empty string (the default), then the padX option for the overall tabnotebook is used
  • -pady value β€” how much extra room the tab should ask for around its label, going up-and-down (Y-direction). When the tab is figuring out how big it needs to be, it adds this amount to the height it'd normally want, so you end up with extra internal space above and below the text label. Any form that Tk_GetPixels accepts works here. Set it to an empty string (that's the default, bestie) and the padY option of the whole tabnotebook gets used instead. πŸ’…
  • -state value β€” the page's mood, and it's one of exactly two: normal or disabled. In normal state, tabs that aren't selected get drawn with the tabforeground and tabbackground options from the tabnotebook or the page. Selected tabs and pages get drawn with the foreground and background options from the tabnotebook or the page. The disabled state means the page and its tab are fully insensitive β€” they do not respond to mouse button presses or releases, like at all. In that state the entry is displayed according to its disabledForeground option for the tabnotebook, plus the background/tabbackground option from the page or the tabnotebook.

pathName childSite ?index?

No arguments? Then you get back a list of pathNames for every page in the tabnotebook. Empty notebook = empty list, no cap. 🫢

Hand it an index and it gives you the pathName of that page's child site frame. Widgets you create with this pathName are the ones that show up when the associated page gets selected. If index isn't a valid index, you get an empty string back. That's it, that's the whole vibe.

pathName configure ?option? ?value option value ...?

Query or change the widget's configuration options, the classic. No option given? You get a list describing every available option for pathName (peep Tk_ConfigureInfo for how that list is formatted). Give an option with no value and you get a list describing just that one named option β€” identical to the matching sublist from the no-option version. Give one or more option-value pairs and the command modifies those widget options to hold those values, and returns an empty string in that case. option can be anything the iwidgets::tabnotebook command accepts. ✨

pathName delete index1 ?index2?

Deletes every page from index1 to index2, inclusive β€” yes, both ends, she's thorough. Leave index2 out and it defaults to index1. Returns an empty string.

pathName index index

Returns the numerical index that corresponds to index. Number go brrr. πŸ”’

pathName insert index ?option value option value ...?

Inserts a brand-new page into the tabnotebook before the page specified by index. A fresh child site frame gets created. Those extra arguments work exactly like the add command's. Returns the child site pathName. πŸ’–

pathName next

Advances the selected page to the next one (order is decided by insertion order, not vibes). If the currently selected page is the last page in the notebook, the selection wraps around to the first page. It behaves as if the user selected the new page.

  • For notebooks with auto set to true: the current page's child site is unpacked from the notebook's child site frame. Then the next page's child site is packed into the notebook's child site frame. The Tcl command given with the command option gets invoked between those two operations.
  • For notebooks with auto set to false: the Tcl command given with the command option just gets invoked.

pathName pageconfigure index ?option? ?value option value ...?

Like configure, except it applies to the options of one individual page, whereas configure applies to the tabnotebook as a whole. Options can be anything the add widget command accepts. Specify options and they get modified as indicated, and the command returns an empty string. Specify none and you get a list describing the current options for page index (again, Tk_ConfigureInfo explains the format of that list). πŸŽ€

pathName prev

Moves the selected page to the previous one (order is decided by insertion order). If the currently selected page is the first page in the notebook, the selection wraps around to the last page. It behaves as if the user selected the new page.

  • For notebooks with auto set to true: the current page's child site is unpacked from the notebook's child site frame. Then the previous page's child site is packed into the notebook's child site frame. The Tcl command given with the command option gets invoked between those two operations.
  • For notebooks with auto set to false: the Tcl command given with the command option just gets invoked.

pathName select index

Selects the page specified by index as the currently selected page. It behaves as if the user selected the new page.

  • For notebooks with auto set to true: the current page's child site is unpacked from the notebook's child site frame. Then the index page's child site is packed into the notebook's child site frame. The Tcl command given with the command option gets invoked between those two operations.
  • For notebooks with auto set to false: the Tcl command given with the command option just gets invoked.

pathName view

Returns the currently selected page. This command exists for compatibility with the scrollbar widget, iykyk. πŸ‘‘

pathName view index

Selects the page specified by index as the currently selected page. Also for scrollbar widget compatibility.

pathName view moveto fraction

Uses the fraction value to figure out which corresponding page to move to. Scrollbar widget compatibility again, bestie.

pathName view scroll num what

Uses the num value to figure out how many pages to move forward or backward (num can be negative or positive, she's flexible like that). The what argument is straight-up ignored. And yeah β€” scrollbar widget compatibility. πŸŒ€


🧩 COMPONENTS 🧩

Okay so generally, all the behavior of the internal components β€” tabset and notebook β€” is controlled through the pageconfigure method. This next bit documents those two components.

Name: tabset Class: Tabset

This is the tabset component. It implements the tabs that are associated with the notebook component. πŸŽ€

See the "Tabset" widget manual entry for the details on the tabset component item.

Name: notebook Class: Notebook

This is the notebook component. It implements the notebook that contains the pages of the tabnotebook. πŸ““

See the "Notebook" widget manual entry for the details on the notebook component item.


🌸 EXAMPLE 🌸

Here's an example that creates a tabnotebook with two pages. Look at her go:

package require Iwidgets 4.0
# Create the tabnotebook widget and pack it.
  iwidgets::tabnotebook .tn -width 100 -height 100
  pack .tn \
        -anchor nw \
        -fill both \
        -expand yes \
        -side left \
        -padx 10 \
        -pady 10

# Add two pages to the tabnotebook,
# labelled "Page One" and "Page Two"
  .tn add -label "Page One"
  .tn add -label "Page Two"

# Get the child site frames of these two pages.
  set page1CS [.tn childsite 0]
  set page2CS [.tn childsite "Page Two"]

# Create buttons on each page of the tabnotebook.
  button $page1CS.b -text "Button One"
  pack $page1CS.b
  button $page2CS.b -text "Button Two"
  pack $page2CS.b

# Select the first page of the tabnotebook.
  .tn select 0

πŸ‘‘ AUTHOR πŸ‘‘

Bill W. Scott


πŸ”‘ KEYWORDS πŸ”‘

tab tabset notebook tabnotebook page


That's the whole page, bestie β€” every option, every method, every component, all of it. πŸ’– This one comes from the Tk source and lives under the iwidgets::tabnotebook(1) name. Go forth and tab, you absolute icon. 🌈✨

πŸ“¦ where this page comes from