-
Notifications
You must be signed in to change notification settings - Fork 0
/
window_main.py
171 lines (149 loc) · 7.7 KB
/
window_main.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
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
import os
from datetime import datetime
import PySimpleGUI as sg
from db import dbms
from window_settings import settingsWindow as sw
import process_main as func
from output_logger import logging as logs
sg.theme("Dark2")
myDb = dbms()
class mainWindow:
def __init__(self):
self.tempDirectory = os.getcwd() + "\\temp"
def styling(self):
subjects = []
for i in myDb.getFromSettings("type", "subject"):
subjects.append(i[1])
if len(subjects) == 0:
subjects.append("Please insert a subject")
finalLayout = [
[
sg.Text("Date: ", size=(15,1)),
sg.InputText(str(datetime.now().strftime("%d-%m-%Y")), key="dateToAdd", size=(65,1), enable_events=True)
],
[
sg.Text("Subject:" , size=(15,1)),
sg.Combo(subjects, key="subject", size=(63,1), default_value=subjects[0])
],
[
sg.Text("Choose Method:\t",),
sg.Radio(text="Image to text", group_id="method", key = "I", default = True, enable_events=True),
sg.Radio(text="Meet", group_id="method", key = "M", enable_events=True),
sg.Radio(text="Hybrid", group_id="method", key = "H", enable_events=True),
sg.Radio(text="Upload data of " + str(datetime.now().strftime("%d-%m-%Y")), group_id="method", key = "U", enable_events=True)
],
[
sg.Text("", size=(15,1)),
sg.Checkbox("Take Screenshots Automatically", enable_events=True, default = False, key="-SS-"),
sg.Checkbox("Upload Data to google Sheets", key="uploadData", default=True)
],
#[
#sg.Text("What to Do:\t"),
#sg.Radio(text="Upload data To Google Sheets", group_id="method2", key = "uploadData", default = True),
#sg.Radio(text="Save data locally", group_id="method2", key = "saveData", default = False)
#],
[
sg.Text("Meet Link:", size=(15,1)),
sg.InputText(disabled_readonly_background_color="#8f9c92", key="meetLink", size=(65,1), disabled=True)
],
[
sg.Text("Images Folder:\t", key="directoryText", visible=False),
sg.In(self.tempDirectory, disabled_readonly_background_color="#8f9c92", size=(65, 1), enable_events=True, key="-FOLDER-", visible=False),
#sg.FolderBrowse(size=(11, 1), visible=False)
],
[
sg.Button("Begin", size=(73,1), key="beginOp"),
#sg.Button("Take SS Only", size=(27,1), key="ssOnlyButton", disabled=True),
#sg.Button("Download JSON Data Only", size=(27,1), key="jsonDownloadButton", disabled=True)
],
[
sg.Text("Log Box:", key="log_textBox")
],
[
sg.Multiline(key="logbox", size=(82,12), autoscroll=True, disabled=True)
],
[
sg.Button(" Clear Logs ", key="clearLog", size=(35,1)),
sg.Button(" Settings ", key="settingsMenu", size=(35,1))
]
]
return finalLayout
def createMainWindow(self):
return sg.Window("Python Auto Attendance", [[self.styling()]]).Finalize()
def main(self):
window = self.createMainWindow()
log = logs(window)
while True:
event, values = window.read()
if event == "Exit" or event == sg.WIN_CLOSED:
break
#logger.updateBox("Event " + str(i) + " " + event)
if event == "beginOp":
self.disableWindow(window, True)
log.write("Operation Begun, Please Wait...", textColor = "blue")
func.main(values, log)
self.disableWindow(window, False)
#init_op(values, logger).startOp()
if (event == "dateToAdd"):
if values["-SS-"] == True:
window['-FOLDER-'].update(os.getcwd() + "\\data\\images\\" + values["dateToAdd"])
window['U'].update(text="Upload data of " + values["dateToAdd"])
if values["U"] == True:
window['directoryText'].update("JSON Folder:\t")
window['uploadData'].update(value=True)
#window['saveData'].update(disabled=True)
window['uploadData'].update(disabled=True)
window['-SS-'].update(disabled=True)
window['-FOLDER-'].update(os.getcwd() + "\\data\\ready_to_upload\\")
window['-FOLDER-'].update(disabled=True)
window['meetLink'].update(disabled=True)
elif values["I"] == True:
window['directoryText'].update("Images Folder:\t")
#window['saveData'].update(disabled=False)
window['-SS-'].update(disabled=False)
#window['meetLink'].update(disabled=False)
#window['-FOLDER-'].update(self.tempDirectory)
#window['-FOLDER-'].update(disabled=False)
if values["-SS-"] == True:
#window.Refresh()
window['-FOLDER-'].update(os.getcwd() + "\\data\\images\\" + values["dateToAdd"])
window['-FOLDER-'].update(disabled=True)
window['meetLink'].update(disabled=False)
else:
window['-FOLDER-'].update(self.tempDirectory)
window['-FOLDER-'].update(disabled=False)
window['meetLink'].update(disabled=True)
elif values["M"] == True:
window['directoryText'].update("Images Folder:\t")
#window['saveData'].update(disabled=False)
window['uploadData'].update(disabled=False)
window['-SS-'].update(disabled=True)
window['meetLink'].update(disabled=False)
window['-FOLDER-'].update("")
window['-FOLDER-'].update(disabled = True)
#window['-FOLDER-'].update(disabled=False)
elif values["H"] == True:
window['directoryText'].update("Images Folder:\t")
#window['saveData'].update(disabled=False)
window['uploadData'].update(disabled=False)
window['-SS-'].update(disabled=False)
window['meetLink'].update(disabled=False)
if values["-SS-"] == True:
#window.Refresh()
window['-FOLDER-'].update(os.getcwd() + "\\data\\images\\" + values["dateToAdd"])
window['-FOLDER-'].update(disabled=True)
else:
window['-FOLDER-'].update(self.tempDirectory)
window['-FOLDER-'].update(disabled=False)
if event == "settingsMenu":
window.close()
sw().main()
window = self.createMainWindow()
log = logs(window)
if event == "clearLog":
window["logbox"].update("")
window.close()
def disableWindow(self, window, whatToDo):
obj = ["dateToAdd", "subject", "I", "M", "H", "U", "-SS-", "uploadData", "meetLink", "-FOLDER-", "beginOp", "clearLog", "settingsMenu"]
for i in obj:
window[i].update(disabled=whatToDo)