mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
stopwatch04
This commit is contained in:
27
sandbox/will/order.py
Normal file
27
sandbox/will/order.py
Normal 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()
|
||||
Reference in New Issue
Block a user