textual/docs/examples/widgets/switch.py
Rodrigo Girão Serrão 5ee0ebfef4
Rename CSS files to TCSS.
Related issue: #3137.
2023-08-22 13:21:17 +01:00

35 lines
991 B
Python

from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Static, Switch
class SwitchApp(App):
def compose(self) -> ComposeResult:
yield Static("[b]Example switches\n", classes="label")
yield Horizontal(
Static("off: ", classes="label"),
Switch(animate=False),
classes="container",
)
yield Horizontal(
Static("on: ", classes="label"),
Switch(value=True),
classes="container",
)
focused_switch = Switch()
focused_switch.focus()
yield Horizontal(
Static("focused: ", classes="label"), focused_switch, classes="container"
)
yield Horizontal(
Static("custom: ", classes="label"),
Switch(id="custom-design"),
classes="container",
)
app = SwitchApp(css_path="switch.tcss")
if __name__ == "__main__":
app.run()