textual/docs/examples/guide/command_palette/command01.py
2024-08-22 14:04:54 +01:00

17 lines
459 B
Python

from typing import Iterable
from textual.app import App, SystemCommand
from textual.screen import Screen
class BellCommandApp(App):
"""An app with a 'bell' command."""
def get_system_commands(self, screen: Screen) -> Iterable[SystemCommand]:
yield from super().get_system_commands(screen) # (1)!
yield SystemCommand("Bell", "Ring the bell", self.bell) # (2)!
if __name__ == "__main__":
app = BellCommandApp()
app.run()