Ok, so I'm not real sure about lots of things in Shoes, but my trial and error approach has failed me so far on this one.
I've got a class that does some sort of computation that takes a while, and I want to throw up a progress bar for the user to look at while it finishes. My computationally intensive method yields its percent complete if passed a block:
class MathyStuff
def initialize()
end
## Some expensive, time consuming method which yields it's percent complete
def expensiveMethod(&block)
0.upto(100) do |i|
0.upto(100000) do |j|
k = j;
end
yield i.to_f/100;
end
end
end
Here's what I'd like to say in Shoes:
require 'MathyStuff.rb'
Shoes.app do
@myMathyStuff = MathyStuff.new();
button("Do expensive mathy thing...") do
window() do
@progress = progress();
@myMathyStuff.expensiveMethod() {|percent| @progress.fraction = percent;}
end
end
end
But it doesn't seem to work. I've tried with/without the window call, I've tried animate() in various ways, I even tried calling Thread.new and passing it the window block, having them converse via Shoes.APPS()[0].get/setPercent methods; nothing seems to work properly.
Maybe I'm not using the progress bar the way it's meant to be used. Then again, what else would a progress bar be for? ;-)