| Module | TkCore |
| In: |
tk/lib/tk.rb
tk/lib/multi-tk.rb |
| INTERP | = | TclTkIp.new(name, opts) |
| WIDGET_DESTROY_HOOK | = | '<WIDGET_DESTROY_HOOK>' |
| EventFlag | = | TclTkLib::EventFlag |
| INTERP | = | MultiTkIp |
# File tk/lib/tk.rb, line 1131 def TkCore.callback(*arg) begin TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) rescue SystemExit exit(0) rescue Interrupt exit!(1) rescue Exception => e begin msg = _toUTF8(e.class.inspect) + ': ' + _toUTF8(e.message) + "\n" + "\n---< backtrace of Ruby side >-----\n" + _toUTF8(e.backtrace.join("\n")) + "\n---< backtrace of Tk side >-------" msg.instance_variable_set(:@encoding, 'utf-8') rescue Exception msg = e.class.inspect + ': ' + e.message + "\n" + "\n---< backtrace of Ruby side >-----\n" + e.backtrace.join("\n") + "\n---< backtrace of Tk side >-------" end fail(e, msg) end end
# File tk/lib/tk.rb, line 1198 def after(ms, cmd=Proc.new) crit_bup = Thread.critical Thread.critical = true myid = _curr_cmd_id cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(myid); ret}) Thread.critical = crit_bup tk_call_without_enc("after",ms,cmdid) # return id # return # if false #defined? Thread # Thread.start do # ms = Float(ms)/1000 # ms = 10 if ms == 0 # sleep ms/1000 # cmd.call # end # else # cmdid = install_cmd(cmd) # tk_call("after",ms,cmdid) # end end
# File tk/lib/tk.rb, line 1222 def after_idle(cmd=Proc.new) crit_bup = Thread.critical Thread.critical = true myid = _curr_cmd_id cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(myid); ret}) Thread.critical = crit_bup tk_call_without_enc('after','idle',cmdid) end
# File tk/lib/tk.rb, line 1261 def appsend(interp, async, *args) if $SAFE >= 4 fail SecurityError, "cannot send Tk commands at level 4" elsif $SAFE >= 1 && args.find{|obj| obj.tainted?} fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}" end if async != true && async != false && async != nil args.unshift(async) async = false end if async tk_call('send', '-async', '--', interp, *args) else tk_call('send', '--', interp, *args) end end
# File tk/lib/tk.rb, line 1296 def appsend_displayof(interp, win, async, *args) if $SAFE >= 4 fail SecurityError, "cannot send Tk commands at level 4" elsif $SAFE >= 1 && args.find{|obj| obj.tainted?} fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}" end win = '.' if win == nil if async != true && async != false && async != nil args.unshift(async) async = false end if async tk_call('send', '-async', '-displayof', win, '--', interp, *args) else tk_call('send', '-displayor', win, '--', interp, *args) end end
# File tk/lib/tk.rb, line 1123 def callback_break fail TkCallbackBreak, "Tk callback returns 'break' status" end
# File tk/lib/tk.rb, line 1127 def callback_continue fail TkCallbackContinue, "Tk callback returns 'continue' status" end
# File tk/lib/tk.rb, line 1412 def chooseColor(keys = nil) tk_call('tk_chooseColor', *hash_kv(keys)) end
# File tk/lib/tk.rb, line 1416 def chooseDirectory(keys = nil) tk_call('tk_chooseDirectory', *hash_kv(keys)) end
# File tk/lib/tk.rb, line 1346 def do_one_event(flag = TclTkLib::EventFlag::ALL) TclTkLib.do_one_event(flag) end
# File tk/lib/tk.rb, line 1387 def event_generate(window, context, keys=nil) #window = window.path if window.kind_of?(TkObject) if keys tk_call_without_enc('event', 'generate', window, "<#{tk_event_sequence(context)}>", *hash_kv(keys, true)) else tk_call_without_enc('event', 'generate', window, "<#{tk_event_sequence(context)}>") end nil end
# File tk/lib/tk.rb, line 1404 def getOpenFile(keys = nil) tk_call('tk_getOpenFile', *hash_kv(keys)) end
# File tk/lib/tk.rb, line 1408 def getSaveFile(keys = nil) tk_call('tk_getSaveFile', *hash_kv(keys)) end
# File tk/lib/tk.rb, line 1440 def ip_eval_without_enc(cmd_string) _ip_eval_core(false, cmd_string) end
# File tk/lib/tk.rb, line 1341 def mainloop_watchdog(check_root = true) # watchdog restarts mainloop when mainloop is dead TclTkLib.mainloop_watchdog(check_root) end
# File tk/lib/tk.rb, line 1278 def rb_appsend(interp, async, *args) if $SAFE >= 4 fail SecurityError, "cannot send Ruby commands at level 4" elsif $SAFE >= 1 && args.find{|obj| obj.tainted?} fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}" end if async != true && async != false && async != nil args.unshift(async) async = false end #args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')} args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"\\]/, '\\\\\&')} # args.push(').to_s"') # appsend(interp, async, 'ruby "(', *args) args.push('}.call)"') appsend(interp, async, 'ruby "TkComm._get_eval_string(proc{', *args) end
# File tk/lib/tk.rb, line 1314 def rb_appsend_displayof(interp, win, async, *args) if $SAFE >= 4 fail SecurityError, "cannot send Ruby commands at level 4" elsif $SAFE >= 1 && args.find{|obj| obj.tainted?} fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}" end win = '.' if win == nil if async != true && async != false && async != nil args.unshift(async) async = false end #args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')} args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"\\]/, '\\\\\&')} # args.push(').to_s"') # appsend_displayof(interp, win, async, 'ruby "(', *args) args.push('}.call)"') appsend(interp, win, async, 'ruby "TkComm._get_eval_string(proc{', *args) end
# File tk/lib/tk.rb, line 1374 def restart(app_name = nil, keys = {}) TkCore::INTERP.init_ip_internal tk_call('set', 'argv0', app_name) if app_name if keys.kind_of?(Hash) # tk_call('set', 'argc', keys.size * 2) tk_call('set', 'argv', hash_kv(keys).join(' ')) end INTERP.restart nil end
# File tk/lib/tk.rb, line 1238 def scaling(scale=nil) if scale tk_call_without_enc('tk', 'scaling', scale) else Float(number(tk_call_without_enc('tk', 'scaling'))) end end
# File tk/lib/tk.rb, line 1245 def scaling_displayof(win, scale=nil) if scale tk_call_without_enc('tk', 'scaling', '-displayof', win, scale) else Float(number(tk_call_without_enc('tk', '-displayof', win, 'scaling'))) end end
# File tk/lib/tk.rb, line 1350 def set_eventloop_tick(timer_tick) TclTkLib.set_eventloop_tick(timer_tick) end
# File tk/lib/tk.rb, line 1366 def set_eventloop_weight(loop_max, no_event_tick) TclTkLib.set_eventloop_weight(loop_max, no_event_tick) end