From: Patrick Lynch Date: 2011-05-03T22:52:45+09:00 Subject: Re: Tk : non blocking Tk.mainloop Good morning, You're doing better than me... I'm working with an iMac Snow Leopard...and Ruby 1.8.7... I have TK installed and can access it from the Bash command line - but it is not known to my Ruby, eg, require 'Tk' returns and error message in irb... I probably should have started a separate link...but I thought I stand a good chance of getting some help here... Thank you ----- Original Message ----- From: "Hidetoshi NAGAI" To: "ruby-talk ML" ; Sent: Monday, May 02, 2011 10:21 PM Subject: Re: Tk : non blocking Tk.mainloop > Thank you for your reply. > > From: Juju SL > Subject: Re: Tk : non blocking Tk.mainloop > Date: Tue, 3 May 2011 05:46:55 +0900 > Message-ID: >> So, I patched manually the tk.rb file : > > You don't need manual patch. Please use "patch" command. > > # Or, packaged version of tk.rb is not a normal one of ruby192p0? > # If so, please tell me the version of your package. > >> Unfortunately, my small scripts ends with an exception : > > Hmmm... Maybe, I misunderstood the reason of the trouble. > The exception is not important. > It is a normal situation when a Tcl/Tk interpreter is deleted at exit. > > I want to know when and how Tk.mainloop exits. > Could you send me a *FULL* debug log with tk.rb (patched by previous > (ruby-talk:382536) patch) patched by the following? > > --- tk.rb~ 2011-05-02 18:16:29.000000000 +0900 > +++ tk.rb 2011-05-03 11:18:17.000000000 +0900 > @@ -1852,32 +1852,56 @@ > TclTkLib.mainloop(check_root) > > else ### Ruby 1.9 !!!!! > +p :log001 > unless TkCore::INTERP.default_master? > +p :log002 > # [MultiTkIp] slave interp ? > return TkCore::INTERP._thread_tkwait('window', '.') if check_root > end > +p :log003 > > # like as 1.8, withdraw a root widget before calling Tk.mainloop > TkCore::INTERP._eval_without_enc('catch {unset > __initial_state_of_rubytk__}') > +p :log004 > INTERP_THREAD.run > +p :log005 > > begin > TclTkLib.set_eventloop_window_mode(true) > +p :log006 > if check_root > +p :log007 > INTERP_MUTEX.synchronize{ > +p :log008 > INTERP_ROOT_CHECK.wait(INTERP_MUTEX) > +p :log009 > status = INTERP_THREAD_STATUS.value > +p [:log010, status] > if status && TkCore::INTERP.default_master? > INTERP_THREAD_STATUS.value = nil if $SAFE < 4 > +p :log011 > raise status if status.kind_of?(Exception) > end > +p :log012 > } > else > - INTERP_THREAD.value > +p :log013 > + # INTERP_THREAD.value > + begin > + INTERP_THREAD.value > + rescue Exception => e > +p [:log014, e] > + raise e > + end > end > + rescue Exception => e > +p [:log015, e] > + raise e > ensure > +p :log016 > TclTkLib.set_eventloop_window_mode(false) > end > +p :log017 > end > end > > > > -- > Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) > Department of Artificial Intelligence, Kyushu Institute of Technology > >