commit f2adbfaa3fb5e761c3a9d5a2379a3b8f5f1befc1
Author: Daniel Barlow <dan@telent.net>
Date: Sat, 10 Jan 2026 20:46:34 +0000
initial commit
Diffstat:
| A | shore.py | | | 64 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 64 insertions(+), 0 deletions(-)
diff --git a/shore.py b/shore.py
@@ -0,0 +1,64 @@
+#!/data/data/com.termux/files/usr/bin/python
+
+import termuxgui as tg
+import time
+import sys
+
+peer_hostname = None
+started = False
+
+def choose_hostname(hostname):
+ if hostname == None:
+ started = False
+ peer_hostname = hostname
+
+hosts = {
+ "eculogical.local" : None,
+ "eculogical2.local" : None,
+ "eculogical3.local" : None
+}
+
+ # Intercept the back button. Instead of finishing the Activity, it now sends an event instead
+ # a.interceptbackbutton(True)
+ # Also possible: a = tg.Activity(c, intercept=True)
+
+
+
+with tg.Connection() as c:
+ # create a new Activity. By default, a new Task as created.
+ a = tg.Activity(c)
+ # you can find the Task under a.t
+
+ def add_host(activity, name, parent):
+ selected = (peer_hostname == name)
+ if selected:
+ label = f"* {name}"
+ else:
+ label = name
+ button = tg.Button(activity, label, parent)
+ button.setlinearlayoutparams(0)
+ button.setheight(tg.View.WRAP_CONTENT)
+ hosts[name] = button
+
+ def refresh_buttons():
+ for name, widget in hosts.items():
+ if name == peer_hostname:
+ label = f"* {name}"
+ else:
+ label = name
+ widget.settext(label)
+
+ instances = tg.LinearLayout(a)
+
+ add_host(a, "eculogical.local", instances)
+ add_host(a, "eculogical2.local", instances)
+ add_host(a, "eculogical3.local", instances)
+
+ for ev in c.events(): # waits for events from the gui
+ if ev.type == tg.Event.destroy:
+ sys.exit()
+ if ev.type == tg.Event.click:
+ for k, v in hosts.items():
+ if v == ev.value["id"]:
+ peer_hostname = k
+ refresh_buttons()