|
# GUI |
|
|
|
def create_map(): |
|
global country_gui |
|
global region_gui |
|
region_gui = cboContinent.get().replace("-", "") |
|
country_gui = cboCountry.get() |
|
app.destroy() |
|
|
|
|
|
def callback_continent(event): |
|
continent = cboContinent.get() |
|
cboCountry["values"] = eval(continent.replace("-", "")) |
|
cboCountry.current(0) |
|
if continent == "europe": |
|
cboCountry.current(14) |
|
|
|
|
|
def switch_reload(): |
|
if fp.get() == 0: |
|
enMaxOldDays.configure(state=NORMAL) |
|
else: |
|
enMaxOldDays.configure(state=DISABLED) |
|
|
|
|
|
app = tk.Tk() |
|
app.geometry("420x360") |
|
app.title("Wahoo map creator") |
|
app.option_add("*Font", "Calibri 16") |
|
country_gui = "none" |
|
region_gui = "none" |
|
|
|
app.grid_rowconfigure(3, minsize=30) |
|
app.grid_rowconfigure(6, minsize=10) |
|
app.grid_rowconfigure(8, minsize=10) |
|
|
|
labTop = tk.Label(app, text="Select continent and country to create a map") |
|
labContinent = tk.Label(app, text="Select continent:") |
|
labCountry = tk.Label(app, text='Select country:') |
|
labMaxOld = tk.Label(app, text='Max Old Days:') |
|
|
|
labTop.grid(column=0, row=0, columnspan=2, sticky=E, padx=5, pady=10) |
|
labContinent.grid(column=0, row=1, sticky=E, padx=5, pady=2) |
|
labCountry.grid(column=0, row=2, sticky=NE, padx=5, pady=2) |
|
labMaxOld.grid(column=0, row=4, sticky=SE, padx=5) |
|
|
|
cboContinent = ttk.Combobox(app, values=constants.continents, state="readonly", width=15) |
|
cboCountry = ttk.Combobox(app, values=constants.europe, state="readonly", width=15) |
|
cboContinent.grid(column=1, row=1, sticky=W, padx=10, pady=2) |
|
cboCountry.grid(column=1, row=2, sticky=NW, padx=10, pady=2) |
|
cboContinent.current(0) |
|
cboCountry.current(14) |
|
cboContinent.bind("<<ComboboxSelected>>", callback_continent) |
|
|
|
fp = IntVar() |
|
fp.set(FORCE_PROCESSING) |
|
maxdays = StringVar() |
|
maxdays.set(str(MAX_DAYS_OLD)) |
|
save_cruiser_maps = IntVar() |
|
save_cruiser_maps.set(SAVE_CRUISER) |
|
enMaxOldDays = tk.Entry(app, textvar=maxdays, width=5) |
|
enMaxOldDays.grid(column=1, row=4, sticky=SW, padx=10) |
|
chkReloadMaps = Checkbutton(app, text="Force reload maps", var=fp, command=switch_reload) |
|
chkReloadMaps.grid(column=1, row=5, sticky=NW, padx=5) |
|
chkSaveCruiser = Checkbutton(app, text="Save uncompressed maps for Cruiser", var=save_cruiser_maps, command=switch_reload) |
|
chkSaveCruiser.grid(columnspan=2, column=0, row=7, sticky=S, pady=5) |
|
|
|
btnOK = tk.Button(app, text="Create map", width=15, command=create_map).grid(column=0, row=9, padx=15, pady=10) |
|
btnCancel = tk.Button(app, text="Exit", width=15, command=app.destroy).grid(column=1, row=9, padx=10, pady=10) |
|
|
|
switch_reload() |
|
app.mainloop() # show gui |
|
|
|
FORCE_PROCESSING = fp.get() |
|
SAVE_CRUISER = save_cruiser_maps.get() |
|
MAX_DAYS_OLD = int(maxdays.get()) |
|
|
|
print('# Force Processing = ' + str(FORCE_PROCESSING)) |
|
print('# Max Days Old = ' + str(MAX_DAYS_OLD)) |
|
print('# Save Cruiser maps = ' + str(SAVE_CRUISER)) |
|
print(f"# GUI exits with {country_gui} in {region_gui}") |
|
if country_gui == "none": |
|
sys.exit() |
|
|
|
# End of GUI |