Created
June 20, 2022 03:41
-
-
Save abenezerangelos/744014f99a6daab2ce3a766f2c05c86a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
from time import * | |
from threading import Thread | |
# ---------------------------- CONSTANTS ------------------------------- # | |
PINK = "#e2979c" | |
RED = "#e7305b" | |
GREEN = "#9bdeac" | |
YELLOW = "#f7f5dd" | |
FONT_NAME = "Courier" | |
WORK_MIN = 25 | |
SHORT_BREAK_MIN = 5 | |
LONG_BREAK_MIN = 20 | |
# ---------------------------- TIMER RESET ------------------------------- # | |
# ---------------------------- TIMER MECHANISM ------------------------------- # | |
# ---------------------------- COUNTDOWN MECHANISM ------------------------------- # | |
def start_countdown(): | |
for i in range(4): | |
print(i) | |
timer["text"] = "Work" | |
timer["fg"] = GREEN | |
window.update() | |
start=time() | |
end= time() | |
while end-start<=3: | |
end=time() | |
print(end - start) | |
timer["text"]="Break" | |
timer["fg"]=PINK | |
test = Frame(window,width=100, height=50, bg=YELLOW) | |
test.grid(row=3,column=1) | |
Label(test,text="✔", font=(FONT_NAME, 12, "bold"), bg=YELLOW, fg=GREEN,padx=3).pack(in_=test,side=LEFT) | |
# counter = Label(text="✔", font=(FONT_NAME, 12, "bold"), bg=YELLOW, fg=GREEN) | |
# counter.grid(row=3, column=1) | |
window.update() | |
start=time() | |
end=time() | |
while end-start<=1: | |
end=time() | |
print(end-start) | |
if i ==1: | |
window.destroy() | |
beginning() | |
# ---------------------------- UI SETUP ------------------------------- # | |
def beginning(): | |
global window | |
window=Tk(className="Pomodoro") | |
window.title("Pomodoro") | |
window.config(pady=50,padx=100,bg=YELLOW) | |
global timer | |
timer=Label(text="Timer",font=(FONT_NAME,50,"bold"),bg=YELLOW,foreground=GREEN) | |
timer.grid(row=0,column=1) | |
canvas=Canvas(width=200,height=223,bg=YELLOW,highlightthickness=0) | |
tomato=PhotoImage(file="tomato.png") | |
canvas.create_image(100,100,image=tomato) | |
canvas.create_text(100,120,text="00:00",fill="white",font=(FONT_NAME,35,"bold")) | |
canvas.grid(row=1,column=1) | |
start=Button(text="Start",highlightthickness=0,borderwidth=0,command=start_countdown) | |
start.grid(row=2,column=0) | |
end=Button(text="Reset",highlightthickness=0,borderwidth=0) | |
end.grid(row=2,column=2) | |
window.mainloop() | |
beginning() | |
# class Work(Thread): | |
# def run(self): | |
# for i in range(4): | |
# print("!!!!") | |
# timer.config(text="Work",fg=GREEN) | |
# start=int(time()) | |
# end=int(time()) | |
# while end-start<3: | |
# end=time() | |
# | |
# Break().start() | |
# if i == 3: | |
# return "exit" | |
# | |
# | |
# | |
# array=[1] | |
# class Break(Thread): | |
# def run(self): | |
# | |
# print("$$$$$$ ") | |
# timer.config(text="Break",fg=PINK) | |
# test=Frame(width = 100,height=50,bg=YELLOW) | |
# test.grid(row=3,column=1) | |
# Label(test,text="✔", font=(FONT_NAME, 12, "bold"), bg=YELLOW, fg=GREEN,padx=3).pack(in_=test,side=LEFT) | |
# | |
# start = int(time()) | |
# end = int(time()) | |
# while end - start < 1: | |
# end = time() | |
# | |
# | |
# array[0]+=1 | |
# | |
# def start_countdown(): | |
# | |
# print("Ok") | |
# | |
# Work().run() | |
# beginning() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment