18

Here's the situation. The company I work for has quite a bit of existing Tcl code, but some of them want to start using python. It would nice to be able to reuse some of the existing Tcl code, because that's money already spent. Besides, some of the test equipment only has Tcl API's.

So, one of the ways I thought of was using the subprocess module to call into some Tcl scripts.

  • Is subprocess my best bet?
  • Has anyone used this fairly new piece of code: Plumage? If so what is your experience (not just for Tk)?
  • Any other possible ways that I have not considered?
4

3 回答 3

19

我希望你为此做好准备。标准 Python

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

在 Re 中编辑评论:Python 的 tcl 解释器不知道其他已安装的 tcl 组件。您可以通过以通常的方式向实际使用的 tcl python 添加扩展来处理这个问题。这是一个包含一些详细信息的链接

于 2009-06-17T00:10:03.320 回答
3

This can be done.

http://wiki.tcl.tk/13312

Specificly look at the typcl extension.

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).

于 2009-06-16T23:55:02.383 回答
0

I've not used it myself, but SWIG might help you out:

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

于 2009-06-16T23:50:04.237 回答