-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainWindow.py
39 lines (35 loc) · 1.43 KB
/
mainWindow.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
import PySimpleGUI as sg
import numpy as np
class mainWindow():
# __init__ is known as the constructor
def __init__(self, task_array):
layout = [[sg.Table(task_array.tolist(), headings=["class/org", "name", "link","priority","%done","start","end","time given","time left"], enable_click_events = True, key = "Table")],
[sg.Button("Add", key = "Add")]]
self.window= sg.Window('Tasks', layout)
self.task_array = task_array
"""_summary_
Handles all events made by the window, might return a new window,"Done, if window was closed, False otherwise
"""
def handle_events(self):
event, values = self.window.read()
if event == sg.WINDOW_CLOSED:
self.window.close()
np.save('tasks', self.task_array)
return "Done"
elif event =='Table':
item = values[event]
print(item)
elif event == 'Add':
return "Added"
return False
def add_data(self, new_data):
try:
if not self.task_array.size > 0:
self.task_array = np.array(new_data,ndmin = 2)
else:
self.task_array = np.append(self.task_array, new_data, axis = 0)
except Exception as e:
print("unable to make new task: ", e)
np.save('tasks', self.task_array)
def update_tasks():
self.window['Table'].update(values=self.task_array.tolist())