Is there a way in my scripts to return to the python prompt so I can poke at my program a bit?
(that is, once I’ve called run(), is there a “stop” or something like that)
Ideally I could put “stop” into a key handler, or have it triggered as an event or …
I guess there might be a matching “continue” since I probably wouldn’t want to call run again.
No, you could do that. It depends on what you mean be a pause() function. You could always write a function that does absolutely nothing, waiting for some event to occur, and that will effectively block the entire application. Or, if you want to return the user to a prompt, you could simply raise the Python exception of your choice. If you raise KeyboardInterrupt, it will be the cleanest break, since the Task manager will trap this and defer it until after the task loop has fully completed one pass. But if you don’t care about that detail (and most people probably won’t), any exception would be fine.
I think what he’s interested in is the function ‘taskMgr.stop()’
The code for “run” is inside direct/src/task/Task.py. It says this:
class TaskManager:
...
def run(self):
...
self.running = 1
while self.running:
...
def stop(self):
# Set a flag so we will stop before beginning next frame
self.running = 0
taskMgr.stop is exactly what I wanted (well, almost - it has the wierd effect that if I didn’t start with an interactive prompt it exits entirely, so i just need to run my program using “import” rather than from the shell command line)
ctrl-c would be handy, but it doesn’t seem to work