beetlebug▾
/

spinbox

Makes a spinbox: an entry with two arrows that step its value.

spinbox PATHNAME ?OPTION VALUE ...?

Description

Makes a spinbox widget with the name PATHNAME and the options of the call, and makes the command PATHNAME for the widget commands below. A spinbox is an entry with an up arrow and a down arrow. The arrows step a number from -from to -to by -increment, or step through the elements of -values. The user can also type a value.

The parent of PATHNAME must exist, and PATHNAME must not. A spinbox is a Spinbox in CSS and for the option database, and ztk::class gives it a style class for a stylesheet.

The commands of the text, such as insert, delete, index, and selection, are the commands of entry, with the same forms of an index. A change of the text from a script runs the validation of -validate.

Widget commands

CommandDescription
spinbox bboxGives the box of the character at INDEX.
spinbox deleteDeletes the characters from FIRST up to LAST.
spinbox getGives the text of the spinbox.
spinbox icursorMoves the insertion cursor to INDEX.
spinbox identifyGives the part of the spinbox at a point.
spinbox indexGives the number of the place that INDEX names.
spinbox insertInserts TEXT before the character at INDEX.
spinbox invokeSteps the value as a press of an arrow does.
spinbox scanScrolls the spinbox by a drag of the mouse.
spinbox selectionReads or changes the selected text of the spinbox.
spinbox setGives or sets the text of the spinbox.
spinbox validateRuns the script of -validatecommand now.
spinbox xviewReads or changes the horizontal view of a text longer than the spinbox.
spinbox cgetGives the value of an option of the spinbox.
spinbox configureGives or sets the options of the spinbox.

Options

OptionTypeDefaultDatabase nameDescription
-activebackgroundcolor#ecececactiveBackgroundThe background color of an arrow while the pointer is over it.
-backgroundcolor#ffffffbackgroundThe background color of the spinbox.
-borderwidthscreen distance1borderWidthThe width of the border of the spinbox.
-buttonbackgroundcolor#d9d9d9buttonBackgroundThe background color of the arrows.
-buttoncursorcursor nameemptybuttonCursorThe shape of the pointer over the arrows.
-buttondownreliefreliefraisedbuttonDownReliefThe relief of the down arrow.
-buttonupreliefreliefraisedbuttonUpReliefThe relief of the up arrow.
-commandscriptemptycommandA script that runs when the user or invoke steps the value.
-cursorcursor namextermcursorThe shape of the pointer over the spinbox.
-disabledbackgroundcolor#d9d9d9disabledBackgroundThe background color while the state is disabled.
-disabledforegroundcolor#a3a3a3disabledForegroundThe text color while the state is disabled.
-exportselectionboolean1exportSelectionWhether the selection of the spinbox is also the selection of the application.
-fontfontTkTextFontfontThe font of the text.
-foregroundcolor#000000foregroundThe color of the text.
-formatstringemptyformatThe format of a number that the arrows make.
-fromnumber0fromThe lowest value of the range of numbers.
-highlightbackgroundcolor#d9d9d9highlightBackgroundThe color of the focus ring while the spinbox has no focus, in the look of Tk on X11.
-highlightcolorcolor#000000highlightColorThe color of the focus ring while the spinbox has the focus, in the look of Tk on X11.
-highlightthicknessscreen distance1highlightThicknessThe width of the focus ring, in the look of Tk on X11.
-incrementnumber1incrementThe step of the arrows.
-insertbackgroundcolor#000000insertBackgroundThe color of the insertion cursor.
-insertborderwidthscreen distance0insertBorderWidthThe width of the border of the insertion cursor.
-insertofftimeinteger300insertOffTimeThe time in milliseconds that the insertion cursor is hidden in each blink.
-insertontimeinteger600insertOnTimeThe time in milliseconds that the insertion cursor shows in each blink.
-insertwidthscreen distance2insertWidthThe width of the insertion cursor.
-invalidcommandscriptemptyinvalidCommandA script that runs when -validatecommand gives false.
-justifyjustificationleftjustifyThe place of the text in a spinbox wider than the text.
-reliefreliefsunkenreliefThe 3-D look of the border.
-readonlybackgroundcolor#d9d9d9readonlyBackgroundThe background color while the state is readonly.
-repeatdelayinteger400repeatDelayThe time in milliseconds before a held button starts to repeat.
-repeatintervalinteger100repeatIntervalThe time in milliseconds between two repeats of a held button.
-selectbackgroundcolor#c3c3c3selectBackgroundThe background color of the selected text.
-selectborderwidthscreen distance0selectBorderWidthThe width of the border around the selection.
-selectforegroundcolor#000000selectForegroundThe text color of the selected text.
-statestatenormalstateWhether the user and a script can edit the text.
-takefocusstringemptytakeFocusWhether the Tab key can move the focus to the spinbox.
-textvariablevariable nameemptytextVariableA global variable whose value is the text of the spinbox.
-tonumber0toThe highest value of the range of numbers.
-validatevalidatenonevalidateWhen the spinbox runs -validatecommand.
-validatecommandscriptemptyvalidateCommandA script that checks a change of the text.
-valuesstringemptyvaluesA list of the values that the arrows step through.
-widthinteger20widthThe width of the text field of the spinbox in average characters of the font.
-wrapboolean0wrapWhether the arrows go on from one end of the range to the other end.
-xscrollcommandscriptemptyxScrollCommandA command prefix that the spinbox calls when its horizontal view changes.
-placeholderstringemptyplaceHolderA hint text that the spinbox shows while it is empty.
-placeholderforegroundcolor#b3b3b3placeholderForegroundThe color of the hint text of -placeholder.

-activebackground COLOR

The background color of an arrow while the pointer is over it.

In Tk, the arrow under the pointer has this color. ztk stores the value with no effect: the theme gives the color of the arrows.

% spinbox .activebackground -activebackground {#336699}
> .activebackground cget -activebackground
#336699
% spinbox .activebackground2 -activebackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-background COLOR

The background color of the spinbox.

The color behind the content. -bg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

spinbox with -textvariable ::ref::name and -background {#fde68a}-background {#fde68a}spinbox with -textvariable ::ref::name and -background {#bfdbfe}-background {#bfdbfe}
Each with -textvariable ::ref::name.
% spinbox .background -background {#336699}
> .background cget -background
#336699
% spinbox .background2 -background nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-borderwidth DISTANCE

The width of the border of the spinbox.

The width of the border around the spinbox. -bd is the same option. A distance is a count of pixels, or a number with c, i, m, or p for centimeters, inches, millimeters, or points.

spinbox with -textvariable ::ref::name -relief solid and -borderwidth 0-borderwidth 0spinbox with -textvariable ::ref::name -relief solid and -borderwidth 1-borderwidth 1spinbox with -textvariable ::ref::name -relief solid and -borderwidth 4-borderwidth 4
Each with -textvariable ::ref::name -relief solid.
% spinbox .borderwidth -borderwidth 4
> .borderwidth cget -borderwidth
4
% spinbox .borderwidth2 -borderwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-buttonbackground COLOR

The background color of the arrows.

In Tk, the two arrows have this color. ztk stores the value with no effect.

% spinbox .buttonbackground -buttonbackground {#336699}
> .buttonbackground cget -buttonbackground
#336699
% spinbox .buttonbackground2 -buttonbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-buttoncursor CURSOR

The shape of the pointer over the arrows.

In Tk, the pointer has this shape over the arrows. ztk stores the value with no effect.

% spinbox .buttoncursor -buttoncursor hand2
> .buttoncursor cget -buttoncursor
hand2

ztk stores each value with no check. Tk 8.6.16 gives an error for a name that is not a cursor.

-buttondownrelief RELIEF

The relief of the down arrow.

In Tk, the down arrow has this 3-D look. ztk stores the value with no effect.

Values: flat, groove, raised, ridge, solid, sunken.

% spinbox .buttondownrelief -buttondownrelief groove
> .buttondownrelief cget -buttondownrelief
groove
% spinbox .buttondownrelief2 -buttondownrelief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy

-buttonuprelief RELIEF

The relief of the up arrow.

In Tk, the up arrow has this 3-D look. ztk stores the value with no effect.

Values: flat, groove, raised, ridge, solid, sunken.

% spinbox .buttonuprelief -buttonuprelief groove
> .buttonuprelief cget -buttonuprelief
groove
% spinbox .buttonuprelief2 -buttonuprelief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy

-command SCRIPT

A script that runs when the user or invoke steps the value.

Before the run, %W in the script changes to the path name, %s to the new text, and %d to up or down. A change of set, of the text, or of the variable runs no script.

% spinbox .command -to 5 -command {set ::step [list %s %d]}
> .command invoke buttonup
> set step
1 up

ztk stores each script with no check.

-cursor CURSOR

The shape of the pointer over the spinbox.

A cursor name of Tk, such as hand2 or xterm. A value that starts with @ names a file. An empty value uses the cursor of the parent.

% spinbox .cursor -cursor hand2
> .cursor cget -cursor
hand2
% spinbox .cursor2 -cursor nocursor
bad cursor spec "nocursor"
-errorcode TK VALUE CURSOR

-disabledbackground COLOR

The background color while the state is disabled.

The color behind the text while -state is disabled. With no value from the script, the theme gives the color.

spinbox with -textvariable ::ref::name -state disabled and -disabledbackground {#fde68a}-disabledbackground {#fde68a}
Each with -textvariable ::ref::name -state disabled.
% spinbox .disabledbackground -disabledbackground {#336699}
> .disabledbackground cget -disabledbackground
#336699
% spinbox .disabledbackground2 -disabledbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-disabledforeground COLOR

The text color while the state is disabled.

The color of the text while -state is disabled.

spinbox with -textvariable ::ref::name -state disabled and -disabledforeground {#b91c1c}-disabledforeground {#b91c1c}
Each with -textvariable ::ref::name -state disabled.
% spinbox .disabledforeground -disabledforeground {#336699}
> .disabledforeground cget -disabledforeground
#336699
% spinbox .disabledforeground2 -disabledforeground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-exportselection BOOLEAN

Whether the selection of the spinbox is also the selection of the application.

In Tk, a true value makes a selection in the spinbox the PRIMARY selection, and selection get gives it. ztk stores the value with no effect: the selection of the spinbox is not the PRIMARY selection.

% spinbox .exportselection -exportselection 0
> .exportselection cget -exportselection
0
% spinbox .exportselection2 -exportselection maybe
expected boolean value but got "maybe"
-errorcode TCL VALUE NUMBER

-font FONT

The font of the text.

A font name, such as TkDefaultFont, or a font description, such as {Helvetica 12 bold}. A family that does not exist falls back to a font of the system.

spinbox with -textvariable ::ref::name and -font TkDefaultFont-font TkDefaultFontspinbox with -textvariable ::ref::name and -font TkFixedFont-font TkFixedFontspinbox with -textvariable ::ref::name and -font {Helvetica 16 bold}-font {Helvetica 16 bold}
Each with -textvariable ::ref::name.
% spinbox .font -font {Helvetica 12 bold}
> .font cget -font
Helvetica 12 bold
% spinbox .font2 -font {Helvetica big}
expected integer but got "big"
-errorcode TCL VALUE NUMBER

-foreground COLOR

The color of the text.

The color of the text. -fg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

spinbox with -textvariable ::ref::name and -foreground {#b91c1c}-foreground {#b91c1c}spinbox with -textvariable ::ref::name and -foreground {#2563eb}-foreground {#2563eb}
Each with -textvariable ::ref::name.
% spinbox .foreground -foreground {#336699}
> .foreground cget -foreground
#336699
% spinbox .foreground2 -foreground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-format FORMAT

The format of a number that the arrows make.

A format of format with one %f, such as %.2f or %5.1f. An empty value uses the fewest digits that show -increment.

% spinbox .format -from 0 -to 1 -increment 0.25 -format %.2f
> .format invoke buttonup
> .format get
0.25
% spinbox .format2 -format %q
bad spinbox format specifier "%q"
-errorcode NONE

-from NUMBER

The lowest value of the range of numbers.

With no -values, the arrows step a number from -from to -to. -to must not be less than -from.

spinbox with -to 100 and -from 0-from 0spinbox with -to 100 and -from 10-from 10
Each with -to 100.
# The spinbox starts at `-from`.
% spinbox .from -from 1 -to 10
> .from get
1
% spinbox .from2 -from x
expected floating-point number but got "x"
-errorcode TCL VALUE NUMBER

% spinbox .from3 -from 5 -to 1
-to value must be greater than -from value
-errorcode NONE

-highlightbackground COLOR

The color of the focus ring while the spinbox has no focus, in the look of Tk on X11.

The color of the highlight ring of -highlightthickness while the spinbox does not have the focus. ztk stores the value with no effect.

% spinbox .highlightbackground -highlightbackground {#336699}
> .highlightbackground cget -highlightbackground
#336699
% spinbox .highlightbackground2 -highlightbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-highlightcolor COLOR

The color of the focus ring while the spinbox has the focus, in the look of Tk on X11.

The color of the highlight ring of -highlightthickness while the spinbox has the focus. ztk stores the value with no effect.

% spinbox .highlightcolor -highlightcolor {#336699}
> .highlightcolor cget -highlightcolor
#336699
% spinbox .highlightcolor2 -highlightcolor nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-highlightthickness DISTANCE

The width of the focus ring, in the look of Tk on X11.

The width of the ring around the spinbox that shows the focus. The modern theme draws the focus with the stylesheet.

% spinbox .highlightthickness -highlightthickness 4
> .highlightthickness cget -highlightthickness
4
% spinbox .highlightthickness2 -highlightthickness x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-increment NUMBER

The step of the arrows.

Each press of an arrow adds or subtracts this number.

% spinbox .increment -increment 2.5
> .increment cget -increment
2.5
% spinbox .increment2 -increment x
expected floating-point number but got "x"
-errorcode TCL VALUE NUMBER

-insertbackground COLOR

The color of the insertion cursor.

The color of the bar that marks the place of the next typed character.

% spinbox .insertbackground -insertbackground {#336699}
> .insertbackground cget -insertbackground
#336699
% spinbox .insertbackground2 -insertbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-insertborderwidth DISTANCE

The width of the border of the insertion cursor.

In Tk, the insertion cursor can have a 3-D border of this width. ztk stores the value with no effect, and cget gives the value of the script.

% spinbox .insertborderwidth -insertborderwidth 4
> .insertborderwidth cget -insertborderwidth
4
% spinbox .insertborderwidth2 -insertborderwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-insertofftime N

The time in milliseconds that the insertion cursor is hidden in each blink.

0 stops the blink, and the cursor stays on.

% spinbox .insertofftime -insertofftime 5
> .insertofftime cget -insertofftime
5
% spinbox .insertofftime2 -insertofftime x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-insertontime N

The time in milliseconds that the insertion cursor shows in each blink.

The cursor blinks only while the spinbox has the focus and -insertofftime is more than 0.

% spinbox .insertontime -insertontime 5
> .insertontime cget -insertontime
5
% spinbox .insertontime2 -insertontime x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-insertwidth DISTANCE

The width of the insertion cursor.

A distance is a count of pixels, or a number with c, i, m, or p for centimeters, inches, millimeters, or points.

% spinbox .insertwidth -insertwidth 4
> .insertwidth cget -insertwidth
4
% spinbox .insertwidth2 -insertwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-invalidcommand SCRIPT

A script that runs when -validatecommand gives false.

The script runs after the validation rejects a change. It has the same % substitutions as -validatecommand. -invcmd is the same option.

% spinbox .invalidcommand -invalidcommand {set ::done 1}
> .invalidcommand cget -invalidcommand
set ::done 1

ztk stores each script with no check.

-justify SIDE

The place of the text in a spinbox wider than the text.

The place of the text in the text field: at the left side, in the middle, or at the right side.

Values: left, right, center.

% spinbox .justify -justify right
> .justify cget -justify
right
% spinbox .justify2 -justify middle
bad justification "middle": must be left, right, or center
-errorcode TCL LOOKUP INDEX justification middle

-relief RELIEF

The 3-D look of the border.

The style of the border: raised and sunken look 3-D, and groove and ridge are lines. The theme draws the border, and the CSS of the theme can give a relief its own look with border-style.

Values: flat, groove, raised, ridge, solid, sunken.

% spinbox .relief -relief groove
> .relief cget -relief
groove
% spinbox .relief2 -relief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy

-readonlybackground COLOR

The background color while the state is readonly.

The color behind the text while -state is readonly. With no value from the script, the theme gives the color.

spinbox with -textvariable ::ref::name -state readonly and -readonlybackground {#fde68a}-readonlybackground {#fde68a}
Each with -textvariable ::ref::name -state readonly.
% spinbox .readonlybackground -readonlybackground {#336699}
> .readonlybackground cget -readonlybackground
#336699
% spinbox .readonlybackground2 -readonlybackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-repeatdelay N

The time in milliseconds before a held button starts to repeat.

A press that is held on an arrow repeats its step after this delay.

% spinbox .repeatdelay -repeatdelay 5
> .repeatdelay cget -repeatdelay
5
% spinbox .repeatdelay2 -repeatdelay x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-repeatinterval N

The time in milliseconds between two repeats of a held button.

A held press on an arrow repeats its step at this interval after -repeatdelay.

% spinbox .repeatinterval -repeatinterval 5
> .repeatinterval cget -repeatinterval
5
% spinbox .repeatinterval2 -repeatinterval x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-selectbackground COLOR

The background color of the selected text.

The color behind the characters of the selection. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

% spinbox .selectbackground -selectbackground {#336699}
> .selectbackground cget -selectbackground
#336699
% spinbox .selectbackground2 -selectbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-selectborderwidth DISTANCE

The width of the border around the selection.

In Tk, the selection can have a 3-D border of this width. ztk stores the value with no effect.

% spinbox .selectborderwidth -selectborderwidth 4
> .selectborderwidth cget -selectborderwidth
4
% spinbox .selectborderwidth2 -selectborderwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-selectforeground COLOR

The text color of the selected text.

The color of the characters of the selection.

% spinbox .selectforeground -selectforeground {#336699}
> .selectforeground cget -selectforeground
#336699
% spinbox .selectforeground2 -selectforeground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-state STATE

Whether the user and a script can edit the text.

normal allows edits. readonly blocks the edits of the keyboard and of insert and delete, and the arrows and invoke still step the value. disabled blocks the edits and the arrows, and draws the text with -disabledforeground. set changes the text in each state.

Values: disabled, normal, readonly.

spinbox with -textvariable ::ref::name and -state normal-state normalspinbox with -textvariable ::ref::name and -state disabled-state disabled
Each with -textvariable ::ref::name.
# The arrows of a readonly spinbox still work.
% spinbox .state -to 9 -state readonly
> .state invoke buttonup
> .state get
1
% spinbox .state2 -state busy
bad state "busy": must be disabled, normal, or readonly
-errorcode TCL LOOKUP INDEX state busy

-takefocus TEXT

Whether the Tab key can move the focus to the spinbox.

1 puts the spinbox in the order of the Tab key, and 0 leaves it out. An empty value uses the default rule of Tk for the widget. In Tk the value can also be a script, and its result is the answer. ztk stores each value with no check.

% spinbox .takefocus -takefocus 1
> .takefocus cget -takefocus
1

ztk stores each value of the option with no check.

-textvariable VAR

A global variable whose value is the text of the spinbox.

The spinbox shows the value of the global variable VAR, and changes its text when the variable changes. A change of the text sets the variable.

% set count 3
> spinbox .textvariable -to 9 -textvariable count
> .textvariable invoke buttonup
> set count
4

Each name is a valid variable name.

-to NUMBER

The highest value of the range of numbers.

The up arrow stops at this value, unless -wrap is on.

% spinbox .to -to 2
> .to set 2
> .to invoke buttonup
> .to get
2
% spinbox .to2 -to x
expected floating-point number but got "x"
-errorcode TCL VALUE NUMBER

-validate WORD

When the spinbox runs -validatecommand.

none runs no validation. key runs it at each change by the keyboard, focus, focusin, and focusout at a change of the focus, and all at each of these. An error in the script, or a script that changes the text, sets the mode to none.

Values: all, key, focus, focusin, focusout, none.

# The script rejects the x.
% spinbox .validate -validate key -vcmd {string is digit %P}
> .validate insert 0 42
> .validate insert end x
> .validate get
42
% spinbox .validate2 -validate bogus
bad validate "bogus": must be all, key, focus, focusin, focusout, or none
-errorcode TCL LOOKUP INDEX validate bogus

-validatecommand SCRIPT

A script that checks a change of the text.

The script gives a boolean. A false result rejects the change, and the spinbox keeps its old text. Before the run, %d, %i, %P, %s, %S, %v, %V, and %W in the script change to facts of the change. -vcmd is the same option.

% spinbox .validatecommand -validatecommand {set ::done 1}
> .validatecommand cget -validatecommand
set ::done 1

ztk stores each script with no check. An error of the script sets -validate to none.

-values LIST

A list of the values that the arrows step through.

With a list, the arrows step through its elements and -from, -to, and -increment have no effect. The spinbox starts with the first element.

spinbox with -values {}-values {}spinbox with -values {Small Medium Large}-values {Small Medium Large}
% spinbox .values -values {red green blue}
> .values invoke buttonup
> .values get
green
% spinbox .values2 -values {a {b}c}
list element in braces followed by "c" instead of space
-errorcode TCL VALUE LIST JUNK

-width CHARS

The width of the text field of the spinbox in average characters of the font.

The spinbox asks for room for this count of characters and for its arrows. 0 or less makes it as wide as its text.

spinbox with -textvariable ::ref::name and -width 8-width 8spinbox with -textvariable ::ref::name and -width 20-width 20spinbox with -textvariable ::ref::name and -width 30-width 30
Each with -textvariable ::ref::name.
% spinbox .width -width 5
> .width cget -width
5
% spinbox .width2 -width x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-wrap BOOLEAN

Whether the arrows go on from one end of the range to the other end.

With a true value, the up arrow at the last value goes to the first value, and the down arrow at the first value goes to the last value.

% spinbox .wrap -values {a b c} -wrap 1
> .wrap invoke buttondown
> .wrap get
c
% spinbox .wrap2 -wrap maybe
expected boolean value but got "maybe"
-errorcode TCL VALUE NUMBER

-xscrollcommand SCRIPT

A command prefix that the spinbox calls when its horizontal view changes.

The spinbox calls the prefix with two fractions, the first and the last visible part of the content, from 0 to 1. The usual value is {.sb set} for a scrollbar .sb.

% spinbox .xscrollcommand -xscrollcommand {set ::done 1}
> .xscrollcommand cget -xscrollcommand
set ::done 1

ztk stores each script with no check. An error of the script shows at the time of the call.

-placeholder TEXT

A hint text that the spinbox shows while it is empty.

The spinbox shows the text in the color of -placeholderforeground while it has no text. The hint is not part of the value. This option is an addition of ztk.

spinbox with -textvariable ::ref::empty and -placeholder {}-placeholder {}spinbox with -textvariable ::ref::empty and -placeholder {Your name}-placeholder {Your name}
Each with -textvariable ::ref::empty.
# The hint is not part of the text.
% spinbox .placeholder -placeholder Count
> list [.placeholder cget -placeholder] [.placeholder get]
Count {}

Each string is a valid hint.

-placeholderforeground COLOR

The color of the hint text of -placeholder.

An empty value uses a gray of the theme. This option is an addition of ztk.

spinbox with -textvariable ::ref::empty -placeholder Your name and -placeholderforeground {#b91c1c}-placeholderforeground {#b91c1c}
Each with -textvariable ::ref::empty -placeholder Your name.
% spinbox .placeholderforeground -placeholderforeground #888888
> .placeholderforeground cget -placeholderforeground
#888888
% spinbox .placeholderforeground2 -placeholderforeground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

Bindings

EventDescription
<Key>Inserts the character of the key at the insert cursor, in place of the selection. Tab, Return, Escape, and the keys with Control or Alt insert no text.
<Key-BackSpace>Deletes the selection, or the character before the insert cursor.
<Key-Delete>Deletes the selection, or the character after the insert cursor.
<Key-Left>Moves the insert cursor one character to the left and clears the selection. With Shift, the selection grows or shrinks to the new place.
<Key-Right>Moves the insert cursor one character to the right and clears the selection. With Shift, the selection grows or shrinks to the new place.
<Control-Key-Left>Moves the insert cursor to the start of the word before it.
<Control-Key-Right>Moves the insert cursor to the end of the word after it.
<Key-Home>Moves the insert cursor to the start of the text. With Shift, the selection grows to the start. Control-a does the same as Home.
<Key-End>Moves the insert cursor to the end of the text. With Shift, the selection grows to the end. Control-e does the same as End.
<Button-1>Places the insert cursor at the pointer, clears the selection, and gives the widget the focus.
<B1-Motion>Selects the text from the place of the press to the pointer, and scrolls the text when the pointer is past an end.
<Shift-Button-1>The selection grows or shrinks to the pointer.
<Double-Button-1>Selects the word under the pointer.
<Triple-Button-1>Selects all of the text.
<Shift-MouseWheel>Scrolls the text to the left or to the right.
<FocusIn>The insert cursor shows and blinks.
<FocusOut>The insert cursor goes.
<Control-Key-c>Sends <<Copy>>.
<Control-Key-x>Sends <<Cut>>.
<Control-Key-v>Sends <<Paste>>.
<Control-Key-z>Sends <<Undo>>.
<Control-Key-y>Sends <<Redo>>. Control-Shift-z does the same.
<Control-Key-slash>Sends <<SelectAll>>.
<Control-Key-backslash>Sends <<SelectNone>>.
<Key-Up>Runs invoke buttonup: the next value of -values, or the value plus -increment, and then the -command script.
<Key-Down>Runs invoke buttondown: the value before in -values, or the value minus -increment, and then the -command script.

Virtual events

EventDescription
<<Copy>>Puts the selected text on the clipboard. With -show, the clipboard gets no text.
<<Cut>>Puts the selected text on the clipboard and deletes it.
<<Paste>>Inserts the text of the clipboard at the insert cursor, in place of the selection.
<<Clear>>Deletes the selected text.
<<Undo>>Undoes the last edit.
<<Redo>>Makes the last edit that <<Undo>> undid again.
<<SelectAll>>Selects all of the text. event generate .s <<SelectAll>> sends it.
<<SelectNone>>Clears the selection.
<<PrevLine>>The same as the Up key.
<<NextLine>>The same as the Down key.

Returns

PATHNAME.

Examples

% spinbox .copies -from 1 -to 99
> .copies invoke buttonup
> .copies get
2

% spinbox .size -values {Small Medium Large}
> .size invoke buttonup
> .size get
Medium

% winfo class [spinbox .go]
Spinbox

Errors

% spinbox .x -foo 1
unknown option "-foo"
-errorcode TK LOOKUP OPTION -foo

% spinbox .twice
> spinbox .twice
window name "twice" already exists in parent
-errorcode TK VALUE WINDOW EXISTS

# The parent .no does not exist.
% spinbox .no.b
bad window path name ".no"
-errorcode TK LOOKUP WINDOW .no

% spinbox
wrong # args: should be "spinbox pathName ?-option value ...?"
-errorcode TCL WRONGARGS

Differences from Tcl

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also