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.0.tar.gz (9.0 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.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for textual_thin_slider-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f0c34c0db76bc922e4c42903a1cb9c7b98aba0f9e986350e1bad78aa3b16c05c
MD5 8efd2e50b82246700e429078adc2d89c
BLAKE2b-256 5b111989276aeaaefb3df8f1a36fc4cc3e57df430fcb701b1a6ff4b7c60df82e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for textual_thin_slider-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c87d3a65246b4a565538aa4b7f8f36aed038530c3c492aaa68567e24a2c0447b
MD5 77fd24ec03f8633b1312ce54e1f8449c
BLAKE2b-256 69e62bcf8642228d75b2925c5f4d525014b5adaccb347c862f315a6fa967ed69

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