ttk::spinbox(3tk)

πŸ“¦
version 9.0.4 Β· 3 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

ttk::spinbox β€” the text field widget that lets you pick stuff, bestie πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

ttk::spinbox pathName ?options?

πŸ’… DESCRIPTION πŸ’…

Okay so picture this: a ttk::spinbox is literally a ttk::entry widget, right, but it comes with up and down buttons built in πŸ”ΌπŸ”½. Those buttons either nudge a numeric value, or let you pick from a whole set of values. Iconic.

And the way that it just… has every single feature of the ttk::entry widget?? Including support for the -textvariable option, so you can link whatever the widget is displaying straight to a Tcl variable. Chef's kiss 🧚


🌸 STANDARD OPTIONS 🌸

  • -class
  • -cursor
  • -state
  • -style
  • -takefocus
  • -xscrollcommand
  • -placeholder
  • -placeholderforeground

If you want the tea on these, the ttk_widget manual entry has all the details, fr fr.


🌈 STANDARD OPTIONS 🌈

  • -validate
  • -validatecommand

And for these two, go check the ttk_entry manual entry, bestie πŸ’œ


πŸ‘‘ WIDGET-SPECIFIC OPTIONS πŸ‘‘

-command

  • Command-Line Name: -command
  • Database Name: command
  • Database Class: Command

Specifies a Tcl command that gets invoked whenever a spinbutton is invoked.

-format

  • Command-Line Name: -format
  • Database Name: format
  • Database Class: Format

Specifies an alternate format to use when setting the string value while you're working with the -from and -to range. Heads up: this has to be a format specifier of the form %<pad>.<pad>f, because it's formatting a floating-point number. No cap.

-from

  • Command-Line Name: -from
  • Database Name: from
  • Database Class: From

A floating-point value specifying the lowest value for the spinbox. It works together with -to and -increment to set up a numerical range.

-increment

  • Command-Line Name: -increment
  • Database Name: increment
  • Database Class: Increment

A floating-point value specifying how much the value changes each time one of the widget spin buttons gets pressed. The up button applies a positive increment, the down button applies a negative increment. Balance ✨

-to

  • Command-Line Name: -to
  • Database Name: to
  • Database Class: To

A floating-point value specifying the highest permissible value for the widget. See also -from and -increment. range.

-values

  • Command-Line Name: -values
  • Database Name: values
  • Database Class: Values

This has to be a Tcl list of values. If you set this option, it overrides any range you set using the -from, -to and -increment options. Instead, the widget will use the values you specified, starting from the first value. Periodt.

-wrap

  • Command-Line Name: -wrap
  • Database Name: wrap
  • Database Class: Wrap

Has to be a proper boolean value. If it's on, the spinbox will wrap around the values of data in the widget πŸŒ€


πŸ¦‹ INDICES πŸ¦‹

See the ttk::entry manual for the info on indexing characters.


πŸ’– VALIDATION πŸ’–

See the ttk::entry manual for the info on using the -validate and -validatecommand options.


⭐ WIDGET COMMAND ⭐

These subcommands are possible for spinbox widgets, on top of all the commands described for the ttk::entry widget:

  • pathName get β€” returns the spinbox's current value.
  • pathName set value β€” set the spinbox string to value. If a -format option has been configured, then this format will be applied. If formatting fails, or isn't set, or the -values option has been used, then the value is set directly.

πŸ”₯ VIRTUAL EVENTS πŸ”₯

The spinbox widget generates a <<Increment>> virtual event when the user presses <Up>, and a <<Decrement>> virtual event when the user presses <Down>. Little events, big main character energy πŸ’«


πŸ“ STYLING OPTIONS πŸ“

The class name for a ttk::spinbox is TSpinbox.

Dynamic states: active, disabled, focus, readonly.

TSpinbox styling options you can configure with ttk::style are:

  • -arrowcolor color
  • -arrowsize amount
  • -background color

For backwards compatibility, when using the aqua theme (for macOS), this option behaves as an alias for the -fieldbackground, provided that no value is specified for -fieldbackground. Otherwise it is ignored.

  • -bordercolor color
  • -darkcolor color
  • -fieldbackground color
  • -foreground color
  • -insertcolor color
  • -insertwidth amount
  • -lightcolor color
  • -padding padding
  • -placeholderforeground color
  • -selectbackground color
  • -selectforeground color
Some options are only available for specific themes, just so you know πŸ‘€

See the ttk::style manual page for the info on how to configure ttk styles.


πŸ’œ SEE ALSO πŸ’œ

ttk::widget(3tk), ttk::entry(3tk), spinbox(3tk)


🫢 KEYWORDS 🫢

entry, spinbox, widget, text field


And that's the whole page, bestie!! This one's from Tk 8.5 and it's the ttk::spinbox(3tk) manual β€” go forth and spin those values, you absolute icon πŸ‘‘βœ¨πŸ’…

πŸ“¦ where this page comes from