Files
textual/docs/examples/guide/compound/compound01.py
Will McGugan 864931e94b Compound docs (#1952)
* compound example

* update bit switch

* prevent

* no css

* compound widget example

* more diagrams

* more diagrams

* diagrams

* words

* words

* remove sender

* removed priority post

* timer fix

* test fixes

* drop async version of post_message

* extended docs

* fix no app

* Added control properties

* changelog

* changelog

* changelog

* fix for stopping timers

* changelog

* docs update

* last byte example

* new section

* update of byte03

* updae to docs

* Added compound examples

* Rewording

* Use set sender

* don't need this

* hyphens

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/widgets.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/guide/widgets.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/guide/widgets.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/guide/widgets.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* parenthesis

* stack diagram

---------

Co-authored-by: Dave Pearson <davep@davep.org>
Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-03-06 16:56:24 +00:00

53 lines
1.0 KiB
Python

from textual.app import App, ComposeResult
from textual.widget import Widget
from textual.widgets import Input, Label
class InputWithLabel(Widget):
"""An input with a label."""
DEFAULT_CSS = """
InputWithLabel {
layout: horizontal;
height: auto;
}
InputWithLabel Label {
padding: 1;
width: 12;
text-align: right;
}
InputWithLabel Input {
width: 1fr;
}
"""
def __init__(self, input_label: str) -> None:
self.input_label = input_label
super().__init__()
def compose(self) -> ComposeResult: # (1)!
yield Label(self.input_label)
yield Input()
class CompoundApp(App):
CSS = """
Screen {
align: center middle;
}
InputWithLabel {
width: 80%;
margin: 1;
}
"""
def compose(self) -> ComposeResult:
yield InputWithLabel("Fist Name")
yield InputWithLabel("Last Name")
yield InputWithLabel("Email")
if __name__ == "__main__":
app = CompoundApp()
app.run()