Skip to main content

SpinButton

A spin button allows someone to incrementally adjust a value in small steps. It’s mainly used for numeric values, but other values are supported too.

Examples​

Live demo

Basic SpinButton​

import pglet
from pglet import SpinButton, Button, Text
with pglet.page("basic-spinbutton") as page:
def button_clicked(e):
t.value = f"Spinbutton value is: {sb.value}."
page.update()

t = Text()
sb = SpinButton(width='50%', label='Default SpinButton')
b = Button(text='Submit', on_click=button_clicked)
page.add(sb, b, t)

input()

SpinButton with change event​

import pglet
from pglet import SpinButton, Text
with pglet.page("spinbutton-with-change-event") as page:
def spinbutton_changed(e):
t.value = f"SpinButton value changed to {sb.value}"
page.update()

t = Text()
sb = SpinButton(width='50%', label='Default SpinButton', on_change=spinbutton_changed)
page.add(sb, t)

input()

Properties​

NameTypeDefaultDescription
valuenumberCurrent value of the SpinButton.
labelstringDescriptive label for the control.
labelPositionstringleftLabel position: left (default), top, right, bottom.
minnumberThe min value of the SpinButton.
maxnumberThe max value of the SpinButton.
stepnumberThe difference between the two adjacent values of the SpinButton.
iconstringIcon to display alongside the control's label.
focusedboolfalseWhen set to true the focus is set on the control when it's shown on the page or page opened.

| data | string | | Additional data attached to the control. The value is passed in change event data along with the SpinButton value. |

Events​

NameDescription
changeFires when the value of the SpinButton has been changed.
focusFires when the control has received focus.
blurFires when the control has lost focus.