Revision: 5876
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5876&view=rev
Author: pkienzle
Date: 2008-07-25 19:52:11 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
wx backend: implement draw_idle
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-25
17:38:06 UTC (rev 5875)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-07-25
19:52:11 UTC (rev 5876)
@@ -719,12 +719,20 @@
bind(self, wx.EVT_LEAVE_WINDOW, self._onLeave)
bind(self, wx.EVT_IDLE, self._onIdle)
+ # Event loop handler for start/stop event loop
self._event_loop = wx.EventLoop()
self.macros = {} # dict from wx id to seq of macros
self.Printer_Init()
+ # Create an timer for handling draw_idle requests
+ # If there are events pending when the timer is
+ # complete, reset the timer and continue. The
+ # alternative approach, binding to wx.EVT_IDLE,
+ # doesn't behave as nicely.
+ self.idletimer = wx.CallLater(1,self._onDrawIdle)
+
def Destroy(self, *args, **kwargs):
wx.Panel.Destroy(self, *args, **kwargs)
@@ -880,8 +888,18 @@
def draw_idle(self, *args, **kwargs):
- pass
+ """
+ Delay rendering until the GUI is idle.
+ """
+ DEBUG_MSG("draw_idle()", 1, self)
+ self.idletimer.Restart(50, *args, **kwargs) # Delay by 50 ms
+ def _onDrawIdle(self, *args, **kwargs):
+ if False and wx.GetApp().Pending():
+ self.idletimer.Restart(5, *args, **kwargs)
+ else:
+ self.draw(*args, **kwargs)
+
def draw(self, repaint=True):
"""
Render the figure using RendererWx instance renderer, or using a
@@ -960,14 +978,16 @@
redraw the image.
"""
DEBUG_MSG("gui_repaint()", 1, self)
- if drawDC is None:
- drawDC=wx.ClientDC(self)
+ if self.IsShownOnScreen():
- drawDC.BeginDrawing()
- drawDC.DrawBitmap(self.bitmap, 0, 0)
- drawDC.EndDrawing()
- #wx.GetApp().Yield()
+ if drawDC is None:
+ drawDC=wx.ClientDC(self)
+ drawDC.BeginDrawing()
+ drawDC.DrawBitmap(self.bitmap, 0, 0)
+ drawDC.EndDrawing()
+ #wx.GetApp().Yield()
+
filetypes = FigureCanvasBase.filetypes.copy()
filetypes['bmp'] = 'Windows bitmap'
filetypes['jpeg'] = 'JPEG'
@@ -1031,6 +1051,10 @@
# Restore everything to normal
self.bitmap = origBitmap
+ # Note: draw is required here since bits of state about the
+ # last renderer are strewn about the artist draw methods. Do
+ # not remove the draw without first verifying that these have
+ # been cleaned up.
self.draw()
self.Refresh()
@@ -1089,7 +1113,7 @@
self.figure.set_size_inches(winch, hinch)
if self._isRealized:
- self.draw()
+ self.draw_idle()
evt.Skip()
def _get_key(self, evt):
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
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-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins