Module | TkCore
In: | tk/lib/tk.rb tk/lib/multi-tk.rb

start Tk which depends on MultiTkIp

### Methods

_tk_call_to_list_core after after_cancel after_idle appname appsend appsend_deny appsend_displayof call callback callback_break callback_continue chooseColor chooseDirectory do_one_event event_generate getMultipleOpenFile getMultipleSaveFile getOpenFile getSaveFile get_eventloop_tick get_eventloop_weight get_no_event_wait inactive inactive_displayof info inspect ip_eval ip_eval_with_enc ip_eval_without_enc ip_invoke ip_invoke_with_enc ip_invoke_without_enc is_mainloop? load_cmd_on_ip mainloop mainloop_exist? mainloop_thread? mainloop_watchdog messageBox new rb_appsend rb_appsend_displayof reset_inactive reset_inactive_displayof restart scaling scaling_displayof set_eventloop_tick set_eventloop_weight set_no_event_wait tk_call tk_call_to_list tk_call_to_list_with_enc tk_call_to_list_without_enc tk_call_to_simplelist tk_call_to_simplelist_with_enc tk_call_to_simplelist_without_enc tk_call_with_enc tk_call_without_enc to_s windowingsystem

### Included Modules

TkComm

### Classes and Modules

Module TkCore::INTERP
Class TkCore::Tk_OBJECT_TABLE

### Constants

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

### Public Class methods

callback(*arg)

[Source]

    # File tk/lib/tk.rb, line 1243
      def TkCore.callback(*arg)
        begin
          if TkCore::INTERP.tk_cmd_tbl.kind_of?(Hash)
            #TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
            normal_ret = false
            ret = catch(:IRB_EXIT) do  # IRB hack
              retval = TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
              normal_ret = true
              retval
            end
            unless normal_ret
              # catch IRB_EXIT
              exit(ret)
            end
            ret
          end
        rescue SystemExit=>e
          exit(e.status)
        rescue Interrupt=>e
          fail(e)
        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
          # TkCore::INTERP._set_global_var('errorInfo', msg)
          # fail(e)
          fail(e, msg)
        end
      end

new(ip, cmd)

[Source]

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

### Public Instance methods

_tk_call_to_list_core(depth, arg_enc, val_enc, *args)

[Source]

    # File tk/lib/tk.rb, line 1690
      def _tk_call_to_list_core(depth, arg_enc, val_enc, *args)
        args = _conv_args([], arg_enc, *args)
        val = _tk_call_core(false, *args)
        if !depth.kind_of?(Integer) || depth == 0
          tk_split_simplelist(val, false, val_enc)
        else
          tk_split_list(val, depth, false, val_enc)
        end
      end

after(ms, cmd=Proc.new)

[Source]

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

after_cancel(afterId)

[Source]

    # File tk/lib/tk.rb, line 1361
      def after_cancel(afterId)
        tk_call_without_enc('after','cancel',afterId)
      end

after_idle(cmd=Proc.new)

[Source]

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

appname(name=None)

[Source]

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

appsend(interp, async, *args)

[Source]

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

appsend_deny()

[Source]

    # File tk/lib/tk.rb, line 1401
      def appsend_deny
        tk_call('rename', 'send', '')
      end

appsend_displayof(interp, win, async, *args)

[Source]

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

call(*args)

[Source]

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

callback_break()

[Source]

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

callback_continue()

[Source]

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

chooseColor(keys = nil)

[Source]

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

chooseDirectory(keys = nil)

[Source]

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

do_one_event(flag = TclTkLib::EventFlag::ALL)

[Source]

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

event_generate(win, context, keys=nil)

[Source]

    # File tk/lib/tk.rb, line 1547
      def event_generate(win, context, keys=nil)
        #win = win.path if win.kind_of?(TkObject)
        if context.kind_of?(TkEvent::Event)
          context.generate(win, ((keys)? keys: {}))
        elsif keys
          tk_call_without_enc('event', 'generate', win,
                              "<#{tk_event_sequence(context)}>",
                              *hash_kv(keys, true))
        else
          tk_call_without_enc('event', 'generate', win,
                              "<#{tk_event_sequence(context)}>")
        end
        nil
      end

getMultipleOpenFile(keys = nil)

[Source]

    # File tk/lib/tk.rb, line 1569
      def getMultipleOpenFile(keys = nil)
        simplelist(tk_call('tk_getOpenFile', '-multiple', '1', *hash_kv(keys)))
      end

getMultipleSaveFile(keys = nil)

[Source]

    # File tk/lib/tk.rb, line 1576
      def getMultipleSaveFile(keys = nil)
        simplelist(tk_call('tk_getSaveFile', '-multiple', '1', *hash_kv(keys)))
      end

getOpenFile(keys = nil)

[Source]

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

getSaveFile(keys = nil)

[Source]

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

get_eventloop_tick()

[Source]

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

get_eventloop_weight()

[Source]

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

get_no_event_wait()

[Source]

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

inactive()

[Source]

    # File tk/lib/tk.rb, line 1384
      def inactive
        Integer(tk_call_without_enc('tk', 'inactive'))
      end

inactive_displayof(win)

[Source]

    # File tk/lib/tk.rb, line 1387
      def inactive_displayof(win)
        Integer(tk_call_without_enc('tk', 'inactive', '-displayof', win))
      end

info(*args)

[Source]

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

inspect()

[Source]

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

ip_eval(cmd_string)

[Source]

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

ip_eval_with_enc(cmd_string)

[Source]

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

ip_eval_without_enc(cmd_string)

[Source]

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

ip_invoke(*args)

[Source]

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

ip_invoke_with_enc(*args)

[Source]

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

ip_invoke_without_enc(*args)

[Source]

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

is_mainloop?()

[Source]

    # File tk/lib/tk.rb, line 1497
      def is_mainloop?
        TclTkLib.mainloop_thread? == true
      end

load_cmd_on_ip(tk_cmd)

[Source]

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

mainloop(check_root = true)

[Source]

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

mainloop_exist?()

[Source]

    # File tk/lib/tk.rb, line 1493
      def mainloop_exist?
        TclTkLib.mainloop_thread? != nil
      end

mainloop_thread?()

[Source]

    # File tk/lib/tk.rb, line 1485
      def mainloop_thread?
        # true  : current thread is mainloop
        # nil   : there is no mainloop
        # false : mainloop is running on the other thread
        #         ( At then, it is dangerous to call Tk interpreter directly. )
        TclTkLib.mainloop_thread?
      end

mainloop_watchdog(check_root = true)

[Source]

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

messageBox(keys)

[Source]

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

rb_appsend(interp, async, *args)

[Source]

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

rb_appsend_displayof(interp, win, async, *args)

[Source]

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

reset_inactive()

[Source]

    # File tk/lib/tk.rb, line 1390
      def reset_inactive
        tk_call_without_enc('tk', 'inactive', 'reset')
      end

reset_inactive_displayof(win)

[Source]

    # File tk/lib/tk.rb, line 1393
      def reset_inactive_displayof(win)
        tk_call_without_enc('tk', 'inactive', '-displayof', win, 'reset')
      end

restart(app_name = nil, keys = {})

[Source]

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

scaling(scale=nil)

[Source]

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

scaling_displayof(win, scale=nil)

[Source]

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

set_eventloop_tick(timer_tick)

[Source]

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

set_eventloop_weight(loop_max, no_event_tick)

[Source]

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

set_no_event_wait(wait)

[Source]

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

tk_call(*args)

[Source]

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

tk_call_to_list(*args)

private :_tk_call_to_list_core

[Source]

    # File tk/lib/tk.rb, line 1701
      def tk_call_to_list(*args)
        _tk_call_to_list_core(-1, nil, true, *args)
      end

tk_call_to_list_with_enc(*args)

[Source]

    # File tk/lib/tk.rb, line 1709
      def tk_call_to_list_with_enc(*args)
        _tk_call_to_list_core(-1, true, true, *args)
      end

tk_call_to_list_without_enc(*args)

[Source]

    # File tk/lib/tk.rb, line 1705
      def tk_call_to_list_without_enc(*args)
        _tk_call_to_list_core(-1, false, false, *args)
      end

tk_call_to_simplelist(*args)

[Source]

    # File tk/lib/tk.rb, line 1713
      def tk_call_to_simplelist(*args)
        _tk_call_to_list_core(0, nil, true, *args)
      end

tk_call_to_simplelist_with_enc(*args)

[Source]

    # File tk/lib/tk.rb, line 1721
      def tk_call_to_simplelist_with_enc(*args)
        _tk_call_to_list_core(0, true, true, *args)
      end

tk_call_to_simplelist_without_enc(*args)

[Source]

    # File tk/lib/tk.rb, line 1717
      def tk_call_to_simplelist_without_enc(*args)
        _tk_call_to_list_core(0, false, false, *args)
      end

tk_call_with_enc(*args)

[Source]

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

tk_call_without_enc(*args)

[Source]

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

to_s()

Alias for inspect

windowingsystem()

[Source]

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

[Validate]