Vitor Bosshard wrote:
> A better way to throttle update frequency is to change the OnMove event 
> handler to just store the coordinates (or whatever data you need from the 
> event) in a special variable, which takes practically no time. Then, bind a 
> different handler to EVT_IDLE, and trigger canvas redraws from there. Since 
> multiple Move events keep overwriting the same variable over and over, the 
> OnIdle handler is guaranteed to see only the most recent one whenever it 
> triggers:
> 
>     @Bind(wx.EVT_IDLE)
>     def OnIdle(self,e):
>         if self._coords is not None:
>             coords = self._coords
>             self._coords = None
>             self.Update(coords)
> 
> This made the canvas both responsive and accurate, without even needing to 
> improve performance of my redrawing methods. Since there are only a couple of 
> dozen objects on the canvas at most, it makes sense for me to just remove all 
> objects and recreate the view based on my underlying data, keeping the code 
> able to process arbitrary changes to the canvas objects in a simple and 
> elegant way.

Thanks for posting this follow-up. I can see how I can rework my code to use 
this
technique, and why it would be more responsive to the user.

Paul

_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to