From: james@... Date: 2002-03-27T03:46:02+09:00 Subject: Error calling Tk in a loop I'm trying to write some code that pops up a Tk window when for certain events. The first call to display works, but the next one gives this error: C:/Ruby/lib/ruby/1.6/tk.rb:986:in `_invoke': can't invoke "label" command: application has been destroyed (RuntimeError) The Ruby version is ruby 1.6.6 (2001-12-26) [i586-mswin32] This is on a Win2K box. I haven't installed any other Tcl/Tk but what came with the Ruby installation. I get the same error on my Linux box using Ruby 1.6.7. Any ides on what causes this, and how to avoid it? Here's example code: #----------------------------------------------- require 'tk' class AlertBox def initialize( caption, box_text ) root = TkRoot.new { title caption } TkLabel.new(root) { text box_text pack { padx 25 ; pady 25; side 'left' } } Tk.mainloop end end if __FILE__ == $0 1.upto(3){ |x| AlertBox.new( "Alert #{x}", "This is #{x}") # First call works, next call fails. sleep(5) } end #----------------------------------------------- Thanks, James