spinbox
Guide: Entry and 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
| Command | Description |
|---|---|
spinbox bbox | Gives the box of the character at INDEX. |
spinbox delete | Deletes the characters from FIRST up to LAST. |
spinbox get | Gives the text of the spinbox. |
spinbox icursor | Moves the insertion cursor to INDEX. |
spinbox identify | Gives the part of the spinbox at a point. |
spinbox index | Gives the number of the place that INDEX names. |
spinbox insert | Inserts TEXT before the character at INDEX. |
spinbox invoke | Steps the value as a press of an arrow does. |
spinbox scan | Scrolls the spinbox by a drag of the mouse. |
spinbox selection | Reads or changes the selected text of the spinbox. |
spinbox set | Gives or sets the text of the spinbox. |
spinbox validate | Runs the script of -validatecommand now. |
spinbox xview | Reads or changes the horizontal view of a text longer than the spinbox. |
spinbox cget | Gives the value of an option of the spinbox. |
spinbox configure | Gives or sets the options of the spinbox. |
Options
| Option | Type | Default | Database name | Description |
|---|---|---|---|---|
-activebackground | color | #ececec | activeBackground | The background color of an arrow while the pointer is over it. |
-background | color | #ffffff | background | The background color of the spinbox. |
-borderwidth | screen distance | 1 | borderWidth | The width of the border of the spinbox. |
-buttonbackground | color | #d9d9d9 | buttonBackground | The background color of the arrows. |
-buttoncursor | cursor name | empty | buttonCursor | The shape of the pointer over the arrows. |
-buttondownrelief | relief | raised | buttonDownRelief | The relief of the down arrow. |
-buttonuprelief | relief | raised | buttonUpRelief | The relief of the up arrow. |
-command | script | empty | command | A script that runs when the user or invoke steps the value. |
-cursor | cursor name | xterm | cursor | The shape of the pointer over the spinbox. |
-disabledbackground | color | #d9d9d9 | disabledBackground | The background color while the state is disabled. |
-disabledforeground | color | #a3a3a3 | disabledForeground | The text color while the state is disabled. |
-exportselection | boolean | 1 | exportSelection | Whether the selection of the spinbox is also the selection of the application. |
-font | font | TkTextFont | font | The font of the text. |
-foreground | color | #000000 | foreground | The color of the text. |
-format | string | empty | format | The format of a number that the arrows make. |
-from | number | 0 | from | The lowest value of the range of numbers. |
-highlightbackground | color | #d9d9d9 | highlightBackground | The color of the focus ring while the spinbox has no focus, in the look of Tk on X11. |
-highlightcolor | color | #000000 | highlightColor | The color of the focus ring while the spinbox has the focus, in the look of Tk on X11. |
-highlightthickness | screen distance | 1 | highlightThickness | The width of the focus ring, in the look of Tk on X11. |
-increment | number | 1 | increment | The step of the arrows. |
-insertbackground | color | #000000 | insertBackground | The color of the insertion cursor. |
-insertborderwidth | screen distance | 0 | insertBorderWidth | The width of the border of the insertion cursor. |
-insertofftime | integer | 300 | insertOffTime | The time in milliseconds that the insertion cursor is hidden in each blink. |
-insertontime | integer | 600 | insertOnTime | The time in milliseconds that the insertion cursor shows in each blink. |
-insertwidth | screen distance | 2 | insertWidth | The width of the insertion cursor. |
-invalidcommand | script | empty | invalidCommand | A script that runs when -validatecommand gives false. |
-justify | justification | left | justify | The place of the text in a spinbox wider than the text. |
-relief | relief | sunken | relief | The 3-D look of the border. |
-readonlybackground | color | #d9d9d9 | readonlyBackground | The background color while the state is readonly. |
-repeatdelay | integer | 400 | repeatDelay | The time in milliseconds before a held button starts to repeat. |
-repeatinterval | integer | 100 | repeatInterval | The time in milliseconds between two repeats of a held button. |
-selectbackground | color | #c3c3c3 | selectBackground | The background color of the selected text. |
-selectborderwidth | screen distance | 0 | selectBorderWidth | The width of the border around the selection. |
-selectforeground | color | #000000 | selectForeground | The text color of the selected text. |
-state | state | normal | state | Whether the user and a script can edit the text. |
-takefocus | string | empty | takeFocus | Whether the Tab key can move the focus to the spinbox. |
-textvariable | variable name | empty | textVariable | A global variable whose value is the text of the spinbox. |
-to | number | 0 | to | The highest value of the range of numbers. |
-validate | validate | none | validate | When the spinbox runs -validatecommand. |
-validatecommand | script | empty | validateCommand | A script that checks a change of the text. |
-values | string | empty | values | A list of the values that the arrows step through. |
-width | integer | 20 | width | The width of the text field of the spinbox in average characters of the font. |
-wrap | boolean | 0 | wrap | Whether the arrows go on from one end of the range to the other end. |
-xscrollcommand | script | empty | xScrollCommand | A command prefix that the spinbox calls when its horizontal view changes. |
-placeholder | string | empty | placeHolder | A hint text that the spinbox shows while it is empty. |
-placeholderforeground | color | #b3b3b3 | placeholderForeground | The 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.

-background {#fde68a}
-background {#bfdbfe}-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.

-borderwidth 0
-borderwidth 1
-borderwidth 4-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
hand2ztk 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 upztk stores each script with no check.
-cursor CURSOR
The shape of the pointer over the spinbox.
Each value side by side: the contact sheet of the cursors
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.

-disabledbackground {#fde68a}-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.

-disabledforeground {#b91c1c}-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.

-font TkDefaultFont
-font TkFixedFont
-font {Helvetica 16 bold}-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.

-foreground {#b91c1c}
-foreground {#2563eb}-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.

-from 0
-from 10-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 1ztk 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.
Each value side by side: the contact sheet of the reliefs
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.

-readonlybackground {#fde68a}-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.

-state normal
-state disabled-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
1ztk 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
4Each 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 1ztk 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.

-values {}
-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.

-width 8
-width 20
-width 30-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 1ztk 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.

-placeholder {}
-placeholder {Your name}-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.

-placeholderforeground {#b91c1c}-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 nocolorBindings
| Event | Description |
|---|---|
<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
| Event | Description |
|---|---|
<<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
- An error of a widget command, such as a bad index, a bad element, or a wrong count of arguments, has the
-errorcodeNONE. Tk 8.6.16 gives a code such asTCL LOOKUP INDEX element bogusorTCL WRONGARGS. -buttoncursoraccepts a name that is not a cursor. Tk 8.6.16 gives the errorbad cursor spec.-activebackground,-buttonbackground,-buttoncursor,-buttondownrelief,-buttonuprelief,-exportselection,-insertborderwidth,-selectborderwidth,-highlightbackground, and-highlightcolorare stored with no effect. The theme gives the look of the arrows.- The selection of a spinbox is not the
PRIMARYselection, soselection getgives an error. -placeholderand-placeholderforegroundare additions of ztk. Tk 8.6.16 has no such options.-highlightthickness,-highlightbackground,-buttonbackground,-buttonuprelief, and-buttondownreliefhave no visible effect yet, and the reliefs other thanflatdraw the same border (ztk#763).
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1