Embedding TCL in Python?

Cameron Laird claird at starbase.neosoft.com
Mon Dec 24 12:25:26 EST 2001


In article <87bsgp9n1y.fsf at psyche.dnsalias.org>,
Carey Evans  <careye at spamcop.net> wrote:
>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
			.
			.
			.
There are other variations, even.  However, use of
Tkinter.tk.eval("source myscript.tcl") should work
for you immediately.  Let us know if it doesn't.
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



More information about the Python-list mailing list