Skip to content

Instantly share code, notes, and snippets.

@veryhappythings
Created June 1, 2009 22:24
Show Gist options
  • Save veryhappythings/121846 to your computer and use it in GitHub Desktop.
Save veryhappythings/121846 to your computer and use it in GitHub Desktop.
A simple timer for the pomodoro technique, written using Shoes.
# http://www.pomodorotechnique.com/
Shoes.app :width => 200, :height => 150, :resizable => false, :title => 'Pomo!' do
def update_time!
@timer_display.text = '%02d:%02d' % [@seconds / 60, @seconds % 60]
end
background whitesmoke
paused = true
@seconds = 0.0
@timer_display = para '00:00', :size => 58
start_button = button 'start', :width => '33%' do
paused = false
end
pause_button = button 'pause', :width => '33%' do
paused = true
end
reset_button = button 'reset', :width => '33%' do
@seconds = 0.0
update_time!
end
animate(1) do
@seconds += 1 unless paused
update_time!
if @seconds >= 1500
paused = true
if @timer_display.style[:stroke] == black
@timer_display.style :stroke => whitesmoke
else
@timer_display.style :stroke => black
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment