Visual effects for Textual, a TermincalTextEffects wrapper.
Project description
textualeffects
Visual effects for Textual, a TerminalTextEffects wrapper.
Intro
textualeffects is a library that provides Textual bindings for the excellent TerminalTextEffects visual effects library.
Widgets
There are two widgets available in textualeffects, EffectLabel and SplashScreen.
An EffectLabel widget that can be used to display text with a visual effect.
from textual.app import App, ComposeResult
from textualeffects.effects import EffectType
from textualeffects.widgets import EffectLabel
text=("Hello World! " * 5 + "\n") * 10,
effect: EffectType = "Spotlights"
config = {
"search_duration": 500,
"spotlight_count": 3,
}
class TextualEffect(App):
def compose(self) -> ComposeResult:
label = EffectLabel(text, effect=effect, config=config)
label.styles.border = ("heavy", "green")
yield label
if __name__ == "__main__":
app = TextualEffect()
app.run()
A SplashScreen widget that can be used to display a splash screen based on ModalScreen with a visual effect. Once the effect is complete, the splash screen will be dismissed. The user can also dismiss the splash screen by pressing the ESC key.
from textual.app import App, ComposeResult
from textual.widgets import TextArea
from textualeffects.effects import EffectType
from textualeffects.widgets import SplashScreen
effect: EffectType = "Spotlights"
config = {
"search_duration": 100,
"spotlight_count": 3,
}
class SplashEffect(App):
def on_mount(self) -> None:
text = ("Hello World! " * 5 + "\n") * 10
self.push_screen(SplashScreen(text, effect=effect, config=config))
def compose(self) -> ComposeResult:
yield TextArea(("Main content" * 5 + "\n") * 10)
if __name__ == "__main__":
app = SplashEffect()
app.run()
Both widgets accept the following arguments:
text: The text to display.effect: The visual effect to apply to the text. Available effects are exposed through theEffectTypetype.config: A dictionary of configuration options for the effect. The available options depend on the effect. Detailed information on the available options can be found in the TerminalTextEffects documentation.
For convenience, when an effect has run its course, the EffectLabel and SplashScreen widgets will emit a EffectLabel.EffectFinished event.
You can listen for this event to perform any actions:
@on(EffectLabel.EffectFinished)
def do_stuff(self, message: EffectLabel.EffectFinished) -> None:
...
License
This project is licensed under the MIT License.
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
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 textualeffects-0.1.4.tar.gz.
File metadata
- Download URL: textualeffects-0.1.4.tar.gz
- Upload date:
- Size: 55.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86709321d49cd7abf47ed513782130174e6f5d85ea16996a7c38709c3646c463
|
|
| MD5 |
4488e721f01f47de3c4240f6c9ad383a
|
|
| BLAKE2b-256 |
640e8307b9349f79d42666e46e936d31d0224e47c8e9dac572c2585e0fa517eb
|
File details
Details for the file textualeffects-0.1.4-py3-none-any.whl.
File metadata
- Download URL: textualeffects-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61a1c17e08c4237e78cd37ce6ea6876fa110890226ff04f19aa2b73df346a406
|
|
| MD5 |
90a501078283440e1ed40b1f60518204
|
|
| BLAKE2b-256 |
500683e758a2aa3e80531bdf56125d51d84d20954493316d3c01d250073a242d
|