From: Juju SL Date: 2011-05-03T05:46:55+09:00 Subject: Re: Tk : non blocking Tk.mainloop So, I patched manually the tk.rb file : ===================================== # diff tk.rb.ORIG tk.rb 1238a1239,1241 > interp.mainloop_abort_on_exception = true > Thread.current.instance_variable_set("@interp", interp) > 1273a1277,1279 > # complete initializing > ruby {TkCore::INTERP_THREAD[:interp] = TkCore::INTERP_THREAD.instance_variable_get('@interp')} > 1280,1281c1286,1287 < interp.mainloop_abort_on_exception = true < Thread.current[:interp] = interp --- > # interp.mainloop_abort_on_exception = true > # Thread.current[:interp] = interp 1286a1293 > p e if $DEBUG 1302a1310 > # check a Tcl/Tk interpreter is initialized 1304c1312,1313 < Thread.pass --- > # Thread.pass > INTERP_THREAD.run 1308a1318,1322 > # check an eventloop is running > while INTERP_THREAD.alive? && TclTkLib.mainloop_thread?.nil? > INTERP_THREAD.run > end > 1318a1333,1336 > > # (for safety's sake) force the eventloop to run > INTERP_THREAD.run > ===================================== Unfortunately, my small scripts ends with an exception : ===================================== tcltklib: delete slaves tcltklib: destroy root widget tcltklib: check `finalize-hook-proc' tcltklib: check `foreach' & `after' tcltklib: cancel after callbacks tcltklib: finish ip_finalize Exception `TypeError' at /usr/lib/ruby/1.9.1/tk.rb:1288 - exception class/object expected tcltklib: eventloop_ensure: current-thread : 9e62658 tcltklib: eventloop_ensure: eventloop-thread : 9e62658 tcltklib: eventloop-ensure: new eventloop-thread -> 4 tcltklib: finish current eventloop 9e62658 tcltklib: ip is deleted tcltklib: ip is deleted tcltklib: ip is deleted tcltklib: delete deleted IP tcltklib: free Tcl Interp 9e7ae68 tcltklib: complete freeing Tcl Interp ===================================== Line 1288 is : Thread.current[:status].value = interp.mainloop(true) Best regards Stéphane -- Posted via http://www.ruby-forum.com/.