I'm not much of a Python programmer, but you should be able to print to stdout from within a PythonScript actor, see below where I added to print() calls to the script.
BCVTB used Ptolemy II as its execution engine. In Ptolemy II, it is possible to listen to actors by right clicking on the actor and selecting "Listen to Actor". At runtime, messages will be displayed in a separate window. To write to the listener from within your Python code, see https://chess.eecs.berkeley.edu/ptext...:
In the script, use self.actor to
access the actor. For example,
self.actor.getDirector() returns the
current director of the actor. For
debugging, use
self.actor.debug(someMessage). The
final message sent to the debug
listeners of the actor will have the
string "From script: " inserted at the
beginning. To avoid generating the
debug message when there are no
listeners, use:
if self.actor.isDebugging() :
self.actor.debug(someMessage)
I'm not sure about the indentation of the above.
To print to an output, see $PTII/ptolemy/actor/lib/python/test/PythonSysPath.xml , which has a PythonActor with the following. Note that I added two print() calls, which seem to work.
import sys.path
import ptolemy.data.type.BaseType
import ptolemy.data.StringToken
class Main :
"Report the components of Jython's syspath"
def preinitialize(self):
self.output.setTypeEquals(ptolemy.data.type.BaseType.STRING)
def prefire(self):
return self.input.hasToken(0)
def fire(self) :
y=self.input.get(0) # retrieve and discard the trigger
result=""
sp=sys.path
for i in range(len(sp)) :
if (len(result) > 0):
result+="\n"
result+=sp[i]
print('The result is')
print(result)
self.output.broadcast(ptolemy.data.StringToken(result))
return