1998-01-16 07:19:09 -05:00
|
|
|
|
# tof
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
#### tcltk library, more direct manipulation of tcl/tk
|
1998-01-16 07:19:09 -05:00
|
|
|
|
#### Sep. 5, 1997 Y. Shigehiro
|
|
|
|
|
|
|
|
|
|
require "tcltklib"
|
|
|
|
|
|
|
|
|
|
################
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# module TclTk: collection of tcl/tk utilities (supplies namespace.)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
module TclTk
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize Hash to hold unique symbols and such
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@namecnt = {}
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize Hash to hold callbacks
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@callback = {}
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# TclTk.mainloop(): call TclTkLib.mainloop()
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def TclTk.mainloop()
|
|
|
|
|
print("mainloop: start\n") if $DEBUG
|
|
|
|
|
TclTkLib.mainloop()
|
|
|
|
|
print("mainloop: end\n") if $DEBUG
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# TclTk.deletecallbackkey(ca): remove callback from TclTk module
|
|
|
|
|
# this does not remove callbacks from tcl/tk interpreter
|
|
|
|
|
# without calling this method, TclTkInterpreter will not be GCed
|
|
|
|
|
# ca: callback(TclTkCallback)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def TclTk.deletecallbackkey(ca)
|
|
|
|
|
print("deletecallbackkey: ", ca.to_s(), "\n") if $DEBUG
|
|
|
|
|
@callback.delete(ca.to_s)
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# TclTk.dcb(ca, wid, W): call TclTk.deletecallbackkey() for each callbacks
|
|
|
|
|
# in an array.
|
|
|
|
|
# this is for callback for top-level <Destroy>
|
|
|
|
|
# ca: array of callbacks(TclTkCallback)
|
|
|
|
|
# wid: top-level widget(TclTkWidget)
|
|
|
|
|
# w: information about window given by %W(String)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def TclTk.dcb(ca, wid, w)
|
|
|
|
|
if wid.to_s() == w
|
|
|
|
|
ca.each{|i|
|
|
|
|
|
TclTk.deletecallbackkey(i)
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# TclTk._addcallback(ca): register callback
|
|
|
|
|
# ca: callback(TclTkCallback)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def TclTk._addcallback(ca)
|
|
|
|
|
print("_addcallback: ", ca.to_s(), "\n") if $DEBUG
|
|
|
|
|
@callback[ca.to_s()] = ca
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# TclTk._callcallback(key, arg): invoke registered callback
|
|
|
|
|
# key: key to select callback (to_s value of the TclTkCallback)
|
|
|
|
|
# arg: parameter from tcl/tk interpreter
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def TclTk._callcallback(key, arg)
|
|
|
|
|
print("_callcallback: ", @callback[key].inspect, "\n") if $DEBUG
|
|
|
|
|
@callback[key]._call(arg)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# throw out callback value
|
|
|
|
|
# should return String to satisfy rb_eval_string()
|
1998-01-16 07:19:09 -05:00
|
|
|
|
return ""
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# TclTk._newname(prefix): generate unique name(String)
|
|
|
|
|
# prefix: prefix of the unique name
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def TclTk._newname(prefix)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# generated name counter is stored in @namecnt
|
1998-01-16 07:19:09 -05:00
|
|
|
|
if !@namecnt.key?(prefix)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# first appearing prefix, initialize
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@namecnt[prefix] = 1
|
|
|
|
|
else
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# already appeared prefix, generate next name
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@namecnt[prefix] += 1
|
|
|
|
|
end
|
|
|
|
|
return "#{prefix}#{@namecnt[prefix]}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
################
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# class TclTkInterpreter: tcl/tk interpreter
|
1998-01-16 07:19:09 -05:00
|
|
|
|
class TclTkInterpreter
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize():
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def initialize()
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# generate interpreter object
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@ip = TclTkIp.new()
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# add ruby_fmt command to tcl interpreter
|
|
|
|
|
# ruby_fmt command format arguments by `format' and call `ruby' command
|
|
|
|
|
# (notice ruby command receives only one argument)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
if $DEBUG
|
|
|
|
|
@ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt $args\" ; ruby [format $fmt $args] }")
|
|
|
|
|
else
|
|
|
|
|
@ip._eval("proc ruby_fmt {fmt args} { ruby [format $fmt $args] }")
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# @ip._get_eval_string(*args): generate string to evaluate in tcl interpreter
|
|
|
|
|
# *args: script which is going to be evaluated under tcl/tk
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def @ip._get_eval_string(*args)
|
|
|
|
|
argstr = ""
|
|
|
|
|
args.each{|arg|
|
|
|
|
|
argstr += " " if argstr != ""
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# call to_eval if it is defined
|
1998-01-16 07:19:09 -05:00
|
|
|
|
if (arg.respond_to?(:to_eval))
|
|
|
|
|
argstr += arg.to_eval()
|
|
|
|
|
else
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# call to_s unless defined
|
1998-01-16 07:19:09 -05:00
|
|
|
|
argstr += arg.to_s()
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
return argstr
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# @ip._eval_args(*args): evaluate string under tcl/tk interpreter
|
|
|
|
|
# returns result string.
|
|
|
|
|
# *args: script which is going to be evaluated under tcl/tk
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def @ip._eval_args(*args)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# calculate the string to eval in the interpreter
|
1998-01-16 07:19:09 -05:00
|
|
|
|
argstr = _get_eval_string(*args)
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# evaluate under the interpreter
|
1998-01-16 07:19:09 -05:00
|
|
|
|
print("_eval: \"", argstr, "\"") if $DEBUG
|
|
|
|
|
res = _eval(argstr)
|
|
|
|
|
if $DEBUG
|
|
|
|
|
print(" -> \"", res, "\"\n")
|
|
|
|
|
elsif _return_value() != 0
|
|
|
|
|
print(res, "\n")
|
|
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
|
fail(%Q/can't eval "#{argstr}"/) if _return_value() != 0 #'
|
1998-01-16 07:19:09 -05:00
|
|
|
|
return res
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# generate tcl/tk command object and register in the hash
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@commands = {}
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# for all commands registered in tcl/tk interpreter:
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@ip._eval("info command").split(/ /).each{|comname|
|
|
|
|
|
if comname =~ /^[.]/
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# if command is a widget (path), generate TclTkWidget,
|
|
|
|
|
# and register it in the hash
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@commands[comname] = TclTkWidget.new(@ip, comname)
|
|
|
|
|
else
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# otherwise, generate TclTkCommand
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@commands[comname] = TclTkCommand.new(@ip, comname)
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# commands(): returns hash of the tcl/tk commands
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def commands()
|
|
|
|
|
return @commands
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# rootwidget(): returns root widget(TclTkWidget)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def rootwidget()
|
|
|
|
|
return @commands["."]
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# _tcltkip(): returns @ip(TclTkIp)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def _tcltkip()
|
|
|
|
|
return @ip
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# method_missing(id, *args): execute undefined method as tcl/tk command
|
|
|
|
|
# id: method symbol
|
|
|
|
|
# *args: method arguments
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def method_missing(id, *args)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# if command named by id registered, then execute it
|
1998-01-16 07:19:09 -05:00
|
|
|
|
if @commands.key?(id.id2name)
|
|
|
|
|
return @commands[id.id2name].e(*args)
|
|
|
|
|
else
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# otherwise, exception
|
1998-01-16 07:19:09 -05:00
|
|
|
|
super
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# class TclTkObject: base class of the tcl/tk objects
|
1998-01-16 07:19:09 -05:00
|
|
|
|
class TclTkObject
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize(ip, exp):
|
|
|
|
|
# ip: interpreter(TclTkIp)
|
|
|
|
|
# exp: tcl/tk representation
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def initialize(ip, exp)
|
|
|
|
|
fail("type is not TclTkIp") if !ip.kind_of?(TclTkIp)
|
|
|
|
|
@ip = ip
|
|
|
|
|
@exp = exp
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# to_s(): returns tcl/tk representation
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def to_s()
|
|
|
|
|
return @exp
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# class TclTkCommand: tcl/tk commands
|
|
|
|
|
# you should not call TclTkCommand.new()
|
|
|
|
|
# commands are created by TclTkInterpreter:initialize()
|
1998-01-16 07:19:09 -05:00
|
|
|
|
class TclTkCommand < TclTkObject
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# e(*args): execute command. returns String (e is for exec or eval)
|
|
|
|
|
# *args: command arguments
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def e(*args)
|
|
|
|
|
return @ip._eval_args(to_s(), *args)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# class TclTkLibCommand: tcl/tk commands in the library
|
1998-01-16 07:19:09 -05:00
|
|
|
|
class TclTkLibCommand < TclTkCommand
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize(ip, name):
|
|
|
|
|
# ip: interpreter(TclTkInterpreter)
|
|
|
|
|
# name: command name (String)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def initialize(ip, name)
|
|
|
|
|
super(ip._tcltkip, name)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# class TclTkVariable: tcl/tk variable
|
1998-01-16 07:19:09 -05:00
|
|
|
|
class TclTkVariable < TclTkObject
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize(interp, dat):
|
|
|
|
|
# interp: interpreter(TclTkInterpreter)
|
|
|
|
|
# dat: the value to set(String)
|
|
|
|
|
# if nil, not initialize variable
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def initialize(interp, dat)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# auto-generate tcl/tk representation (variable name)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
exp = TclTk._newname("v_")
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize TclTkObject
|
1998-01-16 07:19:09 -05:00
|
|
|
|
super(interp._tcltkip(), exp)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# safe this for `set' command
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@set = interp.commands()["set"]
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# set value
|
1998-01-16 07:19:09 -05:00
|
|
|
|
set(dat) if dat
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# although you can set/refer variable by using set in tcl/tk,
|
|
|
|
|
# we provide the method for accessing variables
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# set(data): set tcl/tk variable using `set'
|
|
|
|
|
# data: new value
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def set(data)
|
|
|
|
|
@set.e(to_s(), data.to_s())
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# get(): read tcl/tk variable(String) using `set'
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def get()
|
|
|
|
|
return @set.e(to_s())
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# class TclTkWidget: tcl/tk widget
|
1998-01-16 07:19:09 -05:00
|
|
|
|
class TclTkWidget < TclTkCommand
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize(*args):
|
|
|
|
|
# *args: parameters
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def initialize(*args)
|
|
|
|
|
if args[0].kind_of?(TclTkIp)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# in case the 1st argument is TclTkIp:
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# Wrap tcl/tk widget by TclTkWidget
|
|
|
|
|
# (used in TclTkInterpreter#initialize())
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# need two arguments
|
1998-01-16 07:19:09 -05:00
|
|
|
|
fail("illegal # of parameter") if args.size != 2
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# ip: interpreter(TclTkIp)
|
|
|
|
|
# exp: tcl/tk representation
|
1998-01-16 07:19:09 -05:00
|
|
|
|
ip, exp = args
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize TclTkObject
|
1998-01-16 07:19:09 -05:00
|
|
|
|
super(ip, exp)
|
|
|
|
|
elsif args[0].kind_of?(TclTkInterpreter)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# in case 1st parameter is TclTkInterpreter:
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# generate new widget from parent widget
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# interp: interpreter(TclTkInterpreter)
|
|
|
|
|
# parent: parent widget
|
|
|
|
|
# command: widget generating tk command(label <20><>)
|
|
|
|
|
# *args: argument to the command
|
1998-01-16 07:19:09 -05:00
|
|
|
|
interp, parent, command, *args = args
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# generate widget name
|
1998-01-16 07:19:09 -05:00
|
|
|
|
exp = parent.to_s()
|
|
|
|
|
exp += "." if exp !~ /[.]$/
|
|
|
|
|
exp += TclTk._newname("w_")
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize TclTkObject
|
1998-01-16 07:19:09 -05:00
|
|
|
|
super(interp._tcltkip(), exp)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# generate widget
|
1998-01-16 07:19:09 -05:00
|
|
|
|
res = @ip._eval_args(command, exp, *args)
|
|
|
|
|
# fail("can't create Widget") if res != exp
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# for tk_optionMenu, it is legal res != exp
|
1998-01-16 07:19:09 -05:00
|
|
|
|
else
|
|
|
|
|
fail("first parameter is not TclTkInterpreter")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# class TclTkCallback: tcl/tk callbacks
|
1998-01-16 07:19:09 -05:00
|
|
|
|
class TclTkCallback < TclTkObject
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize(interp, pr, arg):
|
|
|
|
|
# interp: interpreter(TclTkInterpreter)
|
|
|
|
|
# pr: callback procedure(Proc)
|
|
|
|
|
# arg: string to pass as block parameters of pr
|
|
|
|
|
# bind command of tcl/tk uses % replacement for parameters
|
|
|
|
|
# pr can receive replaced data using block parameter
|
|
|
|
|
# its format is specified by arg string
|
|
|
|
|
# You should not specify arg for the command like
|
|
|
|
|
# scrollbar with -command option, which receives parameters
|
|
|
|
|
# without specifying any replacement
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def initialize(interp, pr, arg = nil)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# auto-generate tcl/tk representation (variable name)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
exp = TclTk._newname("c_")
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize TclTkObject
|
1998-01-16 07:19:09 -05:00
|
|
|
|
super(interp._tcltkip(), exp)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# save parameters
|
1998-01-16 07:19:09 -05:00
|
|
|
|
@pr = pr
|
|
|
|
|
@arg = arg
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# register in the module
|
1998-01-16 07:19:09 -05:00
|
|
|
|
TclTk._addcallback(self)
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# to_eval(): retuens string representation for @ip._eval_args
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def to_eval()
|
|
|
|
|
if @arg
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# bind replaces %s before calling ruby_fmt, so %%s is used
|
1998-01-16 07:19:09 -05:00
|
|
|
|
s = %Q/{ruby_fmt {TclTk._callcallback("#{to_s()}", "%%s")} #{@arg}}/
|
|
|
|
|
else
|
|
|
|
|
s = %Q/{ruby_fmt {TclTk._callcallback("#{to_s()}", "%s")}}/
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# _call(arg): invoke callback
|
|
|
|
|
# arg: callback parameter
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def _call(arg)
|
|
|
|
|
@pr.call(arg)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# class TclTkImage: tcl/tk images
|
1998-01-16 07:19:09 -05:00
|
|
|
|
class TclTkImage < TclTkCommand
|
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize(interp, t, *args):
|
|
|
|
|
# generating image is done by TclTkImage.new()
|
|
|
|
|
# destrying is done by image delete (inconsistent, sigh)
|
|
|
|
|
# interp: interpreter(TclTkInterpreter)
|
|
|
|
|
# t: image type (photo, bitmap, etc.)
|
|
|
|
|
# *args: command argument
|
1998-01-16 07:19:09 -05:00
|
|
|
|
def initialize(interp, t, *args)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# auto-generate tcl/tk representation
|
1998-01-16 07:19:09 -05:00
|
|
|
|
exp = TclTk._newname("i_")
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# initialize TclTkObject
|
1998-01-16 07:19:09 -05:00
|
|
|
|
super(interp._tcltkip(), exp)
|
1999-01-19 23:59:39 -05:00
|
|
|
|
# generate image
|
1998-01-16 07:19:09 -05:00
|
|
|
|
res = @ip._eval_args("image create", t, exp, *args)
|
|
|
|
|
fail("can't create Image") if res != exp
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# eof
|