pyprocessing from another module

30 views
Skip to first unread message

Nick Malleson

unread,
Aug 22, 2012, 5:57:30 AM8/22/12
to pyprocess...@googlegroups.com
Hi,

Firstly, thanks for this awesome library and sorry if this is an obvious question (or has already been answered). I have some object-oriented code that generates some data. Once the data are ready I want to pass them to a pyprocessing srcipt to animate them. I'm struggling to make this work and there's probably a simple solution. Here's an example:

In my data-generating code, once the data is ready to be animated, I do something like:

  import my_processing_script  # (the script is called my_processing_script.py)
  my_processing_script.pass_data(the_data)
  my_processing_script.run()

my_processing_script is a simple pyprocessing script (e.g. the centipede.py example) with setup() and draw() methods, as well as a pass_data() method to receive the data to animate.

The problem is that when the program gets to the 'my_processing_script.run()' line, a Python GUI window opens but nothing happens.
If I run my_processing_script.py from the command-line with some dummy data it works OK, I have put the following at the end of the script

if __name__=='__main__':
  run()

Any ideas why the script doesn't work properly when run() is called from another python package? It looks to me like the setup() and draw() methods aren't being called.

Thanks,
Nick

 



Reply all
Reply to author
Forward
0 new messages