Commit e5b6c466 authored by Martin Vítek's avatar Martin Vítek
Browse files

Add start script

parent e09d6095
#!/usr/bin/python3
# Uses examples from: https://www.python-course.eu/tkinter_entry_widgets.php
import tkinter as tk
import os
import sys
import subprocess
config_name = "config"
# Load config file
if os.path.exists(config_name):
with open(config_name, 'r', encoding = 'utf-8') as config:
name = config.readline()[:-1]
latitude = config.readline()[:-1]
longitude = config.readline()[:-1]
else:
name = "OK1RAJ"
latitude = "14.416667"
longitude = "50.083333"
print("From config:")
print("\tCall sign: ", name);
print("\tLatitude: ", latitude);
print("\tLongitude: ", longitude);
# Save data to config and run command
def start_button_handler():
name = e1.get()
latitude = e2.get()
longitude = e3.get()
print("From user:")
print("\tCall sign: ", name);
print("\tLatitude: ", latitude);
print("\tLongitude: ", longitude);
with open(config_name, 'w', encoding = 'utf-8') as config:
config.write(name + '\n');
config.write(latitude + '\n');
config.write(longitude + '\n');
subprocess.Popen(["./habdecWebsocketServer", "--device", "0", "--sampling_rate", "2.024e6", "--rtty", "300", "7", "2", "-print", "1", "--freq", "434.000", "--gain", "35", "--biast", "0", "--afc", "0", "--station", name, "--latlon", latitude, longitude])
sys.exit()
# Create window
master = tk.Tk()
master.title('OK1RAJ Automatic Receiver')
# Fields labels
tk.Label(master, text="Značka").grid(row=0, column=0, pady=2)
tk.Label(master, text="Zeměpisná šířka").grid(row=1, column=0, pady=2)
tk.Label(master, text="Zeměpisná délka").grid(row=2, column=0, pady=2)
# Input fields
e1 = tk.Entry(master)
e2 = tk.Entry(master)
e3 = tk.Entry(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
e3.grid(row=2, column=1)
e1.insert(10, name);
e2.insert(10, latitude);
e3.insert(10, longitude);
# Button
tk.Button(master, text='Start', command=start_button_handler).grid(row=4, column=1, sticky=tk.W, pady=10)
master.mainloop()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment