Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI support #21

Closed
treee111 opened this issue Jul 11, 2021 · 0 comments · Fixed by #24
Closed

GUI support #21

treee111 opened this issue Jul 11, 2021 · 0 comments · Fixed by #24
Labels
enhancement New feature or request

Comments

@treee111
Copy link
Owner

  • get GUI parts from the snippets below
  • put it into a separate python file
  • Maybe together with the CLI arguments
  • GUI and CLI - can they be used both / exist somehow in parallel?

Existing GUI functionality to be used:

# for gui
import tkinter as tk
from tkinter import ttk
from tkinter import *

# 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

@treee111 treee111 added enhancement New feature or request infrastructure Infrastructure labels Jul 11, 2021
@treee111 treee111 removed the infrastructure Infrastructure label Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant