-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
67 lines (61 loc) · 1.39 KB
/
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
import time
import pygame
from playsound import playsound
#---------------------------
#-----VARS--------------------
swidth, sheight = 300, 200
run = True
s, m = 0, 0
rest = False
work, breaka = map(int,input("""
Please type work time and break time(in minutes) separated by a space
here: """).split())
#-----------------------------
#------PYGAME INIT------------
pygame.init()
window = pygame.display.set_mode((swidth, sheight))
pygame.display.set_caption("POMO TIMER")
#-----------------------------
#------MAIN LOOP--------------
while run:
pygame.time.delay(60)
time.sleep(1)
if rest == False:
if m!=(work):
s+=1
if s>59:
s=0
m+=1
else:
rest = True
playsound(r"alarm.wav")
m, s = 0, 0
else:
if m!=(breaka):
s+=1
if s>59:
s=0
m+=1
else:
rest = False
playsound(r"alarm.wav")
m, s = 0, 0
keys = pygame.key.get_pressed()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if len(str(m))!=2 and len(str(s))!= 2:
t = "0" + str(m) + ":" + "0" + str(s)
elif len(str(m))!=2:
t = "0" + str(m) + ":" + str(s)
elif len(str(s))!=2:
t = str(m) + ":" + "0" + str(s)
else:
t = str(m) + ":" + str(s)
myfont = pygame.font.SysFont('Lucida Console', 60)
timee = myfont.render(t, False, (255, 255, 255))
window.fill((0,0,0))
window.blit(timee,(70, 65))
pygame.display.update()
#-------------------------------
pygame.quit()