Skip to main content

A thin slider control widget for the Textual UI platform

Project description

Tests Completion Status Coverage Status Supported Python Versions is support

Textual Thin Slider

A thin slider widget for the Textual UI platform. The thin slider widget is only 1 character tall and allows fine control to choose a value within a range. Options include, no value display, percentage or value. Value may displayed on left or right of slider bar.

Slider w/Percent

Installation

pip install thin-textual-slider
uv add thin-textual-slider

Usage

Display Option Enum and Widget Control Arguments

class ThinSliderDisplayOptions(IntEnum):
    """ How should we show values with the slider bar, use bitwise and/or to set/read values. """
    none = 0  # Do not display the percentage or value (default)
    display_left = 1  # Display percentage/value to the left of the slider bar
    display_right = 2  # Display percentage/value to the right of the slider bar 
    show_value = 4  # Show current slider value instead of percentage

class ThinSlider(
    range_min: int,
    range_max: int,
    value: int,
    step: int,
    display_type: ThinSliderDisplayOptions
)

# Programmatically change slider value
slider.value = {new integer value}

Example: Textual App Usage With Event Message

from textual import on
from textual.app import ComposeResult, App
from textual_thin_slider import ThinSlider, ThinSliderDisplayOptions

class SimpleSliderApp(App):
    slider_value: int = 0
    slider_percentage: float = 0.0

    def compose(self) -> ComposeResult:
        yield ThinSlider(
            id="test-slider",
            range_min=0,
            range_max=250,
            display_type=ThinSliderDisplayOptions.display_right | ThinSliderDisplayOptions.show_value
        )

    @on(ThinSlider.Changed, "#test-slider")
    def on_thin_slider_changed(self, event: ThinSlider.Changed) -> None:
        self.slider_value = event.value
        self.slider_percentage = event.control.percent

if __name__ == "__main__":
    app = SimpleSliderApp()
    app.run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textual_thin_slider-1.0.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textual_thin_slider-1.0.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file textual_thin_slider-1.0.1.tar.gz.

File metadata

  • Download URL: textual_thin_slider-1.0.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for textual_thin_slider-1.0.1.tar.gz
Algorithm Hash digest
SHA256 489ae2c1338b6970333bcc2419f925db7e0852721e1a47f0e620af791712b2a4
MD5 8c704779b57d25d76bf126e7e817d344
BLAKE2b-256 bc4c5ee5b6d2b97d29c812b9683160f16ffa9a0f6b69078a97d6645c012c484a

See more details on using hashes here.

File details

Details for the file textual_thin_slider-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for textual_thin_slider-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f5437b0dc40b401a58b252b5d9f72fa194dd37ce7648ed99d2b11f2d702b872
MD5 cf3ce8f6ad7dec55a8b953c777361f1c
BLAKE2b-256 cb5b79c54a223e00f2b6d8f182624551c645be62ed3879fe997933b35be58778

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page