scrollutil::scrollednotebook
Commandclosetab
Style Elementscrollutil::scrollednotebook
Command – Quick
Referencescrollutil::scrollednotebook
Command – Detailed
Referenceclosetab
Style
Elementscrollutil::addclosetab
Commandscrollutil::removeclosetab
Commandscrollutil::closetabstate
Commandscrollutil::scrollednotebook
Command – Quick Referencescrollutil::scrollednotebook
– Create and manipulate
scrollednotebook widgetspackage require scrollutil_tile scrollutil::scrollednotebook pathName ?options?
-cursor -style
-forgetcommand
command
-height
screenDistance
-leavecommand
command
-movabletabs
boolean
-padding
paddingSpec
-takefocus
0|1|""|command
-width
screenDistance
pathName attrib ?name
?value name value ...??
pathName closetabstate tabId
?normal|disabled?
pathName hasattrib
name
pathName hastabattrib
tabId name
pathName notebookpath
pathName see
tabId
pathName tabattrib
tabId ?name ?value name value
...??
pathName unsetattrib
name
pathName unsettabattrib tabId
name
scrollutil::scrollednotebook
Command – Detailed Referencescrollutil::scrollednotebook
– Create and manipulate
scrollednotebook widgetspackage require scrollutil_tile scrollutil::scrollednotebook pathName ?options?
scrollutil::scrollednotebook
command
is provided by the Scrollutil_tile package, but not by Scrollutil.scrollutil::scrollednotebook
command creates a
new window named pathName
and of the class
Scrollednotebook
, and makes it into a
scrollednotebook widget. Additional options, described below,
may be specified on the command line or in the option database to configure
aspects of the scrollednotebook widget such as its width, height, and
style. The scrollutil::scrollednotebook
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.100
, 125
,
150
, 175
, or 200
), while their color
is theme-specific and is updated whenever the theme changes. An
individual tab can be made visible programmatically with the aid of the
see
subcommand. Unlike the
ttk::notebook widget, whose -width
option is quite
often overridden by the total width of the tabs, the scrollednotebook
widget respects the value of its -width
option, regardless of the space required by
the tabs.-cursor -style
-style
option refers to the style of
the ttk::notebook widget contained in the scrollednotebook. The value
of the -tabposition
option of the style specified by
this Ttk widget option must be one of nw
(the default),
n
(the default for the aqua
theme),
ne
, sw
, s
, or
se
. These values will result in a horizontal tab
layout (the scrollednotebook widget doesn't support vertical tab
layouts).-cursor "" -style TNotebook
| Command-Line Name: | -forgetcommand |
| Database Name: | forgetCommand |
| Database Class: | ForgetCommand |
Specifies a command to be invoked when attempting to remove a tab and unmanage the associated window with the aid of the
forget
subcommand. If the option's value is a nonempty string then it is concatenated with the path name of the scrollednotebook widget and that of the window to be unmanaged, and the resulting script, which must return a boolean, is evaluated in the global scope. If the return value of this script is false then theforget
subcommand is aborted, i.e., the tab is not removed and the associated window is not unmanaged. The default is an empty string.
| Command-Line Name: | -height |
| Database Name: | height |
| Database Class: | Height |
If present and greater than zero, specifies the desired height for the widget in any of the forms acceptable to
Tk_GetPixels
. Otherwise, the widget's height is set to the requested height of the ttk::notebook contained in it (which in turn depends on the maximum height of all panes and tabs), immediately after the scrollednotebook gets mapped. The default is0
.
| Command-Line Name: | -leavecommand |
| Database Name: | leaveCommand |
| Database Class: | LeaveCommand |
Specifies a command to be invoked when attempting to leave the currently selected window by selecting a different one. If the option's value is a nonempty string then it is concatenated with the path name of the scrollednotebook widget and that of the currently selected window, and the resulting script, which must return a boolean, is evaluated in the global scope. If the return value of this script is false then the operation of selecting a different window is aborted. The default is an empty string.
| Command-Line Name: | -movabletabs |
| Database Name: | movableTabs |
| Database Class: | MovableTabs |
Specifies a boolean value that determines whether the tabs can be moved with the mouse. See the FURTHER BINDINGS section below for details. The default is
1
.
| Command-Line Name: | -padding |
| Database Name: | padding |
| Database Class: | Padding |
Specifies the amount of extra space to add around the outside of the ttk::notebook widget contained in the scrollednotebook. See the ttk_notebook manual entry for details. The default is an empty string. Note that if this default value is used then the ttk::notebook widget will be drawn with the external padding specified by the
-padding
option of the widget's style.
| Command-Line Name: | -takefocus |
| Database Name: | takeFocus |
| Database Class: | TakeFocus |
This option determines whether the scrollednotebook widget accepts the focus during keyboard traversal. It is almost identical to the standard option of the same name (see the options manual entry for details). The only difference is that not the scrollednotebook widget itself but the ttk::notebook contained in it will receive the focus during keyboard traversal with the standard keys (
Tab
andShift-Tab
). The default is"ttk::takefocus"
(just like for ttk::notebook and several other Tk themed widgets).
| Command-Line Name: | -width |
| Database Name: | width |
| Database Class: | Width |
If present and greater than zero, specifies the desired width for the widget in any of the forms acceptable to
Tk_GetPixels
. Otherwise, the widget's width is set to the requested width of the ttk::notebook contained in it (which in turn depends, among others, on the maximum width of all panes and the total width of the tabs), immediately after the scrollednotebook gets mapped. The default is10c
, which should be overridden with a suitable application-specific value.
scrollutil::scrollednotebook
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
s determine
the exact behavior of the command. The subcommands possible for
scrollednotebook widgets are the same as those for ttk::notebook widgets
(see the ttk_notebook manual entry for details), except that
scrollednotebook widgets provide the following additional subcommands:pathName attrib
?name ?value name value ...??
name
is specified, the command returns a list of
pairs, each of which contains the name and the value of an attribute
for pathName
. If name
is
specified with no value
, then the command returns
the value of the one named attribute, or an empty string if no
corresponding value exists (you can use the hasattrib
subcommand to distinguish this
case from the one that the value of an existing attribute is an
empty string). If one or more
name
-value
pairs are specified,
then the command sets the given widget attribute(s) to the given
value(s); in this case the return value is an empty string. Each
name
may be an arbitrary string.pathName
closetabstate tabId
?normal|disabled?
closetab
element of the tab specified by
tabId
. Invoking this subcommand is just a
shortcut for passing pathName
,
tabId
, and the optional argument (if present) to
the scrollutil::closetabstate
command.pathName hasattrib
name
1
if the attribute name
exists and 0
otherwise.pathName
hastabattrib tabId name
1
if the attribute name
for the tab given by tabId
exists and
0
otherwise.pathName
notebookpath
nb
denotes the ttk::notebook
path name returned by this subcommand, you can set a tooltip
message
for one of its tabs by using either the
-tab
option of the
tooltip::tooltip
command from the tooltip package
contained in tklib:
tooltip::tooltip nb -tab tabId message
-nbktab
option of the
baltip::tip
command from the baltip package by
Alex Plotnikov:
baltip::tip nb message -nbktab tabWindow ...
-tab
option of the
tooltip::tooltip
command was added in version 1.6
of the tooltip package. The baltip::tip
command accepts a great variety of additional options, too. The
baltip package can be downloaded from the location
https://chiselapp.com/user/aplsimple/repository/baltip/download/
pathName see
tabId
tabId
becomes visible in
it. Note that when a tab gets selected, this command is
automatically invoked for it, in order to make that tab visible.pathName tabattrib
tabId ?name ?value name value
...??
tabId
. If no name
is
specified, the command returns a list of pairs, each of which contains
the name and the value of an attribute for the tab. If
name
is specified with no
value
, then the command returns the value of the
one named tab attribute, or an empty string if no corresponding value
exists (you can use the hastabattrib
subcommand to distinguish
this case from the one that the value of an existing tab
attribute is an empty string). If one or more
name
-value
pairs are specified,
then the command sets the given tab attribute(s) to the given
value(s); in this case the return value is an empty string. Each
name
may be an arbitrary string.pathName
unsetattrib name
name
. Returns an
empty string.pathName
unsettabattrib tabId name
name
for the tab given by
tabId
. Returns an empty string.<<NotebookTabChanged>>
virtual event. This holds true for scrollednotebook widgets,
too.<<Button3>>
as
<Button-3>
for all windowing systems and
additionally as <Control-Button-1>
for Mac OS
X/11+. If this event occurs over a tab of a ttk::notebook or
scrollednotebook whose disabled
widget state flag is
not set, and the Tk version is 8.5a2 or later, then the widget generates
a <<MenuItemsRequested>>
virtual event,
by invoking event generate
with the
-data
option set to a list consisting of the path
name of an empty pop-up menu and the numerical index of the tab in
question. (The support for this option was introduced in Tk
8.5a2.) If the application creates a binding for this virtual
event, the binding script can access the user data as the value of the
%d
field, with the goal to populate the menu with
application-specific entries. Note that the pop-up menu is posted
with a delay of 100 ms, to make sure that it will appear readily
populated by the application.
The following example provides a pop-up menu item for closing the tabs
of a ttk::notebook or scrollednotebook widget $nb
:
bind $nb <<MenuItemsRequested>> { populateMenu %W %d } proc populateMenu {nb data} { foreach {menu tabIdx} $data {} $menu add command -label "Close Tab" -command [list $nb forget $tabIdx] }
<<NotebookTabMoved>>
,
<<NotebookTabClosed>>
, and
<<CloseTabRequested>>
.normal
cyclically
following/preceding the currently selected one. (Note that the
same effect can also be achieved with the keys Right
,
Left
, Control-Tab
, and
Control-Shift-Tab
.) On the windowing system
aqua
, if the Option
key is down while
the mouse wheel is being rotated then a wheel tick selects the 10'th
tab of state normal
cyclically following/preceding
the currently selected one (modulo the number of tabs). The same
holds true on the windowing systems x11
and
win32
if the Tk version is 8.7a4 or later and the
mouse wheel is rotated with the Alt
key down.closetab
element (if any) and then dragged
outside that tab then (in case of a scrollednotebook provided that the
value of the widget's -movabletabs
option is true) the mouse
cursor takes on the shape of a left/right arrow, indicating that the
tab in question is being moved to another position. This
operation ends when mouse button 1 is released, and can be canceled by
pressing the Escape
key. In both cases, the mouse
cursor is reset to its original value, specified by the
-cursor
configuration option. After releasing
mouse button 1, the source tab is moved to the position previously
pointed to by the arrow (provided that the action was not canceled via
Escape
). If the Tk version is 8.5a2 or later then
after moving the tab to its new position, the widget generates a
<<NotebookTabMoved>>
virtual event, by
invoking event generate
with the
-data
option set to a list consisting of the path
name of the widget contained in the source pane and the numerical index
of the target tab position. (The support for this option was
introduced in Tk 8.5a2.) All the above works also for a
ttk::notebook with vertical tab layout, with the only difference that
for the duration of the drag, the cursor is set to one having the shape
of an up/down arrow.closetab
element: If mouse button 1
is pressed over the closetab
element (if any) of a
tab and later released over the same element then, provided that both
the value of the tab's -state
option and the state
of its closetab
element is
normal
, the tab is closed by means of the widget's
forget
subcommand. Recall that this operation
can get canceled by the command specified as the value of the
-forgetcommand
option;
if this was not the case and the Tk version is 8.5a2 or later then,
after closing the tab, the widget generates a
<<NotebookTabClosed>>
virtual event, by
invoking event generate
with the
-data
option set to the path name of the widget
contained in that tab's pane.closetab
element: If mouse button 1 is pressed
over the closetab
element (if any) of a tab and
later released over the same element then, provided that both the
value of the tab's -state
option and the state of
its closetab
element is
normal
, an action depending on the Tk version is
taken:
<<CloseTabRequested>>
virtual
event, by invoking event generate
with the -data
option set to the numerical
index of the tab in question. It is the responsibility of
the application to create a binding for this virtual event and to
close the tab from within the binding script by invoking the
widget's forget
subcommand if appropriate,
like in the following example:
bind $nb <<CloseTabRequested>> { closeTab %W %d } proc closeTab {nb tabIdx} { set btn [tk_messageBox -title "Close Tab?" -icon question \ -message "Do you really want to close the tab?" -type yesno if {$btn eq "yes"} { $nb forget $tabIdx # Optionally: set widget [lindex [$nb tabs] $tabIdx] event generate $nb <<NotebookTabClosed>> -data $widget } }
forget
subcommand. (Recall that the
-data
option for virtual events was introduced
in Tk 8.5a2.)disabled
state flag is
set then none of the above actions occur: the tabs are completely
insensitive.closetab
Style ElementThe Scrollutil_tile package automatically creates a new style element
named closetab
, whose shape resembles that of an x
character. The element's size depends on the display's scaling
percentage (100
, 125
, 150
,
175
, or 200
), while its foreground color is
theme-specific and is updated whenever the theme changes.
You can add this element to the tabs of a ttk::notebook style (like
TNotebook
or My.TNotebook
) by using
the scrollutil::addclosetab
command, thus making the tabs of any ttk::notebook or scrollednotebook widget
of that style closable by the user.
For the opposite operation the Scrollutil_tile package provides the
scrollutil::removeclosetab
command.
The state (normal
or disabled
) of
of the closetab
element of a ttk::notebook or scrollednotebook
tab can be set and queried with the aid of the scrollutil::closetabstate
command.
scrollutil::addclosetab
Commandscrollutil::addclosetab
– Add the
closetab
element to the tabs of a ttk::notebook stylepackage require scrollutil_tile scrollutil::addclosetab notebookStyle
scrollutil::addclosetab
command is
provided by the Scrollutil_tile package, but not by Scrollutil.notebookStyle.Tab
corresponding to a given ttk::notebook style (like
TNotebook
or My.TNotebook
) by
adding the closetab
element to
it. This makes the tabs of any ttk::notebook or scrollednotebook
widget whose -style
option was set to
notebookStyle
closable by the user. If the
closetab
element was already present in the style
notebookStyle.Tab
then the command returns
without performing any action.scrollutil::removeclosetab
Commandscrollutil::removeclosetab
– Remove the
closetab
element from the tabs of a ttk::notebook stylepackage require scrollutil_tile scrollutil::removeclosetab notebookStyle
scrollutil::removeclosetab
command is
provided by the Scrollutil_tile package, but not by Scrollutil.notebookStyle.Tab
corresponding to a given ttk::notebook style (like
TNotebook
or My.TNotebook
) by
removing the closetab
element
from it. If the closetab
element was not present
in the style notebookStyle.Tab
then the command
returns without performing any action.scrollutil::closetabstate
Commandscrollutil::closetabstate
– Set or query the state
of the closetab
element of a ttk::notebook or scrollednotebook
tabpackage require scrollutil_tile scrollutil::closetabstate notebook tabId ?normal|disabled?
scrollutil::closetabstate
command is
provided by the Scrollutil_tile package, but not by Scrollutil.closetab
element of the tab specified by
tabId
of the ttk::notebook or scrollednotebook widget
notebook
. The optional argument specifies the
state as normal
or disabled
.
Without this argument the command returns the current state of the tab's
closetab
element.disabled
state flag is not
set and the value of the tab's -state
option is
normal
, the differences between the two
closetab
states are as follows:
normal
state, the
closetab
element is shown in white color on light
red background when hovered, and in white color on dark red background
when pressed with mouse button 1. By releasing mouse button 1
over the same element, the action described under points 4 and 5 of the
FURTHER BINDINGS section above is
triggered.disabled
state, the
closetab
element, both when hovered and when
pressed, is shown in the same theme-specific foreground color as a
disabled text, and pressing and later releasing mouse button 1 over it
has no effect.closetabstate
scrollednotebook widget
subcommand is a convenient shortcut for this command.