Laurent is right and and I think best would be for you to use a NSTimer.
def drawWord
if !next_word
self.timer.invalidate
return
end
self.label.stringValue = next_word
self.setNeedsDisplay true
end
def next_word
...
end
self.timer = NSTimer.scheduledTimerWithTimeInterval( 1/20.0,
target:self, selector:"drawWord:", userInfo:nil, repeats:true)
Am 25.05.2011 um 02:06 schrieb [email protected]:
> I have a label that I have set to blank, and after a user clicks 'go' I
> generate a random word or number and use:
>
> self.label.stringValue = "some_word"
>
> to update the view.
>
> However, I would like to show 200 or so random words in quick succession
> before the final one is shown - just because it's too plain at the moment.
> Alternatively, I'd be happy with showing an animated graphic in its place -
> which is replaced by the final random word after a few seconds.
>
> I've tried things like:
>
> 100.times do
> num = rand(40)
> self.label.stringValue = num
> sleep 1
> end
>
> But it doesn't work. I've also (after googling) tried .reloadData but to no
> avail as well.
>
> Any ideas on how to achieve this? Or pointers on how to add animations to my
> window/views?
--
Thomas R. "TomK32" Koll, Ruby/Rails freelancer
http://ananasblau.com | http://github.com/TomK32
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel