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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file textual_transitions-0.0.3.tar.gz.
File metadata
- Download URL: textual_transitions-0.0.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcdd37738d3ceffb7c779dc927531d9b4679570a0077326c002689ee8ceb3e51
|
|
| MD5 |
fa34d4bf4d30ec45a0f3a04db8dbaa07
|
|
| BLAKE2b-256 |
b70b02fc8e39c630c346787ebd6ce59319a6f5221e37654d787f32984c6f34c0
|
File details
Details for the file textual_transitions-0.0.3-py3-none-any.whl.
File metadata
- Download URL: textual_transitions-0.0.3-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77bb2045e7e5e8d7e4a98ba3ac43c04ef68122f644e8d7bf0f334300b5ffe7bd
|
|
| MD5 |
a9bd70fbe39beffb573bf62b0a8d1304
|
|
| BLAKE2b-256 |
19efb1b50ae0f061d1861e2d2f13b4dcb70df77ee4725a2b512969d3907e007a
|