如何使用 Python 调用 TCL 过程 [英] How to Call TCL Procedure using Python

查看:24
本文介绍了如何使用 Python 调用 TCL 过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用下面的代码,我可以调用 Proc.tcl 文件中的所有过程,但我想单独调用 sum 或 sub 等过程,请告诉我任何其他调用它的可能性

Using below code i can able to call all procedure in the Proc.tcl file ,but i want to call individually the procs like sum or sub ,Please let me know any other possibility to call it

我的 proc 文件程序,

My proc file program,

 puts "hello"
    proc sum {a b} {

     set c [expr $a + $b]
     puts "Addition: $c "
    }




  proc sub {a b} {

     set c [expr $a - $b]
     puts "Substraction: $c "
    }

我的主文件程序,

 import Tkinter
    import os
    r=Tkinter.Tk()
    r.tk.eval('source proc.tcl')

推荐答案

代替 r.tk.eval('source proc.tcl')

instead of r.tk.eval('source proc.tcl')

尝试使用 os.system ('source proc.tcl')并导入操作系统

try with os.system ('source proc.tcl') and import OS

这篇关于如何使用 Python 调用 TCL 过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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