Embedding TCL in Python?

Carey Evans careye at spamcop.net
Mon Dec 24 00:58:33 EST 2001


Roy Smith <roy at panix.com> writes:

[...]

> Second, I could start a separate TCL interpreter process, and have my 
> Python program drive it with some sort of send/expect type interface.  
> Possible, but ugly, and probably a real mess to code.

I don't know if it would be *that* much of a mess.  You could write a
couple of classes to hide the implementation details and keep the main
code fairly straightforward.

> Lastly, I could just embed a TCL interpreter right in my Python process.  
> This seems like it has promise, but I don't have much of a clue how to go 
> about doing it.  Has anybody done anything like that before?

This is pretty much what Tkinter does, and you might be able to use it
to access your Tcl code without much development work, though I doubt
that this is supported:

>>> import Tkinter
>>> tk = Tkinter.Tk()
>>> tk.tk.call('expr', '2 + 2')
'4'

In any case, you should be able to get some ideas from it.

There's also a project called Minotaur, although it doesn't seem to
have had anything happen to it recently.  See:

    http://www.equi4.com/minotaur/minotaur.html

-- 
	 Carey Evans  http://home.clear.net.nz/pages/c.evans/



More information about the Python-list mailing list