知道将Python与Tcl接口的任何创新方法吗?

2024-04-19 23:54:06 发布

您现在位置:Python中文网/ 问答频道 /正文

情况是这样的。我供职的公司有很多现有的Tcl代码,但其中一些希望开始使用python。能够重用一些现有的Tcl代码是很好的,因为这是已经花掉的钱。另外,有些测试设备只有Tcl的API

所以,我想到的方法之一是使用子流程模块调用一些Tcl脚本。

  • 子流程是我的最佳选择吗?
  • 有没有人用过这段相当新的代码:Plumage?如果是的话,你的经验是什么(不仅仅是Tk的经验)?
  • 还有其他我没有考虑过的方法吗?

Tags: 模块方法代码脚本api情况公司经验
3条回答

我希望你已经准备好了。标准Python

import Tkinter
tclsh = Tkinter.Tcl()
tclsh.eval("""
    proc unknown args {puts "Hello World!"}
    }"!dlroW olleH" stup{ sgra nwonknu corp
""")

在Re-to-comment中编辑:Python的tcl解释器不知道其他已安装的tcl组件。您可以通过向python实际使用的tcl中添加通常的扩展来解决这个问题。以下是一些细节的链接

这是可以做到的。

http://wiki.tcl.tk/13312

具体看typcl扩展。

Typcl is a bit weird... It's a an extension to use Tcl from Python. It doesn't really require CriTcl and could have been done in standard C.

This code demonstrates using Tcl as shared library, and hooking into it at run time (Tcl's stubs architecture makes this delightfully simple). Furthermore, Typcl avoids string conversions where possible (both ways).

我自己也没用过,不过斯威格可能会帮你:

http://www.swig.org/Doc1.1/HTML/Tcl.html

相关问题 更多 >