Support for the Ruby 2.3 series has ended. See here for reference.

In Files

  • tk/lib/tcltk.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

TclTkWidget

class TclTkWidget: tcl/tk widget

Public Class Methods

new(*args) click to toggle source

initialize(*args):

*args: parameters
 
               # File tk/lib/tcltk.rb, line 260
  def initialize(*args)
    if args[0].kind_of?(TclTkIp)
      # in case the 1st argument is TclTkIp:

      # Wrap tcl/tk widget by TclTkWidget
      # (used in TclTkInterpreter#initialize())

      # need two arguments
      fail("invalid # of parameter") if args.size != 2

      # ip: interpreter(TclTkIp)
      # exp: tcl/tk representation
      ip, exp = args

      # initialize TclTkObject
      super(ip, exp)
    elsif args[0].kind_of?(TclTkInterpreter)
      # in case 1st parameter is TclTkInterpreter:

      # generate new widget from parent widget

      # interp: interpreter(TclTkInterpreter)
      # parent: parent widget
      # command: widget generating tk command(label 等)
      # *args: argument to the command
      interp, parent, command, *args = args

      # generate widget name
      exp = parent.to_s()
      exp += "." if exp !~ /[.]$/
      exp += TclTk._newname("w_")
      # initialize TclTkObject
      super(interp._tcltkip(), exp)
      # generate widget
      res = @ip._eval_args(command, exp, *args)
#      fail("can't create Widget") if res != exp
      # for tk_optionMenu, it is legal res != exp
    else
      fail("first parameter is not TclTkInterpreter")
    end
  end