iwidgets::tabset(1)
๐ iwidgets::tabset โ the whole vibe ๐
okay bestie, welcome to iwidgets::tabset(1), straight outta [incr Widgets] โจ this one's a long one so buckle up, we're doing it in parts ๐ซถ
๐ NAME ๐
iwidgets::tabset โ create and manipulate tabs as as set
yes the original says "as as set", we keep it, no notes ๐
โจ SYNOPSIS โจ
iwidgets::tabset pathName ?options?
๐ฆ INHERITANCE ๐ฆ
itk::Widget <- iwidgets::Tabset
๐ธ STANDARD OPTIONS ๐ธ
backgroundfontselectBackgroundcursorforegroundselectForegrounddisabledForegroundheightwidth
See the options manual entry for the full deets on all these standard options, bestie ๐
๐ WIDGET-SPECIFIC OPTIONS ๐
These are the extra options, the ones that make a tabset actually a tabset. Every one of them has a Name, a Class, and a Command-Line Switch, and I'm giving you all three every single time because we do not skip details in this house ๐ซถ
-angleโ Name:angle, Class:Angle, Command-Line Switch:-angle
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 tabPos is e or w, this option is ignored ๐.
-backdropโ Name:backdrop, Class:Backdrop, Command-Line Switch:-backdrop
Specifies a background color to use when filling in the area behind the tabs ๐จ.
-bevelamountโ Name:bevelAmount, Class:BevelAmount, Command-Line Switch:-bevelamount
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.
-commandโ Name:command, Class:Command, Command-Line Switch:-command
Specifes the prefix of a Tcl command to invoke to change the view in the widget associated with the tabset. When a user selects a tab, a Tcl command is invoked. The actual command consists of this option followed by a space and a number. The number is the numerical index of the tab that has been selected ๐ฅ.
-equaltabsโ Name:equalTabs, Class:EqualTabs, Command-Line Switch:-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 the 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 ๐.
-gapโ Name:gap, Class:Gap, Command-Line Switch:-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 ๐.
-marginโ Name:margin, Class:Margin, Command-Line Switch:-margin
Specifies the amount of space to place between the outside edge of the tabset and the outside edge of its tabs. If tabPos is s, this is the amount of space between the bottom edge of the tabset 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 tabset 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 tabset 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 tabset 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, Command-Line Switch:-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, Command-Line Switch:-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, Command-Line Switch:-raiseselect
Specifes whether to slightly raise the selected tab from the rest of the tabs. The selected tab is drawn 2 pixels closer to the outside edge of the tabset than the unselected tabs. A value of true says to raise selected tabs, a value of false turns this off. The default is false. The value may have any of the forms accepted by the Tcl_GetBoolean, such as true, false, 0, 1, yes, or no ๐.
-startโ Name:start, Class:Start, Command-Line Switch:-start
Specifies the amount of space to place between the left or top edge of the tabset and the starting edge of its tabs. For horizontally positioned tabs, this is the amount of space between the left edge of the tabset and the left edge of the first tab. For vertically positioned tabs, this is the amount of space between the top of the tabset and the top of the first tab. This value may change if the user performs a MButton-2 scroll on the tabs. This value may have any of the forms acceptable to Tk_GetPixels ๐.
-stateโ Name:state, Class:State, Command-Line Switch:-state
Sets the active state of the tabset. Specifying normal allows all tabs to be selectable. Specifying disabled disables the tabset causing all tabs to be drawn in the disabledForeground color ๐.
-tabbordersโ Name:tabBorders, Class:TabBorders, Command-Line Switch:-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 the Tcl_GetBoolean, such as true, false, 0, 1, yes, or no ๐ผ๏ธ.
-tabposโ Name:tabPos, Class:TabPos, Command-Line Switch:-tabpos
Specifies the location of the set of tabs in relation to another widget. Must be n, s, e, or w. Defaults to s. North tabs open downward, South tabs open upward. West tabs open to the right, east tabs open to the left ๐งญ.
๐ DESCRIPTION ๐
The iwidgets::tabset command creates a new window (given by the pathName argument) and makes it into a tabset widget. Additional options, described above may be specified on the command line or in the option database to configure aspects of the tabset such as its colors, font, and text. The iwidgets::tabset 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 tabset is a widget that contains a set of Tab buttons. It displays these tabs in a row or column depending on it tabpos. When a tab is clicked on, it becomes the only tab in the tab set that is selected. All other tabs are deselected. The Tcl command prefix associated with this tab (through the command tab configure option) is invoked with the tab index number appended to its argument list. This allows the tabset to control another widget such as a Notebook ๐.
๐๏ธ TABS ๐๏ธ
Tabs are drawn to appear attached to another widget. The tabset draws an edge boundary along one of its edges. This edge is known as the attachment edge. This edge location is dependent on the value of tabPos. For example, if tabPos is s, the attachment edge wil be on the top side of the tabset (in order to attach to the bottom or south side of its attached widget). The selected tab is draw with a 3d relief to appear above the other tabs. This selected tab "opens" toward attachment edge ๐ญ.
Tabs can be controlled in their location along the edges, the angle that tab sides are drawn with, gap between tabs, starting margin of tabs, internal padding around labels in a tab, the font, and its text or bitmap โจ.
๐ ๏ธ WIDGET-SPECIFIC METHODS ๐ ๏ธ
The iwidgets::tabset 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 tabset take as one argument an indicator of which tab of the tabset to operate on. These indicators are called indexes and may be specified in any of the following forms:
numberโ Specifies the tab numerically, where0corresponds to the first tab in the tab set,1to the second, and so on.selectโ Specifies the currently selected tab's index. If no tab is currently selected, the value-1is returned.endโ Specifes the last tab in the tabset's index. If the tabset 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 tab in the tabset, in order from the first to the last tab, until a matching entry is found. The rules ofTcl_StringMatchare used.
............................................................
The following commands are possible for tabset widgets:
pathName add ?option value option value ...?โ bestie, this adds a brand-new tab at the very end of the tabset ๐. It hands you back the child sitepathName. And if you passed extra arguments after it? Those are the options, and here's every single one of them:-anglevalue โ sets the angle of the slope going from the inner edge to the outer edge of the tab. An angle of0gives you square tabs. Valid range is 0 to 45 degrees inclusive. Default is15degrees. If you set this to an empty string (which is the default), then theangleoption of the whole tabset gets used instead. ๐-backgroundvalue โ the background color for showing tabs when they're in their normal state (aka unselected). Empty string (the default) means it falls back to thebackgroundoption of the overall tabset.-bevelamountvalue โ the size of the tab corners.0withangleset to0gives you square tabs. AbevelAmountof4means the tab gets drawn with angled corners that cut in 4 pixels from the edge of the tab. Default is0. Ngl this one is generally only set at the tabset configuration level โ tabs normally want to share the samebevelAmount.-bitmapvalue โ iflabelis a non-empty string, this specifies a bitmap to display in the tab. The bitmap can be any of the forms accepted byTk_GetBitmap. โจ-disabledforegroundvalue โ the foreground color for drawing tab labels when tabs are in their disable state. Empty string (the default) โ thedisabledforegroundoption of the overall tabset gets used.-fontvalue โ the font used when drawing the label on a tab. If it's an empty string, then thefontoption of the overall tabset is used.-foregroundvalue โ the foreground color for drawing tab labels when tabs are in their normal unselected state. Empty string (the default) โ theforegroundoption of the overall tabset.-imagevalue โ iflabelis a non-empty string, this specifies an image to display in the tab. The image has to have been created with theimage createcommand. Typically, ifimageis specified it overrides the other options that specify a bitmap or textual value for the widget; you can resetimageto an empty string to re-enable the bitmap or text display. ๐ฆ-labelvalue โ a text string placed in the tab's label. If you set this, thebitmapoption gets overridden and this is used instead. This label also acts as an extra identifier used to reference the tab, and it can be used as the index value in widget commands. iykyk ๐-selectbackgroundvalue โ the background color for displaying the selected tab. Empty string (the default) โ theselectBackgroundoption of the overall tabset.-selectforegroundvalue โ the foreground color for displaying the selected tab. Empty string (the default) โ theselectForegroundoption of the overall tabset.-padxvalue โ a non-negative value for how much extra space the tab requests around its label in the X-direction. When it's computing how big a window it needs, the tab adds this amount to the width it would normally need, so it ends up with extra internal space to the left and right of its text label. The value can be any form acceptable toTk_GetPixels. If it's an empty string (the default), then thepadXoption of the overall tabset is used.-padyvalue โ a non-negative value for how much extra space the tab requests around its label in the Y-direction. Same deal: the tab adds this to the height it would normally need, giving it extra internal space above and below its text label. Any form acceptable toTk_GetPixelsworks. Empty string (the default) โ thepadYoption of the overall tabset is used.-statevalue โ sets the state of the tab.normalmakes this tab selectable.disableddisables it, which draws its tab label in thedisabledForegroundcolor, and the tab won't respond to events until the state is set back tonormal. ๐
pathName configure ?option? ?value option value ...?โ query or modify the configuration options of the widget. If you give it no option, it returns a list describing all the available options for pathName (peepTk_ConfigureInfofor the format of that list). If you give it an option with no value, it returns a list describing just that one named option โ and that list will be identical to the matching sublist of what you'd get with no option specified. And if you hand it one or more option-value pairs, it modifies the given widget option(s) to have the given value(s), and in that case the command returns an empty string. Option can be any of the values accepted by theiwidgets::tabsetcommand. ๐pathName delete index1 ?index2?โ deletes every tab between index1 and index2, inclusive. If index2 is left out, it defaults to index1. Returns an empty string. Bye bestie ๐pathName index indexโ returns the numerical index corresponding to index.pathName insert index ?option value option value ...?โ inserts a new tab into the tabset before the tab specified by index. The extra arguments are the same as for theaddcommand. Returns the tab'spathName. ๐ธpathName nextโ advances the selected tab to the next tab (the order is determined by insertion order). If the currently selected tab is the last one in the tabset, the selection wraps around to the first tab. It behaves exactly as if the user selected the next tab.pathName tabconfigure index ?option? ?value?โ just like theconfigurecommand, except this one applies to the options for an individual tab, whereasconfigureapplies to the options for the tabset as a whole. Options can be any of the values accepted by theaddwidget command. If options are specified, they get modified as indicated in the command and the command returns an empty string. If no options are specified, it returns a list describing the current options for tab index (seeTk_ConfigureInfofor the format of this list).pathName prevโ moves the selected tab to the previous tab (order determined by insertion order, same as always). If the currently selected tab is the first tab in the tabset, the selection wraps around to the last tab in the tabset. It behaves as if the user selected the previous tab. ๐ฅpathName select indexโ selects the tab specified by index as the currently selected tab. It behaves as if the user selected the new tab. slay ๐
๐ EXAMPLE ๐
Okay bestie, here's the whole thing in action โ a tabset with two tabs plus a listbox that the tabset controls. And plot twist: selecting an item from the list also selects the corresponding tab. Mutual. Reciprocal. It's giving healthy relationship ๐
package require Iwidgets 4.0
# Define a proc that knows how to select an item
# from a list given an index from the tabset -command callback.
proc selectItem { item } {
.l selection clear [.l curselection]
.l selection set $item
.l see $item
}
# Define a proc that knows how to select a tab
# given a y pixel coordinate from the list..
proc selectTab { y } {
set whichItem [.l nearest $y]
.ts select $whichItem
}
# Create a listbox with two items (one and two)
# and bind button 1 press to the selectTab procedure.
listbox .l -selectmode single -exportselection false
.l insert end one
.l insert end two
.l selection set 0
pack .l
bind .l <ButtonPress-1> { selectTab %y }
# Create a tabset, set its -command to call selectItem
# Add two labels to the tabset (one and two).
iwidgets::tabset .ts -command selectItem
.ts add -label 1
.ts add -label 2
.ts select 0
pack .ts -fill x -expand no
Let's break down the girl math ๐งฎโจ
package require Iwidgets 4.0โ load the goods first, always.proc selectItem { item }โ a proc that knows how to select an item from a list when it's handed an index from the tabset-commandcallback. It clears the old selection, sets the new one, and.l see $itemscrolls it into view. Chef's kiss.proc selectTab { y }โ a proc that knows how to select a tab when it's handed a y pixel coordinate from the list. It grabs.l nearest $y, then.ts select $whichItem. Coordinated. Iconic.listbox .l -selectmode single -exportselection falseโ one listbox, single-select only (we're monogamous here), and-exportselection falseso it doesn't fight over the X selection.- Then
.l insert end one,.l insert end two,.l selection set 0,pack .lโ boom, populated and packed. bind .l <ButtonPress-1> { selectTab %y }โ click that mouse button and we're passing%ystraight intoselectTab. Delulu? No. Working. ๐iwidgets::tabset .ts -command selectItemโ the tabset arrives, and its-commandpoints atselectItem..ts add -label 1,.ts add -label 2,.ts select 0โ two labels, and tab zero gets the spotlight first.pack .ts -fill x -expand noโ fill across, but no expanding. Know your boundaries, queen.
๐ซถ AUTHOR ๐ซถ
Bill W. Scott โ the mastermind, the blueprint, the moment. Respect was paid. ๐
๐ฅ KEYWORDS ๐ฅ
tab tabset notebook tabnotebook
And that's a wrap on this page, bestie โ brought to you by Tk and the one and only iwidgets::tabset(1). Go forth and tab responsibly. No cap. ๐ฆโจ๐
๐ฆ where this page comes from
- debian bookworm: iwidgets4-doc 4.1.1-2.1
- debian trixie: iwidgets4-doc 4.1.1-4
- ubuntu jammy: iwidgets4-doc 4.1.1-2.1
- ubuntu noble: iwidgets4-doc 4.1.1-2.1
- ubuntu resolute: iwidgets4-doc 4.1.1-4
- ubuntu stonking: iwidgets4-doc 4.1.1-4
- Copyright (c) 1995 DSC Technologies Corporation
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms