I need to have a plot window hang around and be occasionally updated by 
my script as it does things. I've been looking through examples and have 
not been able to get anything to work.

My current approach, inspired by strip_chart_demo.py and others in the 
animation examples, is:

import gobject, matplotlib, sys
matplotlib.use('GTKAgg')
import matplotlib.pylab as pylab
import threading, time, random

class PylabThread(threading.Thread):
   def __init__(self):
     threading.Thread.__init__(self)
   def update(self):
     pylab.draw()
   def run(self):
     gobject.idle_add(self.update)
     pylab.plot([random.random() for i in xrange(1000)])
     pylab.show()


if __name__ == "__main__":
   p = PylabThread()
   p.start()

   i = 0
   while True:
     print i
     i += 1
     time.sleep(.5)


Running this, however, yields the odd behavior that you only get numbers 
printed every half second (as you should) if you move the mouse (or hit 
keys, or otherwise generate events) within the plot window!

What's going on, and how can I fix this?

Thanks!



dan

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to