calling python procedures from tcl using tclpython

chand chandra.bangalore at gmail.com
Thu Jul 7 09:39:44 EDT 2005


That is exactly i want to know. i.e...,how to provide the python code
path in tcl script file, that loads required function.

--BestRegards.,
--chandra

> definitions etc.

Michael Schlenker wrote:
> chand wrote:
> > Hi..
> >
> > I am writing a Gui in TCL and my backend code is python. I want to call
> > python procedure in tcl using tclpyhton. I want to know clearly how
> > this should be implemented.
> >
> > let's say I have procedure test_function(arg1,arg2 ...) defined in
> > test.py.
> > I want to call this procedure in tcl. Let me know how this should be
> > achieved.
> > The doubt basically have is how the tcl code knows in which .py file
> > this procedure is defined.
> >
> > currently I have wriiten this tcl code which is not working
> >
> > package require tclpython
> > set interpreter [python::interp new]
> > $interpreter eval {def test_function(): arg1,arg2} ;
> > python::interp delete $interpreter
> >
> What does not work? You never load your file test.py anywhere inside,
> you just evaluate 'def test_function(): arg1,arg2' so what are you
> expecting to happen?
>
> Your call to '$interpreter eval' lets you call arbitrary python code,
> but you have to provide the python code that loads your function
> definitions etc. I don't know python, but it should be a trivial code.
> 
> Michael




More information about the Python-list mailing list