TkCore (Module)

In: tk/lib/tk.rb
tk/lib/multi-tk.rb

start Tk which depends on MultiTkIp

Constants

INTERP = TclTkIp.new(name, opts)
WIDGET_DESTROY_HOOK = '<WIDGET_DESTROY_HOOK>'
EventFlag = TclTkLib::EventFlag
INTERP = MultiTkIp

Classes and Modules

Module TkCore::INTERP
Class TkCore::Tk_OBJECT_TABLE

Included Modules

TkComm

Public Class methods

[Source]

# File tk/lib/tk.rb, line 992
  def TkCore.callback(*arg)
    begin
      TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
    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

[Source]

# File tk/lib/tk.rb, line 849
        def initialize(ip, cmd)
          @ip = ip
          @cmd = cmd
        end

Public Instance methods

[Source]

# File tk/lib/tk.rb, line 1055
  def after(ms, cmd=Proc.new)
    myid = _curr_cmd_id
    cmdid = install_cmd(cmd)
    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

[Source]

# File tk/lib/tk.rb, line 1073
  def after_idle(cmd=Proc.new)
    myid = _curr_cmd_id
    cmdid = install_cmd(cmd)
    tk_call_without_enc('after','idle',cmdid)
  end

[Source]

# File tk/lib/tk.rb, line 1098
  def appname(name=None)
    tk_call('tk', 'appname', name)
  end

[Source]

# File tk/lib/tk.rb, line 1102
  def appsend(interp, async, *args)
    if async
      tk_call('send', '-async', '--', interp, *args)
    else
      tk_call('send', '--', interp, *args)
    end
  end

[Source]

# File tk/lib/tk.rb, line 1117
  def appsend_displayof(interp, win, async, *args)
    win = '.' if win == nil
    if async
      tk_call('send', '-async', '-displayof', win, '--', interp, *args)
    else
      tk_call('send', '-displayor', win, '--', interp, *args)
    end
  end

[Source]

# File tk/lib/tk.rb, line 854
        def call(*args)
          @ip.cb_eval(@cmd, *args)
        end

[Source]

# File tk/lib/tk.rb, line 984
  def callback_break
    fail TkCallbackBreak, "Tk callback returns 'break' status"
  end

[Source]

# File tk/lib/tk.rb, line 988
  def callback_continue
    fail TkCallbackContinue, "Tk callback returns 'continue' status"
  end

[Source]

# File tk/lib/tk.rb, line 1212
  def chooseColor(keys = nil)
    tk_call('tk_chooseColor', *hash_kv(keys))
  end

[Source]

# File tk/lib/tk.rb, line 1216
  def chooseDirectory(keys = nil)
    tk_call('tk_chooseDirectory', *hash_kv(keys))
  end

[Source]

# File tk/lib/tk.rb, line 1146
  def do_one_event(flag = TclTkLib::EventFlag::ALL)
    TclTkLib.do_one_event(flag)
  end

[Source]

# File tk/lib/tk.rb, line 1187
  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

[Source]

# File tk/lib/tk.rb, line 1204
  def getOpenFile(keys = nil)
    tk_call('tk_getOpenFile', *hash_kv(keys))
  end

[Source]

# File tk/lib/tk.rb, line 1208
  def getSaveFile(keys = nil)
    tk_call('tk_getSaveFile', *hash_kv(keys))
  end

[Source]

# File tk/lib/tk.rb, line 1154
  def get_eventloop_tick()
    TclTkLib.get_eventloop_tick
  end

[Source]

# File tk/lib/tk.rb, line 1170
  def get_eventloop_weight()
    TclTkLib.get_eventloop_weight
  end

[Source]

# File tk/lib/tk.rb, line 1162
  def get_no_event_wait()
    TclTkLib.get_no_eventloop_wait
  end

[Source]

# File tk/lib/tk.rb, line 1133
  def info(*args)
    tk_call('info', *args)
  end

[Source]

# File tk/lib/tk.rb, line 857
        def inspect
          sprintf("#<cb_entry:%0x>", self.__id__)
        end

[Source]

# File tk/lib/tk.rb, line 1236
  def ip_eval(cmd_string)
    _ip_eval_core(nil, cmd_string)
  end

[Source]

# File tk/lib/tk.rb, line 1244
  def ip_eval_with_enc(cmd_string)
    _ip_eval_core(true, cmd_string)
  end

[Source]

# File tk/lib/tk.rb, line 1240
  def ip_eval_without_enc(cmd_string)
    _ip_eval_core(false, cmd_string)
  end

[Source]

# File tk/lib/tk.rb, line 1264
  def ip_invoke(*args)
    _ip_invoke_core(nil, *args)
  end

[Source]

# File tk/lib/tk.rb, line 1272
  def ip_invoke_with_enc(*args)
    _ip_invoke_core(true, *args)
  end

[Source]

# File tk/lib/tk.rb, line 1268
  def ip_invoke_without_enc(*args)
    _ip_invoke_core(false, *args)
  end

[Source]

# File tk/lib/tk.rb, line 1051
  def load_cmd_on_ip(tk_cmd)
    bool(tk_call('auto_load', tk_cmd))
  end

[Source]

# File tk/lib/tk.rb, line 1137
  def mainloop(check_root = true)
    TclTkLib.mainloop(check_root)
  end

[Source]

# File tk/lib/tk.rb, line 1141
  def mainloop_watchdog(check_root = true)
    # watchdog restarts mainloop when mainloop is dead

    TclTkLib.mainloop_watchdog(check_root)
  end

[Source]

# File tk/lib/tk.rb, line 1200
  def messageBox(keys)
    tk_call('tk_messageBox', *hash_kv(keys))
  end

[Source]

# File tk/lib/tk.rb, line 1110
  def rb_appsend(interp, async, *args)
    #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)
  end

[Source]

# File tk/lib/tk.rb, line 1126
  def rb_appsend_displayof(interp, win, async, *args)
    #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)
  end

[Source]

# File tk/lib/tk.rb, line 1174
  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

[Source]

# File tk/lib/tk.rb, line 1083
  def scaling(scale=nil)
    if scale
      tk_call_without_enc('tk', 'scaling', scale)
    else
      Float(number(tk_call_without_enc('tk', 'scaling')))
    end
  end

[Source]

# File tk/lib/tk.rb, line 1090
  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

[Source]

# File tk/lib/tk.rb, line 1150
  def set_eventloop_tick(timer_tick)
    TclTkLib.set_eventloop_tick(timer_tick)
  end

[Source]

# File tk/lib/tk.rb, line 1166
  def set_eventloop_weight(loop_max, no_event_tick)
    TclTkLib.set_eventloop_weight(loop_max, no_event_tick)
  end

[Source]

# File tk/lib/tk.rb, line 1158
  def set_no_event_wait(wait)
    TclTkLib.set_no_even_wait(wait)
  end

[Source]

# File tk/lib/tk.rb, line 1310
  def tk_call(*args)
    _tk_call_core(nil, *args)
  end

[Source]

# File tk/lib/tk.rb, line 1318
  def tk_call_with_enc(*args)
    _tk_call_core(true, *args)
  end

[Source]

# File tk/lib/tk.rb, line 1314
  def tk_call_without_enc(*args)
    _tk_call_core(false, *args)
  end
to_s()

Alias for inspect

[Source]

# File tk/lib/tk.rb, line 1079
  def windowingsystem
    tk_call_without_enc('tk', 'windowingsystem')
  end

[Validate]