Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
✨ Example for Textualize/textual#4292
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Mar 14, 2024
1 parent 2456702 commit 8485ba9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions greedy_textarea.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Example for https://github.com/Textualize/textual/issues/4292"""

from pathlib import Path

from textual.app import App, ComposeResult
from textual.widgets import Collapsible, TextArea


class GreedyScrollbarApp(App[None]):
BINDINGS = [("f1", "collapse")]

CSS = """
TextArea {
height: 10;
}
"""

def compose(self) -> ComposeResult:
for n in range(5):
with Collapsible(title=f"This is collapsible #{n}", collapsed=bool(n)):
yield TextArea(Path(__file__).read_text(), language="python")

def action_collapse(self) -> None:
target.collapsed = not (target := self.query(Collapsible).first()).collapsed


if __name__ == "__main__":
GreedyScrollbarApp().run()

### greedy_textarea.py ends here

0 comments on commit 8485ba9

Please sign in to comment.