Realtime interactive graphing of a simulation
I am writing a program to simulate a double displacement reaction getting to equilibrium, but I am having some trouble graphing the particles' concentrations. It seems that it's only possible to pan and zoom the graph once the program exits (when running it from IDLE), but I don't want to have to kill the sim every time I want to view the graph (besides, when I do, the graph window dissappears).
The following code contains all the graphing functionality, the initGraph() function is called before the sim's main loop, and updateGraph() is called once a second with the current concentrations of 4 types of particles. The sim uses PyGame for graphics, and I didn't think that code was relevant: if it is, just let me know and I'll post it. Code:
from pylab import * |
(Second try: I accidentally closed the tab with my response :()
Hi! I think you need threads. They allow you to run different parts of your program in parallel. Take a look to the links (just googled "python threads"): http://www.wellho.net/solutions/pyth...t-example.html http://www.devshed.com/c/a/Python/Ba...ing-in-Python/ HTH! |
Yea, I have tried threads too (and will actually change the whole graphing mechanism to one that uses TCP for communication, so I can graph on a different machine etc.), but I have the same problem.
|
All times are GMT -5. The time now is 11:44 PM. |