commit d9e20e4ca572389a30983016176554a16c044d08
parent f2adbfaa3fb5e761c3a9d5a2379a3b8f5f1befc1
Author: Daniel Barlow <dan@telent.net>
Date: Sat, 10 Jan 2026 21:54:35 +0000
working (fake) start/stop button
Diffstat:
| M | shore.py | | | 40 | ++++++++++++++++++++++++++++++++-------- |
1 file changed, 32 insertions(+), 8 deletions(-)
diff --git a/shore.py b/shore.py
@@ -7,11 +7,6 @@ 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,
@@ -23,7 +18,6 @@ hosts = {
# 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)
@@ -40,6 +34,13 @@ with tg.Connection() as c:
button.setheight(tg.View.WRAP_CONTENT)
hosts[name] = button
+ def choose_hostname(hostname):
+ global peer_hostname
+ if hostname == None:
+ started = False
+ peer_hostname = hostname
+ refresh_buttons()
+
def refresh_buttons():
for name, widget in hosts.items():
if name == peer_hostname:
@@ -47,12 +48,33 @@ with tg.Connection() as c:
else:
label = name
widget.settext(label)
+ if peer_hostname == None:
+ start_button.settext("----")
+ else:
+ start_button.settext("STOP" if started else "START")
+
+ def start_recording(start_or_stop):
+ global started
+ if start_or_stop and peer_hostname != None:
+ print("pretending to do udp things")
+ else:
+ print("pretending to close udp socket")
+ started = start_or_stop
instances = tg.LinearLayout(a)
add_host(a, "eculogical.local", instances)
add_host(a, "eculogical2.local", instances)
add_host(a, "eculogical3.local", instances)
+ tg.Space(a, instances)
+
+ buttons = tg.LinearLayout(a, instances, False)
+
+ start_button = tg.Button(a, "(start)", buttons)
+ start_button.setlinearlayoutparams(0)
+ start_button.setheight(tg.View.WRAP_CONTENT)
+ # start_button.setwidth(tg.View.WRAP_CONTENT)
+ start_button.setgravity(1, 1)
for ev in c.events(): # waits for events from the gui
if ev.type == tg.Event.destroy:
@@ -60,5 +82,7 @@ with tg.Connection() as c:
if ev.type == tg.Event.click:
for k, v in hosts.items():
if v == ev.value["id"]:
- peer_hostname = k
- refresh_buttons()
+ choose_hostname(k)
+ if ev.value["id"] == start_button:
+ start_recording(not started)
+ refresh_buttons()