TclTkWidget (Class)

In: tcltklib/lib/tcltk.rb
Parent: TclTkCommand

class TclTkWidget: tcl/tk widget

Methods

new  

Public Class methods

initialize(*args):

  *args: parameters

[Source]

# File tcltklib/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("illegal # 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

[Validate]