Skip to main content

A Textual Spinbox widget

Demo a Textual spinbox

Simply run from the repo with uv

uvx --from git+https://github.com/friscorose/textual-spinbox spinbox_demo

now you can scroll wheel up or down, drag up or down and click the up or down arrows to change the value in the spinbox. A simple ctrl+c to quit.

NB: This widget is also available from PyPI if you want to use pip/pipx to manage your python packages; ie.

uv venv uv pip install textual-spinbox

Use uv to build an app

Build a silly app with a custom Textual spinbox widget using uv.

uv init sillyapp

then

cd sillyapp

edit hello.py to contain the following source

"""A silly demo of the SpinBox widget"""
from calendar import month_name
from textual.app import App, ComposeResult
from textual.reactive import reactive
from textual.widgets import Button, Label
from textual_spinbox import SpinBox

class Statement( Label ):
    """Make label reactive"""
    silly = reactive( "...a silly statement.", recompose=True )

    def compose(self) -> ComposeResult:
        yield Label( self.silly )

class SpinboxApp(App):
    """The main demo app"""
    DEFAULT_CSS = """
    SpinBox {
        width: 13;
    }
    """

    months = list(month_name)[1:]
    things = ['albatross', 'boomerang', 'cat', 'dodo', 'ewe', 'flotilla', 'geriatric', 'hopscotch', 'ice flow', 'jalopy', 'Kobayashi Maru', 'lava', 'mycelium', 'narwhal', 'oil tanker', 'pod', 'quaaltagh', 'rat', 'snail', 'tiptoe', 'ukulele', 'verb', 'wheeriemigo', 'xanthippe', 'yill', 'zymurgy']
    def compose(self) -> ComposeResult:
        yield SpinBox( id="pennies" )
        yield SpinBox( range(1,32), 21, id="date" )
        yield SpinBox( self.months, id="month" )
        yield SpinBox( self.things, "snail", id="thing" )
        yield Button( "Make", variant="primary", id="make" )
        yield Statement()

    def on_button_pressed(self, event: Button.Pressed):
        """What to do when the button is clicked"""
        if event.button.id == "make":
            pennies = self.query_one("#pennies").value
            date = self.query_one("#date").value
            month = self.query_one("#month").value
            thing = self.query_one("#thing").value
            self.query_one("Statement").silly = f"""\
...my bank statement change by {pennies} cents on {month}/{date} \n\
Reason: compulsory {thing} race gambling."""

def exec_main():
    """Allow call by script handler in pyproject"""
    app = SpinboxApp()
    app.run()

if __name__ == "__main__":
    exec_main()

make Textual available to the app

uv add textual

then make the textual-spinbox widget available

uv add "textual-spinbox @ git+https://github.com/friscorose/textual-spinbox"

now run it

uv run hello.py

Release files for textual-spinbox 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for textual-spinbox 0.8.2
File Size Uploaded
textual_spinbox-0.8.2.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textual-spinbox 0.8.2
File Interpreter ABI Platform
textual_spinbox-0.8.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / textual_spinbox-0.8.2.tar.gz

Download URL textual_spinbox-0.8.2.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4cc128cb856d01482eb3f57962d7ec1a3d5d139b841ab684f1ac4f408c69224a
BLAKE2b-256 checksum
How to use checksums
d5d2ac34a02e31b12586094f819eed64ff9911982ef8a63739004a5ff914ea70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.29

Release files / textual_spinbox-0.8.2-py3-none-any.whl

Download URL textual_spinbox-0.8.2-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a690c96a5985dd19d5485e5974501de7bbda1c671cb2ab6aace152d1ac47ebbf
BLAKE2b-256 checksum
How to use checksums
929e57a44cca63ad0eb6f7674ae2b6b2d043f7e77c266b372483c5cf60aae40a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.29

Release history Release notifications | RSS feed

This release

0.8.2 This release

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page