tabbar::tabbar
- Create and manipulate tabbar widgetstabbar::tabbar pathName ?options?
-activebackground
-anchor
-background or -bg
-borderwidth or -bd
-disabledforeground
-font
-foreground or -fg
-height
-padx
-pady
-relief
-state
-takefocus
-width
-xscrollincrement
-bordercolor color
-close left|right
-closecommand command
-closeimage image
-closeshow enter|current|all
-command command
-history boolean
-inactivebackground color
-margin pixels
-maxtabwidth pixels
-mintabwidth pixels
-compound left|right
-emboss boolean
-image image
-padx pixels
-pady pixels
-state normal|disabled|hidden
-text text
-movable boolean
pathName
btag
pathName
cget
option
pathName
configure
?option? ?value option value ...?
pathName
delete
first ?last?
pathName
index
tab_index
pathName
insert
tab_index page_pathName ?tab_option value ...?
pathName
select
?tab_index?
pathName
tab
tab_index ?tab_option value ...?
pathName
tabs
pathName xview
args
pathName xview
pathName xview scroll number what
pathName xview shown
tabbar::tabbar
- Create and manipulate tabbar widgetstabbar::tabbar pathName ?options?
-activebackground
-anchor
-background or -bg
-borderwidth or -bd
-disabledforeground
-font
-foreground or -fg
-height
-padx
-pady
-relief
-state
-takefocus
-width
-xscrollincrement
Command-Line Name: | -bordercolor |
Database Name: | borderColor |
Database Class: | Color |
Specifies the color that is used in the border of each tab.
Command-Line Name: | -close |
Database Name: | close |
Database Class: | Close |
If this option is set to a value of left or right, a close button will be
drawn on each tab at the specified location on the tab. When the user left-clicks on this
button, the -closecommand
will be executed and the tab will be removed
from the tabbar. If this option is set to the empty string, a close button will not be
drawn and there will not be a widget-provided way to close a tab. The default value of
this option is right.
Command-Line Name: | -closecommand |
Database Name: | closeCommand |
Database Class: | Command |
If the-close
option is set to a non-empty string value, a close button will be displayed on each tab. When the user clicks on the close button, the command specified by this option is executed, allowing the code to remove the page associated with the tab from view and do any other cleanup necessary. If this option is set to the empty string, no command will be executed when a tab is closed (but the tab will still be removed from the tabbar widget). If this optin is set to a non-empty value, the associated command will be executed in global namespace and the pathname of the tabbar widget and the pathname of the associated page widget will be appended to the-closecommand
string.
Command-Line Name: | -closeimage |
Database Name: | closeImage |
Database Class: | Image |
Specifies an alternative image to use for the close button. This option is only used when
the -close
option is a non-empty value. By default, the tabbar widget
comes with a close button image which is basically just an "x" image. The default image
is a bitmap image which is has a foreground color that matches the foreground color of the
tab and a transparent background (performed by specifying the same bitmap file to the
-maskfile option of the bitmap image creation script.
Command-Line Name: | -closeshow |
Database Name: | closeShow |
Database Class: | CloseShow |
The value can be set to a value of either enter, current or all. Its value specifies when the close button will be displayed and hidden. If a value of enter is specified, the close button will be hidden until the mouse cursor enters the associated tab. At this time the close button will be displayed. When the mouse cursor leaves the tab, the close button will be hidden from view. If a value of current is specified, the close button will be continually displayed in the tab that has a tab_index value that matches current. If a value of all is specified, the close button will be displayed in all tabs at all times. The default value of this option is enter.
Command-Line Name: | -command |
Database Name: | command |
Database Class: | Command |
When a tab is left-clicked, the command that is associated with this option will be executed in global namespace, appending the pathname of the tabbar as well as the pathname associated with the clicked tab when the tab was added to the tabbar. If the value of this option is the empty string, no command will be executed when a tab is clicked.
Command-Line Name: | -history |
Database Name: | history |
Database Class: | History |
If this option is set to a boolean true value, the historical order of tab selections will be recorded for the tabbar such that when a tab is removed from the tabbar, the previously selected tab will be set to current tab. The highest number of stored tabs is the total number of tabs in the tabbar (i.e., tabs are not stored twice in the history list). If this option is set to a boolean value of false, the tab to the left of the removed tab is set to current (if no tabs to the left of the removed tab exist, the first tab to the right of the removed tab is made the current tab). The default value of this option is true.
Command-Line Name: | -inactivebackground |
Database Name: | inactiveBackground |
Database Class: | Background |
The associated color associated with this option is used to colorize the background of any tab that is not the current tab.
Command-Line Name: | -margin |
Database Name: | margin |
Database Class: | Margin |
Specifies the number of horizontal pixels to separate each tab from its neighboring tab. Default is to draw tabs with no margin.
Command-Line Name: | -maxtabwidth |
Database Name: | maxTabWidth |
Database Class: | TabWidth |
Specifies the maximum width that a tab can be drawn in number of pixels. If this value is set to a value of 0, the maximum width of the tab will be the total width of the tabbar divided by the number of tabs to display.
Command-Line Name: | -mintabwidth |
Database Name: | minTabWidth |
Database Class: | TabWidth |
Specifies the minimum width that a tab can be drawn in number of pixels. If the number of tabs to draw multiplied by their minimum width exceeds the width of the tabbar widget, left and right tab shift buttons will be displayed on the left and right side of the tabbar to allow the user to view buttons that are not currently displayed. Additionally, a dropdown button will be drawn on the right-most side of the tabbar to allow the user to quickly select a tab. If this value is set 0, the right, left and dropdown buttons will never be displayed. If the text in the tab cannot be displayed in full, the text will be elided, displaying the first portion of the tab string, followed by the string "...".
The options specified in the section can only be specified when retrieving or setting options on a tab.
-compound
If this option is set to a value of
left
orright
an image specified by the-image
tab option will be displayed on the specified side of the tab text. If this option is set to the empty string (default), the tab will only be able to display an image or text, but not both.
-emboss
If set to a boolean value of true, draws the text with an emboss effect; otherwise, draws normal text.
-image
Specifies an image to display in the tab as returned from an
image create
command call. If the-compound
option is set, specifies the location of the image in relation to the text.
-padx
Specifies, in pixels, the amount of horizontal padding to provide between the tab border and the tab content (text/image/close).
-pady
Specifies, in pixels, the amount of vertical padding to provide between the tab border and the tab content (text/image/close).
-state
Specifies the current state of the tab. The legal values are:
normal
,disabled
, orhidden
. A button with a normal state will be shown, can be moved, and may be selected. A button with a disabled state will be shown, may not be moved and may not be selected. The text in disabled tabs will be colored with the-disabledforeground
color. A button with a hidden state will not be shown, but is still managed by the widget and can be displayed again at any time by setting the state to a value ofnormal
ordisabled
.
-text
Determines the text string to display in the tab. This value will be ignored if the
-image
option is set and the-compound
option is set to the empty string. If the width of the tab is not wide enough to display the full text stored in the tab, the text will be automatically elided, displaying the left-most characters of the text followed by the string "...".
-movable
If set to a boolean value of true, the tab will be allowed to move within the tabbar and its order number will be allowed to change. If set to a boolean value of false, the tab will not be allowed to be moved within the tabbar and its position may not be modified by moving other tabs to the opposite side of the unmovable tab.
tabbar::tabbar
command creates a new window named
pathName
and of the class Tabbar
, and makes it
into a tabbar
widget. Additional options, described above, may be
specified on the command-line or in the option database to configure aspects of the
tab bar such as its colors, font, sizing, etc. The tabbar::tabbar
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.
tabbar
widget is a specialized version of a ttk::notebook. Instead
of displaying both the tab bar and the associated frame, the tabbar
widget only displays the tab bar portion, allowing the user to place a tabbar in the same
horizontal space in the application as other widgets (including other tabbar widgets),
leaving the display of the tab frame up to the application writer. This mechanism allows
the application writer to design some powerful interfaces that make more efficient use of
screen real estate.
tabbar
widget provides some
powerful, modern tab bar behaviors that most users come to expect from a tab bar, including
a built-in close button per tab, the ability to re-order/move tabs by dragging them within
the tabbar, dynamically resizing tabs based on number and size of the tabbar (maintaining
even tab sizes), properly handling tabs when all tabs cannot be shown in the widget, and
even the ability to hide tabs, just to name a few.
insert
command, this index refers to the position to the right of the right-most tab (i.e.,
the position of the inserted tab will be in the right-most position).
-history
option is set to a value of 1, refers to the last
selected tab prior to the selection of the current tab. If the -history
option is set to a value of 0 or there is no selection history, using this index will
result in an error.
tabbar::tabbar
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 arg
determine the exact behavior
of the command. The following commands are possible for tabbar widgets:
pathName btag
pathName cget option
pathName configure ?option? ?value option value ...?
pathName delete index ?index?
-history
option is set to true.
pathName index index
pathName insert index pathname ?option value ...?
pathName select ?index?
pathName tab index option ?value? ?option value ...?
pathName tabs
pathName xview ?args?
pathName xview
pathName xview scroll number
pathName xview shown
# Require the tabbar package package require tabbar # This procedure displays the associated widget in the notebook frame. proc show_frame {tb win} { } ######################## # Create the interface # ######################## # Create the tabbar frame (contains an add button and the tabbar frame) ttk::frame .tf ttk::button .tf.add -text "+" -command "add_tab" tabbar::tabbar .tf.tb -command "show_frame"