-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window.py
117 lines (97 loc) · 3.84 KB
/
Window.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
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
from tkinter import *
from tkinter import ttk
from PIL import Image, ImageTk
from tkinter.filedialog import askopenfilename
from DataService import DataService
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
self.currentFile = None
self.entryList = []
self.nominalList = []
self.deptList=[]
self.tkvar = StringVar()
self.init_window()
def init_window(self):
self.master.title("Finance App")
self.pack(fill=BOTH, expand=1)
menu = Menu(self.master)
self.master.config(menu=menu)
file = Menu(menu)
file.add_command(label='Import File', command=self.openFile)
file.add_command(label='Exit', command=self.client_exit)
menu.add_cascade(label='File', menu=file)
func = Menu(menu)
func.add_command(label='Show Image', command=self.showImg)
func.add_command(label='Show Text', command=self.showTxt)
menu.add_cascade(label="Functions", menu=func)
calcButton = Button(self, text="Calculate", command=self.getDeptTotal)
calcButton.place(x=0, y=580)
quitButton = Button(self, text="Quit", command=self.client_exit)
quitButton.place(x=0, y=0)
# if (self.currentFile == True):
def client_exit(self):
exit()
def showImg(self):
load = Image.open('pic.jpg')
render = ImageTk.PhotoImage(load)
img = Label(self, image=render)
img.image = render
img.place(x=0, y=0)
def showTxt(self):
text = Label(self, text='Who Watches The Watchmen?')
text.pack()
def populateMenu(self, list):
options = []
for item in list:
options.append(str(item.name))
return options
def openFile(self):
filename = askopenfilename()
self.currentFile = DataService.openFile(filename)
ws = self.currentFile['Sheet1']
DataService.categorise(ws)
self.entryList = DataService.importEntries(self.currentFile, 'Sheet1')
entryLength = IntVar()
entryLength.set(self.entryList.__len__())
self.nominalList = DataService.getList(ws, 3, 4)
nominalLength = IntVar()
nominalLength.set(self.nominalList.__len__())
self.deptList = DataService.getList(ws, 1, 2)
deptLength = IntVar()
deptLength.set(self.deptList.__len__())
nominalText = Label(self, text="Unique Nominal Codes: " + str(nominalLength.get()))
nominalText.pack()
deptText = Label(self, text="Unique Departments: " + str(deptLength.get()))
deptText.pack()
entryText = Label(self, text="Unique Postings: " + str(entryLength.get()))
entryText.pack()
# tkvar = StringVar(root)
search = ttk.Combobox(self, state="readonly", textvariable=self.tkvar)
menuChoices = self.populateMenu(self.deptList)
search['values'] = self.populateMenu(self.deptList)
# menuChoices = ['Dept 1', 'Dept 2']
# tkvar.set(menuChoices[0])
print(menuChoices[1])
# popupMenu = OptionMenu(root, tkvar, *menuChoices)
Label(root, text="Choose a Dept").place(x=50, y=250)
# popupMenu.place(x=50, y=300)
search.place(x=50, y=250)
sumText = Label(self, text=("Dept Total" + (self.getDeptTotal)))
sumText.place(x=200, y=550)
def change_dropdown(*args):
print( self.tkvar.get() )
# link function to change dropdown
self.tkvar.trace('w', change_dropdown)
print(filename)
def getDeptTotal(self):
ws = self.currentFile["Sheet1"]
dept = self.tkvar.get()
total = DataService.sumDept(dept, ws)
return str(total)
root = Tk()
root.geometry("800x600")
DataService = DataService()
app = Window(root)
app.mainloop()