This repository has been archived by the owner on May 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgui.py
87 lines (71 loc) · 3.06 KB
/
gui.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
The GUI file for Project Solar! Originally Solar was a console only script however this is being changed as to make the
script more user-friendly!
Patch Notes vAX-0.1.2: Hotfixes for existing work
Patch Notes vMG-0.1.1: Seems to mostly be working, I think most of the issues rn are in the solar module not gui
Patch Notes vMG-0.1: Actually created the file, current calls from solar itself so still does console printing
"""
import PySimpleGUI as sg
import solar as so
# Setting the color scheme
sg.theme("NeutralBlue")
# Create a list for our wonderful dropdown menu
dropdownList = ["Del Non-Endo", "Non-WA in Region", "Nation Non-Endo", "Debugging"]
# Create the layout
layout = [
[sg.Text("Welcome to Solar!", key="OUT")],
[sg.Text("Main Nation: "), sg.Input(key="user-agent")],
[sg.Text("Target: "), sg.Input(key="target")],
[sg.Text("Desired Action: "), sg.Combo(values=dropdownList, readonly=True, key="action"), sg.Button('TAG', size=(4, 1), button_color='white on black', key='tag')],
[sg.Button("Exit", size=(3, 1), key="exit"), sg.Button("Submit", size=(5, 1), key="submit")],
]
# Create the window!
window = sg.Window("Solar", layout)
# Starting event
event = "start"
headers = ""
# Setting user entry
def GetHeaders(values):
# Headers with main nation from entry
headers = {
"User-Agent": f"Project Solar requesting region and nation information, developed by nation=Hesskin_Empire "
f"and in use by {values['user-agent']}"
}
return headers
# For the TAG/TG button!
down = graphic_off = True
# Loop to open and hold open the gui
while event != "exit":
event, values = window.read()
# Check if the headers have been set
if headers == "":
headers = GetHeaders(values)
# Checks if the window closed or if the exit button was clicked
if event == sg.WIN_CLOSED or event == "exit":
break
elif event == "submit":
# Wonderful, wonderful match case
match (values["action"]):
case "Del Non-Endo":
post = so.region_info(headers, "NER", values["target"])
window['OUT'].update(post)
case "Non-WA in Region":
post = so.region_info(headers, "NWR", values["target"])
window['OUT'].update(post)
case "Nation Non-Endo":
if window['tag'].get_text() == 'TAG':
post = so.calc_non_nat_tagged(headers, values["target"])
window['OUT'].update(post)
else:
post = so.calc_non_nat(headers, values["target"])
window['OUT'].update(post)
case other:
print("Yeet")
elif event == 'tag': # if the normal button that changes color and text
down = not down
window['tag'].update(text='TAG' if down else 'TG',
button_color='white on black' if down else 'white on black')
else:
print("test")
# Close the window
window.close()