clock example

This commit is contained in:
Will McGugan
2021-08-07 12:09:16 +01:00
parent 636ed1a6e6
commit 9e405c3e0a

View File

@@ -0,0 +1,22 @@
from datetime import datetime
from rich.align import Align
from textual.app import App
from textual.widget import Widget
class Clock(Widget):
async def on_mount(self, event):
self.set_interval(1, callback=self.refresh)
def render(self) -> Align:
time = datetime.now().strftime("%X")
return Align.center(time, vertical="middle")
class ClockApp(App):
async def on_mount(self, event):
await self.view.dock(Clock())
ClockApp.run()