On Sep 26, 2007, at 9:21 AM, Hidetoshi NAGAI wrote: > How about the following? > ---------------------------------------------------------------- > require 'tk' > > evloop = Thread.new{Tk.mainloop} > text = TkText.new(Tk.root).pack > > i = 0 > n = 10000 > > Tk.root.protocol(:WM_DELETE_WINDOW){ > if Tk.messageBox(:type=>'okcancel', :message=>' Realy? ') == 'ok' > printf "Bye ...\n" > exit > else > #ignore > end > } > > while (text.exist? rescue false) > if (i += 1) % n == 0 > text.value = <<EOS > This is GUI #{(i / n)} > Time is #{Time.now.strftime("%Y-%m-%d %I:%M:%S")} > EOS > printf "This is command line #{i / n}\n" > end > end I had a little trouble when I tried to run your code. I kept getting a segment fault at the point the code called the exit method. Maybe it's because I'm still running Ruby 1.8.2 on Mac OS X, and it wouldn't happen I had a new version of Ruby. However, I did get it to run by moving the exit call to come after the Tk.mainloop message and adding a Tk.root.destroy message to block given to the protocol method. <code> require 'tk' tk_event_thread = Thread.new do Tk.mainloop puts "Bye..." exit end progress_msg = TkText.new(Tk.root).pack Tk.root.protocol(:WM_DELETE_WINDOW) { if Tk.messageBox(:type=>'okcancel', :message=>'Really?') == 'ok' Tk.root.destroy end } i = 0 loop do i += 1 progress_msg.value = <<TEXT This is GUI output #{i} Time is #{Time.now.strftime("%Y-%m-%d %I:%M:%S")} TEXT puts "This is command line output #{i}" sleep(1) end </code> But thanks very much for posting your code. I learned several important new things about Ruby/Tk from it. Regards, Morton