mirror of
https://github.com/Textualize/textual-serve.git
synced 2025-10-17 02:50:37 +03:00
26 lines
679 B
Python
26 lines
679 B
Python
from textual import on
|
|
from textual.app import App, ComposeResult
|
|
from textual.binding import Binding
|
|
from textual.widgets import Button
|
|
|
|
|
|
class ScreenshotApp(App[None]):
|
|
BINDINGS = [Binding("s", "deliver_screenshot", "Screenshot")]
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Button("Hello, World!")
|
|
|
|
@on(Button.Pressed)
|
|
def on_button_pressed(self) -> None:
|
|
self.action_deliver_screenshot()
|
|
|
|
def action_deliver_screenshot(self) -> None:
|
|
print("Delivering screenshot action!")
|
|
filename = self.save_screenshot("screenshot.svg")
|
|
self.deliver_text(filename)
|
|
|
|
|
|
app = ScreenshotApp()
|
|
if __name__ == "__main__":
|
|
app.run()
|