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

Commit

Permalink
✨ Another example for #3483
Browse files Browse the repository at this point in the history
See Textualize/textual#3483 (comment)
for the specific context.
  • Loading branch information
davep committed Oct 10, 2023
1 parent 5628c25 commit f9e9800
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions issue_3483_davep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""https://github.com/Textualize/textual/issues/3483"""

from textual.app import App, ComposeResult
from textual.containers import Grid
from textual.widgets import Label, Input, Select

class StandardRow(Grid):
"""A standard row in the display.
Other compound widgets inherit from this.
"""

DEFAULT_CSS = """
StandardRow {
grid-size: 3;
grid-columns: 12 1fr 1fr;
height: auto;
margin-bottom: 1;
}
"""

class InputWithLabel(StandardRow):
"""A labeled input row with optional select."""

def __init__(self, input_label: str, with_select: bool = False) -> None:
self.input_label = input_label
self.with_select = with_select
super().__init__()

def compose(self) -> ComposeResult:
yield Label(self.input_label)
yield Input()
if self.with_select:
yield Select([("a", "A"), ("b", "B"), ("c", "C")])

class Issue3483Example(App[None]):

def compose(self) -> ComposeResult:
yield InputWithLabel("First Name")
yield InputWithLabel("Last Name", with_select=True)
yield InputWithLabel("Email")

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

### issue_3483_davep.py ends here

0 comments on commit f9e9800

Please sign in to comment.