Call Different Interpreter For Tcl In Python
Solution 1:
It depends on how OpenSees is built and what options it offers.
Typically programs that embed Tcl have two main options how to do it, quite similar to Python.
Variant one is to have a normal C/C++ main program and link to the Tcl library, in effect the same thing tclsh
does, a shell that can execute Tcl commands and providing extra commands statically.
Variant two is using a normal tclsh
and just loading some extension modules to add the functionality. If that is the case, you can often simply load the package in the tkinter
shell if they are similar enough, and are done.
OpenSees seems to be a program that implements variant one, a bigwish that includes some extra commands not available outside. So you cannot load the code directly in a tkinter
shell.
You have three options:
- Use something like the Tcllib
comm
package to communicate between Tkinter and the OpenSees shell (see Running TCL code (on an existing TCL shell) from Python for an example) - Run opensees via
subprocess
and implement some kind of communication protocol to send your commands. - Hack at the OpenSees code to build it as a loadable package for Tcl and load it into your tkinter process (might be hard).
Solution 2:
Solved it with a oneliner:
subprocess.call('Opensees elastic-1dof-spectrum.tcl', shell=True)
Post a Comment for "Call Different Interpreter For Tcl In Python"