Files
textual/examples/simple.py
2021-06-14 21:33:20 +01:00

25 lines
645 B
Python

from rich.markdown import Markdown
from textual import events
from textual.app import App
from textual.widgets.header import Header
from textual.widgets.placeholder import Placeholder
from textual.widgets.window import Window
with open("richreadme.md", "rt") as fh:
readme = Markdown(fh.read(), hyperlinks=True, code_theme="fruity")
class MyApp(App):
KEYS = {"q": "quit", "ctrl+c": "quit", "b": "view.toggle('left')"}
async def on_startup(self, event: events.Startup) -> None:
await self.view.mount_all(
header=Header(self.title), left=Placeholder(), body=Window(readme)
)
app = MyApp()
app.run()