Shoes.app do
  stack do
    @p = progress(:width => 1.0, :margin => 0.1)
    @a = animate 2 do |frame|
      if frame == 10
        @a.stop
        next
      end
      @p.fraction = (frame + 1.0) / 10.0
    end
  end
end

On Wed, Jun 3, 2009 at 1:34 PM, Ian Leitch <[email protected]> wrote:
> Hey all,
>
> I'm obviously using Shoes in a way it wasn't intended because by app isn't
> acting like I'm expecting!
>
> So, I have a loop that does some computation on each iteration and updates a
> progress bar as it goes. Once the loop is done, the window closes.
>
> The problem is, the progress bar doesn't update inside my loop, it only
> updates once my code has finished, and because I'm closing the window right
> after, I don't really see much.
>
> So what's the right thing to do in this situation? Do I somehow instruct the
> progress bar to draw immediately, or is there a way to let execution return
> to the main internal loop (whatever you call it) which will yield my next
> iteration as a callback? I feel like I should be using something like
> times(n) {}, or each([1, 2, 3]) {} that allows the UI to be drawn after each
> iteration, but I don't see anything in the manual that does this...
>
> Many thanks!
>
> Example code:
>
> Shoes.app do
>   stack do
>     @p = progress(:width => 1.0, :margin => 0.1)
>     start do
>       10.times do |i|
>         sleep 0.5
>         @p.fraction = (i + 1.0) / 10.0
>       end
>       close
>     end
>   end
> end
>



-- 
    ~devyn

Reply via email to