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 to help understand a question being asked
- Loading branch information
Showing
1 changed file
with
43 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,43 @@ | ||
"""https://github.com/Textualize/textual/issues/3483""" | ||
|
||
from textual import on | ||
from textual.app import App, ComposeResult | ||
from textual.containers import Grid | ||
from textual.widgets import Label, Input, Log | ||
|
||
class TitledInput(Grid): | ||
|
||
DEFAULT_CSS = """ | ||
TitledInput { | ||
grid-size: 2; | ||
height: auto; | ||
} | ||
Label { | ||
background: green; | ||
} | ||
""" | ||
|
||
def __init__(self, title: str) -> None: | ||
super().__init__() | ||
self.title = title | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Label(self.title) | ||
yield Input() | ||
|
||
class KindaGridApp(App[None]): | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Log() | ||
for n in range(4): | ||
yield TitledInput(f"Input {n}") | ||
|
||
@on(Input.Changed) | ||
def update_logs(self, event: Input.Changed) -> None: | ||
self.query_one(Log).write_line(f"{event.control.parent.title} changed: {event.value}") | ||
|
||
if __name__ == "__main__": | ||
KindaGridApp().run() | ||
|
||
### kinda_grid.py ends here |