Python Pass More Than One Arguments To Tcl Proc Using Tkinter Tcl.eval
how to pass more than one arguments to tcl proc using Tkinter. i want to pass 3 args to tcl proc tableParser from python proc validate_op which has 3 args... from Tkinter import Tc
Solution 1:
The simplest way to handle this is to use the _stringify
function in the Tkinter module.
def validate_op(fetch, header, value):
tcl.eval('source tcl_proc.tcl')
f = tkinter._stringify(fetch)
h = tkinter._stringify(header)
v = tkinter._stringify(value)
tcl.eval('set op [tableParser %(f)s %(h)s %(v)s]' % locals())
These two questions, while not answering your question, were useful in answering it:
Solution 2:
If you do not insist on eval, you can also do it like this:
defvalidate_op(fetch, header, value):
tcl.eval('source tcl_proc.tcl')
# create a Tcl string variable op to hold the result
op = tkinter.StringVar(name='op')
# call the Tcl code and store the result in the string var
op.set(tcl.call('tableParser', fetch, header, value))
If your tableParser
returns a handle to some expensive to serialize object, this is probably not a good idea, as it involves a conversion to string, which is avoided in the eval case. But if you just need to get a string back, this is just fine and you do not need to deal with the _stringify
function mentioned in Donals answer.
Post a Comment for "Python Pass More Than One Arguments To Tcl Proc Using Tkinter Tcl.eval"