mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
docs/widgets/Button
This commit is contained in:
3
docs/examples/widgets/button.css
Normal file
3
docs/examples/widgets/button.css
Normal file
@@ -0,0 +1,3 @@
|
||||
Button {
|
||||
margin: 1 2;
|
||||
}
|
||||
20
docs/examples/widgets/button.py
Normal file
20
docs/examples/widgets/button.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Button
|
||||
|
||||
|
||||
class ButtonsApp(App):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Button("Default", id="foo")
|
||||
yield Button("Disabled", disabled=True)
|
||||
yield Button.success("Success!")
|
||||
yield Button.warning("Warning!")
|
||||
yield Button.error("Error!")
|
||||
|
||||
def on_button_pressed(self, _event: Button.Pressed) -> None:
|
||||
self.app.bell()
|
||||
|
||||
|
||||
app = ButtonsApp(css_path="button.css")
|
||||
|
||||
if __name__ == "__main__":
|
||||
result = app.run()
|
||||
Reference in New Issue
Block a user