Note
Go to the end to download the full example code.
SpinBox#
This example demonstrates the SpinBox UI element.
Click the up/down buttons to change the value by step, or click the
textbox, type a number and press Enter. The value is always clamped to
[min_val, max_val].
First, let’s import the necessary modules.
from fury.data import fetch_viz_icons
from fury.ui import SpinBox, TextBlock2D
from fury.window import Scene, ShowManager
Fetch the bundled icon set used for the up/down buttons.
fetch_viz_icons()
Data size is approximately 12KB
Dataset is already in place. If you want to fetch it again please first remove the folder C:\Users\magor\.fury\icons
({'icomoon.tar.gz': ('https://github.com/fury-gl/fury-data/raw/refs/heads/master/icons/icomoon.tar.gz', 'BC1FEEA6F58BA3601D6A0B029EB8DFC5F352E21F2A16BA41099A96AA3F5A4735')}, 'C:\\Users\\magor\\.fury\\icons')
Create a Scene.
scene = Scene()
Create a SpinBox with a range of [-20, 20] that moves in steps of 2.
Show the current value in a label that updates whenever it changes.
label = TextBlock2D(
text=f"Value: {spinbox.value}",
position=(270, 310),
font_size=24,
color=(1, 1, 1),
dynamic_bbox=True,
)
scene.add(label)
def on_spinbox_change(sb):
label.message = f"Value: {sb.value}"
spinbox.on_change = on_spinbox_change
Create and start the ShowManager.
current_size = (700, 600)
show_manager = ShowManager(
scene=scene,
size=current_size,
title="FURY SpinBox Example",
)
show_manager.start()

Total running time of the script: (0 minutes 0.194 seconds)