mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
24 lines
444 B
Python
24 lines
444 B
Python
from datetime import datetime
|
|
|
|
from rich.align import Align
|
|
|
|
from textual.app import App
|
|
from textual.widget import Widget
|
|
|
|
|
|
class Clock(Widget):
|
|
def on_mount(self):
|
|
self.set_interval(1, self.refresh)
|
|
|
|
def render(self):
|
|
time = datetime.now().strftime("%c")
|
|
return Align.center(time, vertical="middle")
|
|
|
|
|
|
class ClockApp(App):
|
|
async def on_mount(self):
|
|
await self.screen.dock(Clock())
|
|
|
|
|
|
ClockApp.run()
|