Broken project to implement a cross-protocol browser in textual
Toolbar buttons: Make refresh and up buttons work
Zach DeCook 2022-12-24
parent 09b393b · commit 2278c71
-rw-r--r--browset.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/browset.py b/browset.py
index c316c1d..3b32939 100644
--- a/browset.py
+++ b/browset.py
@@ -18,9 +18,9 @@ class Browset(App):
yield Footer()
yield Container(
Button("🔙"), # ⏪
- Button("🔝"), # ⏫
+ Button("🔝", name='../'), # ⏫
Button("🔜"), # ⏩
- Button("🔄"), # 🔁
+ Button("🔄", variant='primary', name='refresh'), # 🔁
Input(placeholder="Enter URI", id="url"),
id="toolbar"
@@ -30,6 +30,10 @@ class Browset(App):
self._do_url(message.value)
async def on_button_pressed(self, event: Button.Pressed) -> None:
+ if event.button.variant == 'primary':
+ if event.button.name == "refresh":
+ self._do_url(self.url)
+ else:
url = event.button.name
if not ":" in url:
url = GeminiProtocol.relativeURL(url, self.url)