In Files

  • tk/lib/tcltk.rb



Class/Module Index [+]



class TclTkWidget: tcl/tk widget

Public Class Methods

new(*args) click to toggle source


*args: parameters
               # File tk/lib/tcltk.rb, line 261
  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
      fail("first parameter is not TclTkInterpreter")

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit