From: 7stud -- Date: 2008-04-14T15:01:59+09:00 Subject: Re: ruby/tk and loop delay 7stud -- wrote: > Ed Redman wrote: >> I am writing a card game in ruby/tk. >> >> I have a Tk_button(shuffle) that shuffles the cards and places them on a >> canvas.The shuffle works fine but I would like to have a slight delay >> between between each card being displayed on the canvas. Below is the >> shuffle buttons command. I would like to delay the loop each time so >> their is a slight delay. I have tried putting Tk.after(time) >> { part around the loop} but it just delays the shuffle and is not Try using the calling the update() method on the widget. I can't get the after() method to work at all: even if I specify 40,000,000 milliseconds as the delay, all the lines get drawn instantly. require 'tk' def do_press(e) widget = e.widget x = e.x y = e.y threads = [] 10.times do |i| x += 10 TkcLine.new(widget, x, y, x+100, y+100) Tk.after(40000000, proc{widget.update} ) end end root = TkRoot.new {title 'Canvas Test'} canvas = TkCanvas.new(root) canvas.pack canvas.bind('ButtonRelease-1', lambda {|e| do_press(e)}) Tk.mainloop -- Posted via http://www.ruby-forum.com/.