-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path\
502 lines (367 loc) · 15.2 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
import tkinter as tk
import sqlite3
from tkinter import *
from tkinter import font, ttk, StringVar, Button, Canvas, messagebox
from PIL import ImageTk, Image
import array
import webbrowser
from matplotlib.figure import Figure
from matplotlib.backend.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)
# Color pallete used in GUI
color_Mode = True
classCountSelection = False
is_data = False
box_state = False
logobg = "#eaddcf"
navbg = "#e3f6f5"
sideBarbg = "#"
#submainbg = "#3f3f46"
submainbg = "#fef6e4"
darksubmainbg = "#282828"
darkslabbg = "#787878"
darklogobg="#242424"
#darksubmainbg = "#242424"
# This section will be dynamically updated based off of user input
# Dependencies:
# Most recent user selection will dictate database query
#
#Temporary Lists to test dropdown box selections
#
# Connecting to the database in order to create dynamic dropdown options
#
#conn = sqlite3.connect('assets/FacDatabase.sqlite')
#cursor = conn.cursor()
#cursor.execute('SELECT * FROM table')
#data = cursor.fetchall()
TEMP_OPT = ["100", "200", "300", "400", "500", "All Courses"]
TEMP_SUB = ['AFR African Studies', 'ANTH Anthropology',
'ASIA Asian Studies', 'BI Biology', 'CH Chemistry',
'CINE Cinema Studies', 'CIS Computer and Information Science',
'CIT Computer Information Technology', 'CLAS Classics', 'COLT Comparative Literature',
'CRWR Creative Writing', 'EALL East Asian Languages and Literatures', 'EC Economics',
'ENG English', 'ENVS Environmental Studies', 'ES Ethnic Studies', 'EURO European Studies',
'FLR Folklore', 'GEOG Geography', 'GEOL Geological Sciences', 'GER German', 'HIST History',
'HPHY Human Physiology', 'HUM Humanities', 'INTL International Studies', 'JDST Judaic Studies',
'LA Landscape Architecture', 'LAS Latin American Studies', 'LING Linguistics', 'MATH Mathematics',
'MDVL Medieval Studies', 'PHIL Philosophy', 'PHYS Physics', 'PS Political Science', 'PSY Psychology',
'REES Russian and East European Studies', 'REL Religious Studies', 'RL Romance Languages', 'SCAN Scandinavian',
'SOC Sociology', 'TA Theater Arts', "WGS Women's and Gender Studies"]
GRADE_OPT = ["A", "D/F"]
FACULTY_OPT = ["Permanent", "Temporary", "All"]
selectedDic = {}
selectedList = []
gradeSel = "A"
# subMain.tkraise()
def ResWindow():
# clear(subMain)
resbg = ""
windH = root.winfo_height()
if color_Mode == False:
resbg = darksubmainbg
else:
resbg = submainbg
resFrame = tk.Frame(main, bg=resbg)
fig = Figure(figsize=(5,5), dpi=100)
#dummy test plot
y = [1**2 for i in range(101)]
plot1 = fig.add_subplot(111)
plot1.plot(y)
canvas = FigureCanvasTkAgg(fig, master=main)
canvas.draw()
canvas.get_tk_widget().grid(row=1, column=1)
toolbar = NavigationToolbar2Tk(canvas, window)
toolbar.update()
canvas.get_tk_widget().grid(row=1, column=2)
resFrame.place(height=windH, width=700)
test = tk.Label(resFrame, text="solid")
backButton = tk.Button(resFrame, text="New Query", command=lambda: [resFrame.destroy(), clearBox()])
main.add(resFrame)
test.grid(row=0, column=0)
backButton.grid(row=1, column=0)
class Win:
def popup(self, alertM=""):
tk.Tk().withdraw()
name = messagebox.showinfo(title="Warning", message=alertM)
def submitQuery():
if (var1.get() == 0) and (var2.get() == 0) and (len(selectedList) == 0):
win = Win()
win.popup("Must Select Subject and EasyA/Pass Field in order to submit")
return 0
elif (var1.get() == 0) and (var2.get() == 0) and (len(selectedList) > 0):
win = Win()
win.popup("Must Select either A or D/F")
else:
selectedList.append(gradeSel)
selectedDic["GradeSel"] = gradeSel
selectedDic["ClassCount"] = classCountSelection
print(f"Submitting complete query: {selectedList}")
print(f"Submitting complete query: {selectedDic}")
ResWindow()
#resWindow.tkraise()
def clear(object):
slaves = object.grid_slaves()
for x in slaves:
x.destroy()
def openWeb(link):
webbrowser.open_new(link)
def clearBox():
subMenu0.set('')
subMenu1.set('')
subMenu2.set('')
# subMenu3.set('')
subMenu4.set('')
#subMenu5.set('')
PassTypeL0.deselect()
PassTypeL1.deselect()
selectedDic.clear()
box_state = False
menuState='disabled'
subMenu1.config(state=menuState)
subMenu2.config(state=menuState)
subMenu4.config(state=menuState)
#subMenu5.config(state=menuState)
def change_theme():
if root.tk.call("ttk::style", "theme", "use")=="azure-dark":
root.tk.call("set_theme", "light")
else:
root.tk.call("set_theme", "dark")
def toggle():
global color_Mode
if color_Mode == False:
toggleB.config(image=offjpg)
change_theme()
subMain.config(bg=submainbg)
#subjL.config(bg=submainbg)
subjL.config(bg=submainbg)
classL.config(bg=submainbg)
courseL.config(bg=submainbg)
#facultyL.config(bg=submainbg)
instructL.config(bg=submainbg)
ClassCount.config(bg=submainbg)
PassTypeL.config(bg=submainbg)
PassTypeL0.config(bg=submainbg)
PassTypeL1.config(bg=submainbg)
logo_widget2.config(bg=submainbg)
slab1.config(bg=navbg)
slab2.config(bg=navbg)
slab3.config(bg=navbg)
NavBar.config(bg=navbg)
logoBar.config(bg=logobg)
paddLab.config(bg=logobg)
toggleLab.config(bg=logobg)
toggleB.config(bg=logobg)
logo_widget.config(bg=logobg)
color_Mode = True
print(f"Global ColorMode: {color_Mode}\n")
else:
toggleB.config(image=onjpg)
change_theme()
subMain.config(bg=darksubmainbg)
subjL.config(bg=darksubmainbg)
classL.config(bg=darksubmainbg)
courseL.config(bg=darksubmainbg)
#facultyL.config(bg=darksubmainbg)
instructL.config(bg=darksubmainbg)
ClassCount.config(bg=darksubmainbg)
PassTypeL.config(bg=darksubmainbg)
PassTypeL0.config(bg=darksubmainbg)
PassTypeL1.config(bg=darksubmainbg)
logo_widget2.config(bg=darksubmainbg)
slab1.config(bg=darkslabbg)
slab2.config(bg=darkslabbg)
slab3.config(bg=darkslabbg)
NavBar.config(bg=darkslabbg)
logoBar.config(bg=darklogobg)
paddLab.config(bg=darklogobg)
toggleLab.config(bg=darklogobg)
toggleB.config(bg=darklogobg)
logo_widget.config(bg=darklogobg)
color_Mode = False
print(f"Global ColorMode: {color_Mode}\n")
def closeGUI():
root.destroy()
exit()
def sendSelected(data):
selectedList.append(data)
print(f"New array: {selectedList}")
menuState = 'disabled'
def sub_select0(event):
selected = subMenu0.get()
code = selected.split(" ")
print(code[0])
sendSelected(code[0])
selectedDic["Subject"] = selected
box_state = True
menuState = 'enabled'
subMenu1.config(state=menuState)
subMenu2.config(state=menuState)
subMenu4.config(state=menuState)
def sub_select1(event):
selected = subMenu1.get()
print(selected)
sendSelected(selected)
selectedDic["CourseLevel"] = selected
def sub_select2(event):
selected = subMenu2.get()
print(selected)
sendSelected(selected)
selectedDic["CourseName"] = selected
def sub_select4(event):
selected = subMenu4.get()
print(selected)
sendSelected(selected)
selectedDic["Instructor"] = selected
def sub_select6():
selected = ''
if (var1.get() == 1) and (var2.get() == 1):
print("error: cannot choose both options in same query")
win = Win()
win.popup("Must Select either A or D/F. User cannot select both")
PassTypeL0.deselect()
PassTypeL1.deselect()
return 0
elif (var2.get() == 0) and (var1.get() == 1):
selected = 'A'
elif (var2.get() == 1) and (var1.get() == 0):
selected = 'D/F'
else:
print("error: Must select either A or D/F to submit query")
win = Win()
win.popup("Must Select either A or D/F")
PassTypeL0.deselect()
PassTypeL1.deselect()
return 0
print(selected)
gradeSel = selected
def sub_select7():
selected = ''
if classCount.get() == 1:
classCountSelection = True
print(classCountSelection)
else:
classCountSelection = False
print(classCountSelection)
# Create root Window for the GUI
global root
root = tk.Tk()
root.tk.call("source", "assets/Azure-ttk-theme-main/azure.tcl")
root.tk.call("set_theme", "light")
root.title("Easy A")
root.eval("tk::PlaceWindow . center")
root.geometry("800x850")
#root.configure(bg=rootbg)
# Create toplevel frame for the result window that will display graphs
# resWindow.grid(row=0, column=20)
# Redesigning the base frames slightly
onjpg = PhotoImage(file= "assets/icons8-toggle-on-50.png")
offjpg = PhotoImage(file="assets/icons8-toggle-off-50.png")
logoBar = tk.Frame(root, bg=logobg, height=60)
paddLab = tk.Label(logoBar, text="", bg=logobg)
paddLab.grid(row=1, column=2, padx=240, pady=8)
toggleLab = tk.Label(logoBar, text="Light/Dark Mode:", bg=logobg)
toggleLab.grid(row=1, column=3, padx=10, pady=8)
toggleB = tk.Button(logoBar, image=offjpg, background=logobg, bd=0, command=toggle)
toggleB.grid(row=1, column=4, padx=2, pady=8)
# This is the Logo that I created in Adobe Illistrator
logoFrame = tk.Frame(root, bg=logobg, height=50)
logoImg = Image.open("assets/EasyA.png")
logoS = logoImg.resize((100, 40))
#logo = ImageTk.PhotoImage(file="assets/EasyA.png")
logo = ImageTk.PhotoImage(logoS)
logo_widget = tk.Label(logoBar, image=logo, bg=logobg)
logo_widget.grid(row=1, column=1, padx=5, pady=8)
main = tk.PanedWindow(root, bg=navbg)
"""
NavBar = tk.Frame(main, bg="#99fb99", width=100)
subMain = tk.PanedWindow(root, bg="#FFF", width=200))
main.add(NavBar)
main.add(subMain)
"""
root.grid_rowconfigure(1, weight=1)
root.grid_columnconfigure(0, weight=1)
logoBar.grid(row=0, column=0, sticky="ew")
main.grid(row=1, column=0, sticky="nsew")
NavBar = tk.Frame(main, bg=navbg, width=70)
subMain = tk.Frame(root, bg=submainbg, width=200)
# resFrame = tk.Frame(main, bg=submainbg)
var1 = tk.IntVar()
var2 = tk.IntVar()
classCount = tk.IntVar()
subjL = tk.Label(subMain, text="Subject: ", bg=submainbg)
classL = tk.Label(subMain, text="Course Level: ", bg=submainbg)
courseL= tk.Label(subMain, text="Course Name: ", bg=submainbg)
instructL = tk.Label(subMain, text="Instructor: ", bg=submainbg)
#graphTypeL = tk.Label(subMain, text="Graph Type: ", bg=submainbg)
ClassCount = tk.Checkbutton(subMain, text="Class Count", bg=submainbg, variable=classCount, onvalue=1, offvalue=0, command=sub_select7)
PassTypeL = tk.Label(subMain, text="EasyA/Pass: ", bg=submainbg)
PassTypeL0 = tk.Checkbutton(subMain, text="A", bg=submainbg, variable=var1, onvalue=1, offvalue=0, command=sub_select6)
PassTypeL1 = tk.Checkbutton(subMain, text="D/F", bg=submainbg, variable=var2, onvalue=1, offvalue=0, command=sub_select6)
logoImgv2 = Image.open("assets/EasyA.png")
logoS2 = logoImgv2.resize((90, 35))
#logo = ImageTk.PhotoImage(file="assets/EasyA.png")
logo2 = ImageTk.PhotoImage(logoS2)
logo_widget2 = tk.Label(subMain, image=logo2, bg=submainbg)
varSelect = StringVar(subMain)
subMenu0 = ttk.Combobox(subMain, textvariable=varSelect, values=TEMP_SUB)
subMenu0.bind("<<ComboboxSelected>>", sub_select0)
subMenu1 = ttk.Combobox(subMain, values=TEMP_OPT, state=menuState)
subMenu1.bind("<<ComboboxSelected>>", sub_select1)
subMenu2 = ttk.Combobox(subMain, values=TEMP_SUB, state=menuState)
subMenu2.bind("<<ComboboxSelected>>", sub_select2)
subMenu4 = ttk.Combobox(subMain, values=FACULTY_OPT, state=menuState)
subMenu4.bind("<<ComboboxSelected>>", sub_select4)
#subMenu5 = ttk.Combobox(subMain, values=TEMP_OPT, state=menuState)
#subMenu5.bind("<<ComboboxSelected>>", sub_select5)
#subMenu6 = ttk.Combobox(subMain, values=GRADE_OPT)
#subMenu6.bind("<<ComboboxSelected>>", sub_select6)
canvas = Canvas(subMain, width=100, height=10)
submitBttn = ttk.Button(subMain, text="Submit", command=lambda: [submitQuery()])
canvas = Canvas(subMain, width=100, height=10)
canvas1 = Canvas(subMain, width=100, height=10)
clearBttn = ttk.Button(subMain, text="Reset All", command=clearBox)
# nextBttn = ttk.Button(subMain, text="Next Page", command=ResWindow)
slab1 = tk.Label(NavBar, text="About", bg=navbg, cursor="hand2", font=("Adobe Caslon Pro", 8))
slab2 = tk.Label(NavBar, text="GitHub", bg=navbg, cursor="hand2", font=("Adobe Caslon Pro", 8))
slab3 = tk.Label(NavBar, text="Data Source", bg=navbg, cursor="hand2", font=("Adobe Caslon Pro", 8))
sExitbuttn = ttk.Button(NavBar, text="Quit EasyA", command=closeGUI)
def firstsubMainPage():
# Contrary to the name subMain, this window will hold the bulk of the interation that the user will have with the GUI
# subjL = tk.Label(subMain, text="Subject: ", bg=submainbg)
subjL.grid(row=2, column=1, ipadx=20, ipady=5)
# classL = tk.Label(subMain, text="Course Level: ", bg=submainbg)
classL.grid(row=3, column=1, ipadx=20, ipady=5)
# courseL= tk.Label(subMain, text="Course: ", bg=submainbg)
courseL.grid(row=4, column=1, ipadx=20, ipady=5)
# instructL = tk.Label(subMain, text="Instructor: ", bg=submainbg)
instructL.grid(row=5, column=1, ipadx=20, ipady=5)
# graphTypeL = tk.Label(subMain, text="Graph Type ", bg=submainbg)
ClassCount.grid(row=7, column=1, ipadx=20, ipady=5)
#PassTypeL0
#PassTypeL = tk.Label(subMain, text="EasyA/Pass ", bg=submainbg)
PassTypeL.grid(row=6, column=1, ipadx=0, ipady=5)
logo_widget2.grid(row=1, column=1, padx=30, pady=20, sticky="nsew")
subMenu0.grid(row=2, column=2, padx=10, pady=10)
subMenu1.grid(row=3, column=2, padx=10, pady=10)
subMenu2.grid(row=4, column=2, padx=10, pady=10)
subMenu4.grid(row=5, column=2, padx=10, pady=10)
PassTypeL0.grid(row=6, column=2, padx=0, pady=10)
PassTypeL1.grid(row=6, column=3, padx=0, pady=10)
canvas.grid(row=10, column=2, padx=10, pady=10)
submitBttn.grid(row=11, column=2, padx=10, pady=10)
canvas1.grid(row=10, column=1, padx=10, pady=10)
clearBttn.grid(row=11, column=1, padx=10, pady=10)
main.add(NavBar)
main.add(subMain)
# Labels that will turn into clickable buttons that will take you to the desired screen and information
# slab1 = tk.Label(NavBar, text="About", bg=navbg, cursor="hand2", font=("Adobe Caslon Pro", 8))
slab1.grid(row=1, column=1, padx=5, pady=40)
slab1.bind("<Button-1>", lambda e: openWeb("https://github.com/freddy-lopez01/Project-1-EasyA"))
# slab2 = tk.Label(NavBar, text="GitHub", bg=navbg, cursor="hand2", font=("Adobe Caslon Pro", 8))
slab2.grid(row=2, column=1, padx=5, pady=40)
slab2.bind("<Button-1>", lambda e: openWeb("https://github.com/freddy-lopez01/Project-1-EasyA"))
# slab3 = tk.Label(NavBar, text="Data Source", bg=navbg, cursor="hand2", font=("Adobe Caslon Pro", 8))
slab3.grid(row=3, column=1, padx=5, pady=40)
slab3.bind("<Button-1>", lambda e: openWeb("https://web.archive.org/web/20140901091007/http://catalog.uoregon.edu/arts_sciences/"))
sExitbuttn.grid(row=8, column=1, padx=5, pady=80)
firstsubMainPage()
root.mainloop()