I'm new to Ruby Shoes. I am doing a program that will fetch the information from the internet every 5 minutes.
I am thinking of using the ruby shoes method every()
. A progress bar will show how close until it approaches the 5 minutes mark, then the main code get executed then the method will wait for 5 min to loop again. However, with this code, the program will wait after 300 sec to do the first iteration, so the progress bar won't show up until then. I want to ask if you can show me a way to work around this?
Right now,I can't even think about how to tweak the animate
to work with my 300 seconds, so I have to set every(100)
and animate(1)
so basically every 1:40 minute not 5 min.
Anyway, my top priority right now is to make the progress bar show up not only during the iteration but also before it
Sorry for the long post. This is my pseudo code for the progress bar I hope you can get the idea:
Shoes.app do
stack :margin => 0.1 do
title "Progress bar"
@p = progress :width => 1.0
every(100) do |p|
@animate = animate (1) do |i|
@p.fraction = (i % 100) / 100.0
@animate.stop if i > 99
end
#main codes go here
end
end
end
I am new to this and still learning. I appreciate your help!
I change your code, so that it's executed every 10 seconds. You can modify it yourself to every 5 minutes. Try it and thank me later ;)
Shoes.app do
stack :margin => 0.1 do
title "Progress bar"
@p = progress :width => 1.0
@animate = animate (1) do |i|
@p.fraction = (i % 10) / 10.0
@animate.stop if @p.fraction > 0.9
end
every(10) do |p|
#main codes go here
end
end
end