Broken project to implement a cross-protocol browser in textual
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
from textual.widgets import Button, Static
from textual.app import ComposeResult
from textual.containers import Container
class Gemtext(Static):
"""Gemtext widget."""
items = []
def compose(self) -> ComposeResult:
yield Container(*self.items)
def __init__(self, txt):
super().__init__()
for line in txt.split('\n'):
if line.startswith("=>"):
path = line[2:].lstrip().split(' ')[0]
text = ' '.join(line[2:].lstrip().split(' ')[1:])
self.items.append(Button(text or path, name=path))
else:
self.items.append(Static(line))
if __name__ == "__main__":
from textual.app import App
class Test(App):
def compose(self) -> ComposeResult:
yield Gemtext(txt="#title\n=> /href link text\nworld star hiphop")
app = Test()
app.run()
|