From: nagai@... Date: 2002-03-27T17:57:24+09:00 Subject: Re: Error calling Tk in a loop Hi, From: Subject: Error calling Tk in a loop Date: Wed, 27 Mar 2002 03:46:02 +0900 Message-ID: james> class AlertBox james> def initialize( caption, box_text ) james> root = TkRoot.new { title caption } james> TkLabel.new(root) { james> text box_text james> pack { padx 25 ; pady 25; side 'left' } james> } james> Tk.mainloop james> end james> end The problem is that Tk.mainloop doesn't return while the root widget alives. Therefore, this initialize method does not finish till the root widget is destroyed. If the root widget is destroyed, Tk extension is finished and cannot generate new widgets. Well, Ruby/Tk on Ruby 1.6.7 has Tk.restart method. I don't recommend, but it can restart Tk extension and generate new root widget on same Tcl/Tk interpreter. If your purpose is only to generate AlertBox windows, you should use one TkToplevel widget for one AlertBox window. -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)