This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Example for Textualize/textual#4292
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |