Skip to main content

Transition effects for Textual TUI apps

Project description

Textual Effects

Textual Effects is a transition effects library for textual TUI applications. It provides a series of wipe-like transitions as overlays for content similar to how PowerPoint or Keynote do slide transitions.

The current effects are:

  • Blinds: mimics vertical blinds closing

  • Curtain: a wipe that starts from the top and descends, then re-ascends

  • Drapes: two wipes starting from the left and right

  • Fire: simulates setting fire to the screen

  • Iris: a centred rectangular block that grows in side until it fills the screen

  • Matrix: Matrix-movie like green character lines

  • Scanline: a right-to left line that transitions from top to bottom

  • Water: a dripping water effect until the screen fills

capture.gif

Each effect has an optional call-back mechanism that gets triggered in the middle of the effect. This is typically used to replace the content that you have overlayed so that when the transition is complete new content is present.

Installation

$ pip install textual-effects

Quick Start

The effects are installed as an overlay of an existing widget (typically a Container) using the layers CSS directive. Consider the following structure that you want to overlay:

def compose(self) -> ComposeResult:
    with Container(id="my_content"):
        yield Static("Stuff in my content")
        # and more widgets

To create an overlay, put your existing widget into a wrapping Container which will also contains a sibling Container for the effect. The above code would be replaced with:

def compose(self) -> ComposeResult:

    with Container(id="effect_holder") as self.effect_holder:
        self.overlay = Container(id="overlay")
        yeild self.overlay

        # Original contents
        with Container(id="my_content"):
            yield Static("Stuff in my content")
            # and more widgets

The original and effects Containers need to be on different layers, and the overlay must be set to hidden:

#effect_holder {
    layers: below above;
}

#overlay {
    layer: above;
    visibility: hidden;
}

#my_content {
    layer: below;
}

To activate the effect, you instantiate a new effect class, mount it within the overlay, then create a worker with the effect’s .run() method:

from textual_effect import Curtain

async def on_key(self, event):
    if event.key == 'c':
        curtain = Curtain(self.effect_holder)
        self.overlay.mount(curtain)
        self.run_worker(curtain.run(), exclusive=True)

All effects support call-back mechanisms, one or more ways of adjusting the transition speed, and padding controls. Some effects also allow you to determine the color of the wipe. For full information on each effect, see the documentation.

Supports

This code is still pretty much alpha and doesn’t have automated tests. Manual testing was done in Python 3.13. There are no match/case blocks or walrus operators, so it should work with earlier versions.

Docs & Source

Docs: http://textual_effects.readthedocs.io/en/latest/

Source: https://github.com/cltrudeau/textual-effects

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_transitions-0.0.2.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

textual_transitions-0.0.2-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file textual_transitions-0.0.2.tar.gz.

File metadata

  • Download URL: textual_transitions-0.0.2.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for textual_transitions-0.0.2.tar.gz
Algorithm Hash digest
SHA256 42036d63f40fbc11da79d18b81555b1bcf206b2acd35089e06a4b173bbff884d
MD5 cf35c7c4146dad66f1cbbe3e8a44cc15
BLAKE2b-256 81250ab88b4abad29b71869437accc15c4733d588dd280a9aea3bad68e2155e2

See more details on using hashes here.

File details

Details for the file textual_transitions-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for textual_transitions-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64d66c31c24dedf72351710fd7a5564e8a3a1b1b8395d160a7818732baf21ae5
MD5 6b135b568af9b320fd893a07d2c80341
BLAKE2b-256 fb3bd9fe2d9c45579ddda2fb4cfa0b75401e73480bbb003d7a6e65fc6f92f042

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