Move code out of gui.py
This commit is contained in:
parent
05d0032876
commit
ec45452570
|
@ -1,66 +0,0 @@
|
|||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
import pyqrcode
|
||||
import navpoint.fix_path
|
||||
import navpoint.usb
|
||||
|
||||
|
||||
def choose_mode():
|
||||
def _usb_clicked():
|
||||
window.destroy()
|
||||
global mode
|
||||
mode = "usb"
|
||||
|
||||
def _mobile_clicked():
|
||||
window.destroy()
|
||||
global mode
|
||||
mode = "mobile"
|
||||
|
||||
window = tk.Tk(className="navpoint")
|
||||
window.title("Navpoint")
|
||||
window.resizable(width=False, height=False)
|
||||
|
||||
global mode
|
||||
mode = ""
|
||||
|
||||
ttk.Label(window, text="How should Navpoint obtain location data?").pack()
|
||||
usb_button = ttk.Button(
|
||||
window, text="USB GPS receiver (NMEA)", command=_usb_clicked
|
||||
)
|
||||
usb_button.pack()
|
||||
mobile_button = ttk.Button(
|
||||
window, text="Phone running Navpoint Mobile", command=_mobile_clicked
|
||||
)
|
||||
mobile_button.pack()
|
||||
|
||||
try:
|
||||
window.iconbitmap(navpoint.fix_path.fix_path("icon.ico"))
|
||||
except tk.TclError:
|
||||
pass
|
||||
|
||||
window.mainloop()
|
||||
return mode
|
||||
|
||||
|
||||
def show_qr(link):
|
||||
window = tk.Tk(className="navpoint")
|
||||
window.title("Navpoint")
|
||||
window.resizable(width=False, height=False)
|
||||
|
||||
label = tk.Label(window, text="QR code here...")
|
||||
label.pack()
|
||||
|
||||
image = tk.BitmapImage(
|
||||
data=pyqrcode.create(link).xbm(scale=int(window.winfo_fpixels("2m")))
|
||||
)
|
||||
image.config(background="white")
|
||||
image.config(foreground="black")
|
||||
|
||||
label.config(image=image)
|
||||
|
||||
try:
|
||||
window.iconbitmap(navpoint.fix_path.fix_path("icon.ico"))
|
||||
except tk.TclError:
|
||||
pass
|
||||
|
||||
window.mainloop()
|
|
@ -4,6 +4,10 @@ import navpoint.content
|
|||
import asyncio
|
||||
import secrets
|
||||
import threading
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
import pyqrcode
|
||||
import navpoint.fix_path
|
||||
|
||||
|
||||
class PostHandler(tornado.web.RequestHandler):
|
||||
|
@ -43,4 +47,26 @@ def run():
|
|||
daemon=True,
|
||||
).start()
|
||||
|
||||
return f"http://{ip}:8888/{token}"
|
||||
link = f"http://{ip}:8888/{token}"
|
||||
|
||||
window = tk.Tk(className="navpoint")
|
||||
window.title("Navpoint")
|
||||
window.resizable(width=False, height=False)
|
||||
|
||||
label = tk.Label(window, text="QR code here...")
|
||||
label.pack()
|
||||
|
||||
image = tk.BitmapImage(
|
||||
data=pyqrcode.create(link).xbm(scale=int(window.winfo_fpixels("2m")))
|
||||
)
|
||||
image.config(background="white")
|
||||
image.config(foreground="black")
|
||||
|
||||
label.config(image=image)
|
||||
|
||||
try:
|
||||
window.iconbitmap(navpoint.fix_path.fix_path("icon.ico"))
|
||||
except tk.TclError:
|
||||
pass
|
||||
|
||||
window.mainloop()
|
||||
|
|
|
@ -1,15 +1,49 @@
|
|||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
import navpoint.fix_path
|
||||
import navpoint.local_server
|
||||
import navpoint.phone_server
|
||||
import navpoint.usb
|
||||
import navpoint.gui
|
||||
|
||||
|
||||
def run():
|
||||
mode = navpoint.gui.choose_mode()
|
||||
def _usb_clicked():
|
||||
window.destroy()
|
||||
global mode
|
||||
mode = "usb"
|
||||
|
||||
def _mobile_clicked():
|
||||
window.destroy()
|
||||
global mode
|
||||
mode = "mobile"
|
||||
|
||||
window = tk.Tk(className="navpoint")
|
||||
window.title("Navpoint")
|
||||
window.resizable(width=False, height=False)
|
||||
|
||||
global mode
|
||||
mode = ""
|
||||
|
||||
ttk.Label(window, text="How should Navpoint obtain location data?").pack()
|
||||
usb_button = ttk.Button(
|
||||
window, text="USB GPS receiver (NMEA)", command=_usb_clicked
|
||||
)
|
||||
usb_button.pack()
|
||||
mobile_button = ttk.Button(
|
||||
window, text="Phone running Navpoint Mobile", command=_mobile_clicked
|
||||
)
|
||||
mobile_button.pack()
|
||||
|
||||
try:
|
||||
window.iconbitmap(navpoint.fix_path.fix_path("icon.ico"))
|
||||
except tk.TclError:
|
||||
pass
|
||||
|
||||
window.mainloop()
|
||||
|
||||
if mode == "mobile":
|
||||
navpoint.local_server.run()
|
||||
link = navpoint.phone_server.run()
|
||||
navpoint.gui.show_qr(link)
|
||||
elif mode == "usb":
|
||||
navpoint.local_server.run()
|
||||
navpoint.usb.run_ui()
|
||||
|
|
Loading…
Reference in New Issue
Block a user