forked from antoinelame/GazeTracking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavee.py
414 lines (369 loc) · 11.2 KB
/
navee.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
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
from tkinter import *
from tkinter.tix import TList
from tkinter.messagebox import showinfo, showwarning, showerror
from tkinter import ttk
from turtle import back
import Functions_Navee as ftn
import time
from playsound import playsound
from datetime import timedelta
from gaze_tracking import GazeTracking
import math
import sys
import cv2
#variables
pauseText='Pause/Play'
breakTime=0
breakTime2=0
pauseTimeB=0
exitInt=1
breakCount=0
timeLeft=0
locTime=0
x=1
trabajando = 0
breakT=0
pausa=0
pauseTime=0
#paleta de colores
global letras
global backgnd
global fondocanva
newSesColor='#EC994B'
letras= '#F1EEE9'
backgnd='#4F6BFF'
fondocanva = "#15133C"
#configuracion de la ventana
gui = Tk()
#####################################################################################################################################
#photoimage = PhotoImage(file='C:\\Users\\oguzm\\Logo.png')
gui.configure(bg=backgnd)
icon=PhotoImage(file=r'C:\Users\reegi\GazeTracking\icon.png')
photoimage = PhotoImage(file=r'C:\Users\reegi\GazeTracking\logoNavee.png')
def canva():
gui.title('Navee: Focus Software')
gui.iconphoto(True,icon)
width, height = photoimage.width(), photoimage.height()
canvas = Canvas(gui, bg=fondocanva, width=1.5*width, height=height)
canvas.pack()
canvas.create_image(280,0, image=photoimage, anchor=NW)
gui.resizable(False,False)
canva()
def clear_frame(): #limpia la ventana de los widgets
for widgets in gui.winfo_children():
widgets.destroy()
canva()
def newSes():
clear_frame()
newSesMenu()
def settings():
clear_frame()
settingsMenu()
def pomodoro():
clear_frame()
workMenu()
def calib():
ftn.calibration()
def rtn():
global trabajando
trabajando=0
clear_frame()
mainMenu()
def mainMenu():
#Boton para iniciar una nueva sesion
newSesBut = Button(gui,
text= 'New Session',
command=newSes,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=newSesColor,
activeforeground=newSesColor,
activebackground=letras,)
newSesBut.place(x=30, y=0+36)
setBut = Button(gui,
text= 'Settings',
command=settings,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
setBut.place(x=30, y=80+72)
statBut = Button(gui,
text= 'View Stats',
command=viewStats,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
statBut.place(x=30, y=160+108)
exitBut = Button(gui,
text= 'Exit',
command=exitCom,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
exitBut.place(x=30, y=240+144)
def exitCom(): #esto no funciona
print('haha')
def viewStats():
print("Perrón las stats")
def returnBut():
returnB = Button(gui,
text= 'Return',
command=rtn,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
returnB.place(x=30, y=240+144)
def newSesMenu():
gui.title('New Session')
pomoBut = Button(gui,
text= 'Pomodoro',
command=pomodoro,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
pomoBut.place(x=30, y=0+36)
# 15,3,21
progBut = Button(gui,
text= 'Program your own session',
command=progOwn,
font=('Comic Sans',15),
height=3,
width=21,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
progBut.place(x=30, y=80+72)
returnBut()
def progOwn():
print("Perrón las settings")
def settingsMenu():
gui.title("Settings")
calibrationB= Button(gui,
text='Calibration',
command= calib,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
calibrationB.place(x=30, y=0+36)
soundBut= Button(gui,
text='Choose sound package',
command= soundP,
font=('Comic Sans',15),
height=3,
width=21,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
soundBut.place(x=30, y=80+72)
returnBut()
def soundP():
print("Perrón el Sound")
def workMenu():
global pauseText
gui.title("Pomodoro Working Session")
start= Button(gui,
text='Start',
command=startSessionPomo,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
start.place(x=30, y=80+72)
pause = Button(gui,
text=pauseText,
command=pauseSession,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
pause.place(x=30, y=160+108)
returnBut()
def pauseSession():
#Poner aqui un pop up de Pausa!
global webcam
global trabajando
global gaze
global pauseTime
global times
global pauseText
if trabajando == 0:
trabajando =1
webcam = cv2.VideoCapture(0)
gaze=GazeTracking()
pauseTime= time.time()-newTime
pauseText='Pause'
elif trabajando ==1:
pauseText='Un-Pause'
trabajando=0
webcam.release()
def breakMenu():
clear_frame()
gui.title("Pomodoro Break")
startB= Button(gui,
text='Start Break',
command= breakStart,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
startB.place(x=30, y=80+72)
pauseB = Button(gui,
text=pauseText,
command=breakPause,
font=('Comic Sans',30),
height=1,
width=10,
fg=letras,
bg=backgnd,
activeforeground=backgnd,
activebackground=letras,)
pauseB.place(x=30, y=160+108)
returnBut()
def breakPause():
global pauseTimeB
global breakT
if breakT==0:
breakT=1
pauseTimeB=time.time()-breakTime2
elif breakT==1:
breakT=0
def breakStart():
global breakTime1
global sT
global breakCount
global breakT
global txtB
breakTime1=time.time()
breakT=1
if breakCount>3:
sT=int(900)
breakCount=0
elif breakCount<3:
sT=int(500) # 5 mins ==500!!! cambia a 15 pa revisar si jala
breakCount=breakCount+1
txtB= Label(gui,
text = 'Time left: ',
font=('Comic Sans',15),
height=3,
width=21,
fg=fondocanva,
bg=newSesColor,
activeforeground=newSesColor,
activebackground=fondocanva,)
txtB.place (x=30,y=36)
def startSessionPomo():
#AQUI CORRO TODO POR PRIMERA VEZ!!!!!!
global timeLeft
timeLeft=0
global txt
global webcam
webcam = cv2.VideoCapture(0)
global gaze
gaze=GazeTracking()
global times
times=time.time()
global newTime
newTime=time.time()
global tL
tL=1
global trabajando
trabajando=1
global wt
wt=int(1500)
print('start')
global attention
attention=r"C:\Users\reegi\GazeTracking\ZeldaSoundPack\attention.mp3"
global alarmSound
alarmSound= r'C:\Users\reegi\GazeTracking\ZeldaSoundPack\alarm.mp3'
txt= Label(gui,
text = 'Time left: ',
font=('Comic Sans',15),
height=3,
width=21,
fg=fondocanva,
bg=newSesColor,
activeforeground=newSesColor,
activebackground=fondocanva,)
txt.place (x=30,y=36)
def workingTime(time1,newTime,attention):
global x
global locTime
global timeLeft
global webcam
global gaze
_, frame = webcam.read()
gaze.refresh(frame)
located= gaze.pupils_located
if located==False:
if x==1:
locTime=time.time()
x=0
if (newTime-locTime) > 10:
playsound(attention)
showwarning('Pay attention!','Hey! Remember your task? Go for it!')
x=1
else:
x=1
locTime=0
if (newTime-time1)> 1200: #5 minutos en segundos, tampoco funciona
if timeLeft == 0:
showinfo('Time Left', 'Only 5 minutes left, you can do this!')
mainMenu() #VA FUERA NO LO MUEVAS
while 1:
gui.update()
if trabajando==1:
newTime=time.time()-pauseTime
workingTime(times,newTime,attention)
txt['text']='Time Left: '+str(timedelta(seconds=math.trunc(wt-(newTime-times))))
#workProgress(newTime,times)
if (newTime-times)> wt:
trabajando=0
playsound(alarmSound)
showinfo("Work time over!", "Great job! Time for a break! Go drink some water and stretch yourself")
webcam.release()
breakMenu()
if breakT==1: #incorporar contador para que se pueda decidir si es descanso corto o largo
breakTime2= time.time()-pauseTimeB
txtB['text']='Time Left: '+str(timedelta(seconds=math.trunc(sT-(breakTime2-breakTime1))))
if (breakTime2-breakTime1) >sT:
breakT=0
playsound(alarmSound)
showinfo("Break Time over!","Hope you got some rest! Lets keep going!")
workMenu()