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

Commit

Permalink
✨ Example to help understand a question being asked
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Oct 9, 2023
1 parent d391b01 commit 3cab4ae
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions kinda_grid.py
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

0 comments on commit 3cab4ae

Please sign in to comment.