-
Notifications
You must be signed in to change notification settings - Fork 2
/
productive.py
171 lines (121 loc) · 4.33 KB
/
productive.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
from tkinter import *
from tkinter import messagebox
import tkinter
import math
from PIL import ImageTk
tasks_list = []
counter = 1
PINK = "#e2979c"
RED = "#e7305b"
BROWN = "#964B00"
BLACK = "#002240"
FONT_NAME = "Courier"
WORK_MIN = 50
SHORT_BREAK_MIN = 10
reps = 0
timer = None
def inputError() :
if enterTaskField.get() == "" :
messagebox.showinfo("Enter","I dont think there can be an empty task!")
enterTaskField.delete(0, END)
taskNumberField.delete(0.0, END)
return 0
return 1
def insertTask(e = 0):
global counter
value = inputError()
if value == 0:
return
content = enterTaskField.get() + "\n"
tasks_list.append(content)
TextArea.insert('end -1 chars', "( " + str(counter) + " ) " + content)
counter += 1
enterTaskField.delete(0, END)
def delete(e = 0) :
global counter
if len(tasks_list) == 0 :
messagebox.showinfo("No task","Hey... there is no unfinished business!")
return
number = taskNumberField.get(1.0, END)
if number == "\n" :
messagebox.showerror("input error")
return
else :
task_no = int(number)
taskNumberField.delete(0.0, END)
tasks_list.pop(task_no - 1)
counter -= 1
TextArea.delete(1.0, END)
for i in range(len(tasks_list)) :
TextArea.insert('end -1 chars', "( " + str(i + 1) + " ) " + tasks_list[i])
def clear_screen():
messagebox.showinfo("Over","Three hours completed. Hurray... Now it is time for rest !")
reset_timer()
def reset_timer():
root.after_cancel(timer)
canvas.itemconfig(timer_text, text="00:00")
title_label.config(text=" TIMER ")
global reps
reps = 0
def start_timer():
global reps
reps += 1
work_sec = WORK_MIN * 60
short_break_sec = SHORT_BREAK_MIN * 60
if reps % 2 == 0:
count_down(short_break_sec)
title_label.config(text=" BREAK ", fg=PINK)
else:
count_down(work_sec)
title_label.config(text=" WORK. ", fg=BROWN)
if reps == 6:
clear_screen()
def count_down(count):
count_min = math.floor(count / 60)
count_sec = count % 60
if count_sec < 10:
count_sec = f"0{count_sec}"
canvas.itemconfig(timer_text, text=f"{count_min}:{count_sec}")
if count > 0:
global timer
timer = root.after(1000, count_down, count - 1)
else:
start_timer()
if __name__ == "__main__" :
root = tkinter.Tk(className=' Webie: Your productivity sidechick ')
root.geometry('600x430')
root.resizable(False,False)
b = ImageTk.PhotoImage(file = "bg.jpeg")
limg= Label(root, i=b)
limg.pack()
enterTask = Label(text=" TASKS ", fg=BROWN, font=(FONT_NAME, 30))
CenterTask = Label(root, text = "Press Enter key to submit")
enterTaskField = Entry(root)
Submit = Button(root, text = "Submit", command = insertTask)
TextArea = Text(root, height = 10, width = 28, font = "lucida 13")
taskNumber = Label(root, text = "Delete Task Number")
taskNumberField = Text(root, height = 1, width = 2, font = "lucida 13")
deltask = Label(root, text = "Press Delete key to remove")
done = Button(root, text = "Done", command = delete)
root.bind('<Return>', insertTask)
root.bind('<Delete>',delete)
enterTask.place(x = 35, y = 30)
CenterTask.place(x = 45, y = 85)
enterTaskField.place(x = 45, y = 110)
Submit.place(x = 175, y = 110)
TextArea.place(x = 45, y = 140)
taskNumber.place(x = 45, y = 350)
taskNumberField.place(x = 170, y = 350)
deltask.place(x=45,y=380)
done.place(x = 195, y = 380)
title_label = Label(text=" TIMER ", fg=BROWN, font=(FONT_NAME, 30))
title_label.place(x = 360, y = 30)
canvas = Canvas(root,height=120,width=150)
canvas.pack()
timer_text = canvas.create_text(75, 70, text="00:00", fill="black", font=(FONT_NAME, 35, "bold"))
canvas.place(x=375, y=90)
start_button = Button(text=" Start ", highlightthickness=0, command=start_timer)
start_button.place(x=390, y=250)
reset_button = Button(text=" Reset ", highlightthickness=0, command = reset_timer)
reset_button.place(x = 450, y = 250)
root.mainloop()