跳转至

Spinbox

This widget style features a input box with a styled border and arrows. The border color is muted by default and changes to primary or the selected color on hover. The border increases in thickness on focus. The arrow color changes to the default or selected color on hover or on focus.

This widget also supports special styles for disabled state, readonly state, and invalid state.

spinbox

# default spinbox style
Spinbox()

# danger colored spinbox style
Spinbox(bootstyle="danger")

Other styles

Disabled spinbox

This widget supports a style reserved for the disabled state, which you can see in the exhibit above. This style cannot be applied via keywords. To apply the disabled style:

# create the widget in a disabled state
Spinbox(state="disabled")

# disable the widget after creation
e = Spinbox()
e.configure(state="disabled")

Readonly spinbox

This widget supports a style reserved for the readonly state, which you can see in the exhibit above. This style cannot be applied via keywords. To apply the readonly style:

# create the widget in a readonly state
Spinbox(state="readonly")

# set the widget readonly state after creation
e = Spinbox()
e.configure(state="readonly")

Invalid spinbox

This style cannot be applied via keywords, but rather is the result of a validation process implemented on the widget. In the Cookbook you will find an example of how to apply validation to an Entry based widget.