stopwatch04

This commit is contained in:
Will McGugan
2022-08-20 20:29:19 +01:00
parent 47a3536172
commit bda9790a2a
12 changed files with 245 additions and 110 deletions

27
sandbox/will/order.py Normal file
View File

@@ -0,0 +1,27 @@
import asyncio
from textual.app import App
from textual import events
from textual.widget import Widget
class OrderWidget(Widget, can_focus=True):
def on_key(self, event) -> None:
self.log("PRESS", event.key)
class OrderApp(App):
def compose(self):
yield OrderWidget()
async def on_mount(self):
async def send_keys():
self.query_one(OrderWidget).focus()
chars = ["tab", "enter", "h", "e", "l", "l", "o"]
for char in chars:
self.log("SENDING", char)
await self.post_message(events.Key(self, key=char))
self.set_timer(1, lambda: asyncio.create_task(send_keys()))
app = OrderApp()