Skip to content
Discussion options

You must be logged in to vote

Here's a quick example of how you might reveal the redacted text when hovered.

The RedactedText widget has a reveal_range reactive attribute which is updated when some redacted text is hovered. This will prompt a "smart refresh" to update which ranges have the 'redacted' styling.

The important part is the metadata (meta) applied to portions of the text. The mouse event handler checks the event.style.meta and updates the reveal_range reactive attribute accordingly.

from rich.text import Text
from textual import events
from textual.app import App, ComposeResult, RenderResult
from textual.reactive import reactive
from textual.widget import Widget


class RedactedText(Widget):
    COMPONENT_C…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@cdxjcl
Comment options

@TomJGooding
Comment options

Answer selected by cdxjcl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants