-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGui.py
More file actions
47 lines (39 loc) · 1.93 KB
/
Copy pathGui.py
File metadata and controls
47 lines (39 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import PySimpleGUI as sg
from K_means import k_means_constrained
from K_means import create_proximity_map
def run() :
def make_first_layout():
layout1 = [
[sg.Text("Parcel Density", size = (20, 1), justification="left", font = "sans-serif, 40")],
[sg.Text("Choose a csv file to upload", justification="left")], [sg.FileBrowse(key = "-BROWSER-")],
[sg.Text("Minimum orders:")],
[sg.Input(key = "-MIN_ORDERS-")],
[sg.Text("Maximum orders:")],
[sg.Input(key = "-MAX_ORDERS-")],
[sg.Text("Number of drivers:")],
[sg.Input(key = "-NUM_DRIVERS-")],
[sg.Button("Get Proximity Clusters", key = "-PROX-")]
]
return sg.Window("Redacted Name Demo", layout= layout1, margins=(100, 200), finalize=True)
def make_second_layout():
layout2 = [
[sg.Text("Parcel Density", size = (20, 1), justification="left", font = "sans-serif, 40")],
[sg.Image("googlemaps.png", size = (500, 500))],
[sg.Button("Back to Browse", key = "-REVERT-")]
]
return sg.Window("Redacted Name Demo", layout= layout2, margins=(50, 50), finalize=True)
window1, window2 = make_first_layout(), None
while True:
window, event, values = sg.read_all_windows()
if event == sg.WIN_CLOSED:
break
elif event == "-PROX-":
print(values)
if values["-BROWSER-"] and values["-MIN_ORDERS-"] and values["-MAX_ORDERS-"] and values["-NUM_DRIVERS-"]:
data, clusters, labels, = k_means_constrained(values["-BROWSER-"], int(values["-MIN_ORDERS-"]), int(values["-MAX_ORDERS-"]), int(values["-NUM_DRIVERS-"]))
create_proximity_map(data, labels)
window2 = make_second_layout()
window1.close()
elif event == "-REVERT-":
window1 = make_first_layout()
window2.close()