Silly Little Pomodoro Timer using Tkinter

https://en.wikipedia.org/wiki/Pomodoro_Technique
Seems to work 🙂

[sourcecode language=”Text”]
import Tkinter
from Tkinter import *
import time
import math
import tkMessageBox

tickCount = 0
divisions = 25

def drawClock( clockArea ):
global tickCount
global divisions
tetha = ( 2 * math.pi ) / divisions
tickCount = tickCount + 1
clockArea.create_oval(10,10,190,190,width=10,fill="blue")
clockArea.create_line( 100, 100, 100 + 60 * math.sin(tetha * ( tickCount – 1 ) ), 100 – 60 * math.cos(tetha * ( tickCount – 1) ),width =3 )
print ( tickCount)
if ( tickCount == divisions):
tkMessageBox.showinfo("Time up!", "Time up!")
tickCount = 0
return
clockArea.after(1000 * 60 , lambda: drawClock(clockArea) )
def reset(clockArea):
global tickCount
global divisions
tickCount = 0
divisions = 25
drawClock(clockArea)

def takeBreak(clockArea):
global divisions
tickCount = 0
divisions = 5
drawClock(clockArea)

if __name__ == "__main__":
root = Tk()
root.resizable(0,0)
root.title("Pomodoro Timer")
clockArea = Canvas(root,width=200,height=200)
clockArea.create_oval(10,10,190,190,width=10,fill="blue")
clockArea.create_line ( 100,100, 100, 20, width = 3 )
clockArea.pack()
clockArea.after(1000 * 60 , lambda: drawClock(clockArea))
resetButton = Button(root, text="Reset",width=25,command=lambda:reset(clockArea) )
resetButton.pack()
takeBreakButton = Button(root,text="TakeBreak",width=25,command=lambda:takeBreak(clockArea) )
takeBreakButton.pack()
root.mainloop()

[/sourcecode]

Leave a Reply

Your email address will not be published.