Python 使用 Tkinter tcl.eval 将多个参数传递给 tcl proc [英] Python pass more than one arguments to tcl proc using Tkinter tcl.eval

查看:51
本文介绍了Python 使用 Tkinter tcl.eval 将多个参数传递给 tcl proc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 Tkinter 将多个参数传递给 tcl proc.我想将 3 个参数从 python proc validate_op 传递给 tcl proc tableParser,它有 3 个参数...

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 Tcl
import os

tcl = Tcl()

def validate_op(fetch, header, value):
    tcl.eval('source tcl_proc.tcl') 
    tcl.eval('set op [tableParser $fetch $header $value]') <<<<< not working



proc tableParser { result_col args} {

  ..
..
..

}

推荐答案

最简单的处理方法是使用 Tkinter 模块中的 _stringify 函数.

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:

这篇关于Python 使用 Tkinter tcl.eval 将多个参数传递给 tcl proc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆