mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
23 lines
479 B
Python
23 lines
479 B
Python
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()
|