From d36b75810a8bcf1e884ed12ee276b66a506e2ee3 Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Tue, 23 Jul 2024 09:46:08 -0700 Subject: [PATCH] Add "last updated" to mobile mode --- navpoint/phone_server.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/navpoint/phone_server.py b/navpoint/phone_server.py index 3f70434..d42fe38 100755 --- a/navpoint/phone_server.py +++ b/navpoint/phone_server.py @@ -18,6 +18,12 @@ class PostHandler(tornado.web.RequestHandler): def post(self): navpoint.content.content = self.request.body + intercom.put( + "Updated", + navpoint.content.content.decode("utf-8") + .split("")[1] + .split("")[0], + ) self.write("Navpoint") @@ -36,16 +42,12 @@ def run_in_thread(ip, token): def run(): + def new_data(purpose, content): + if purpose == "Updated": + updated.config(text="Last updated: " + content) + ip = navpoint.get_ip.get_ip() token = secrets.token_urlsafe() - threading.Thread( - target=run_in_thread, - args=( - ip, - token, - ), - daemon=True, - ).start() link = f"http://{ip}:8888/{token}" @@ -56,6 +58,9 @@ def run(): label = tk.Label(window, text="QR code here...") label.pack() + updated = ttk.Label(window, text="Waiting for location") + updated.pack() + image = tk.BitmapImage( data=pyqrcode.create(link).xbm(scale=int(window.winfo_fpixels("2m"))) ) @@ -69,4 +74,16 @@ def run(): except tk.TclError: pass + global intercom + intercom = navpoint.intercom.Intercom(window, new_data) + + threading.Thread( + target=run_in_thread, + args=( + ip, + token, + ), + daemon=True, + ).start() + window.mainloop()