Files
textual/docs/examples/widgets/button.py
2022-09-18 22:02:08 +01:00

36 lines
1.1 KiB
Python

from textual import layout
from textual.app import App, ComposeResult
from textual.widgets import Button, Static
class ButtonsApp(App):
CSS_PATH = "button.css"
def compose(self) -> ComposeResult:
yield layout.Horizontal(
layout.Vertical(
Static("Standard Buttons", classes="header"),
Button("Default"),
Button("Primary!", variant="primary"),
Button.success("Success!"),
Button.warning("Warning!"),
Button.error("Error!"),
),
layout.Vertical(
Static("Disabled Buttons", classes="header"),
Button("Default", disabled=True),
Button("Primary!", variant="primary", disabled=True),
Button.success("Success!", disabled=True),
Button.warning("Warning!", disabled=True),
Button.error("Error!", disabled=True),
),
)
def on_button_pressed(self, _event: Button.Pressed) -> None:
self.app.bell()
if __name__ == "__main__":
app = ButtonsApp()
result = app.run()