On Mon, Sep 15, 2008 at 11:29:15PM +0200, Gael Varoquaux wrote: > On Mon, Sep 15, 2008 at 04:06:45PM -0400, Paul Kienzle wrote: > > Hi, > > > I tweaked the wx backend so that the idle delay is 5 ms rather than 50 ms. > > This allows the idle delay to kick in between mouse move events so > > the graph will be updated during a drag operation. > > > Users can override the idle delay using: > > > mpl.backends.backend_wx.IDLE_DELAY = n > > I don't know what the context is here, but if I understand it properly, > to be doing polling on a 5ms timescale is not very nice. This means a > wake up of the CPU every 5ms for this specific app. If everybody starts > doing that (I am looking at you, flash) my battery life goes down and my > laptop starts heating up.
It does not poll. draw_idle() triggers a timer with a 5ms delay. This timer is reset for each draw_idle() call. At timeout the timer is restarted if there are more events on the wx event queue, otherwise the graph is rendered. This means you can do as many draw_idle commands as you want while processing your data, but the expensive rendering will only happen once. Note that the wx.EVT_IDLE event polls about once per second. The backend must always bind to wx.EVT_IDLE since mpl_connect doesn't tell it whether or not it wants to receive the events, so this can't be avoided. I'm including a demo program to check the idle event behaviour on any platform, and the output I get on OS X when starting the application, waiting a few seconds and moving the mouse. Wx is generating more events than I expect. Is there any reason to keep idle_event support? It would seems more useful to have timer+draw_idle. - Paul -- idle.py -- import time import pylab t0 = time.time() def idle(ev): print "idle event at time %.6f seconds"%(time.time()-t0) def mouse(ev): print "motion event at time %.6f seconds"%(time.time()-t0) pylab.plot([1,2,3]) pylab.gcf().canvas.mpl_connect('idle_event',idle) pylab.gcf().canvas.mpl_connect('motion_notify_event',mouse) pylab.show() -- output -- $ python idle.py idle event at time 0.564772 seconds idle event at time 0.565030 seconds idle event at time 0.565147 seconds idle event at time 1.565512 seconds idle event at time 1.565739 seconds idle event at time 2.566126 seconds idle event at time 2.566348 seconds idle event at time 3.566702 seconds idle event at time 3.566920 seconds idle event at time 4.567263 seconds idle event at time 4.567488 seconds idle event at time 5.567894 seconds idle event at time 5.568116 seconds idle event at time 6.568480 seconds idle event at time 6.568698 seconds motion event at time 6.945880 seconds idle event at time 6.946449 seconds idle event at time 6.946573 seconds idle event at time 6.946688 seconds motion event at time 6.963200 seconds idle event at time 6.963724 seconds idle event at time 6.963845 seconds idle event at time 6.963959 seconds motion event at time 6.978130 seconds idle event at time 6.978689 seconds idle event at time 6.978846 seconds idle event at time 6.978963 seconds motion event at time 6.996028 seconds idle event at time 6.996623 seconds idle event at time 6.996751 seconds idle event at time 6.996866 seconds ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel