mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
30 lines
492 B
Python
30 lines
492 B
Python
from textual.app import App
|
|
|
|
|
|
class ExampleApp(App):
|
|
|
|
COLORS = [
|
|
"white",
|
|
"maroon",
|
|
"red",
|
|
"purple",
|
|
"fuchsia",
|
|
"olive",
|
|
"yellow",
|
|
"navy",
|
|
"teal",
|
|
"aqua",
|
|
]
|
|
|
|
def on_mount(self):
|
|
self.styles.background = "darkblue"
|
|
|
|
def on_key(self, event):
|
|
if event.key.isdigit():
|
|
self.styles.background = self.COLORS[int(event.key)]
|
|
self.bell()
|
|
|
|
|
|
app = ExampleApp()
|
|
app.run()
|