Skip to content

Commit

Permalink
Merge pull request #2844 from tacaswell/qt_win_specialcase
Browse files Browse the repository at this point in the history
BUG : Qt repaint workaround on windows
  • Loading branch information
efiring committed Mar 12, 2014
2 parents a7d9266 + 333f2dc commit 7feeb0e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/matplotlib/backends/backend_qt4agg.py
Expand Up @@ -73,6 +73,22 @@ def __init__( self, figure ):
self.rect = []
self.blitbox = None
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
# it has been reported that Qt is semi-broken in a windows
# environment. If `self.draw()` uses `update` to trigger a
# system-level window repaint (as is explicitly advised in the
# Qt documentation) the figure responds very slowly to mouse
# input. The work around is to directly use `repaint`
# (against the advice of the Qt documentation). The
# difference between `update` and repaint is that `update`
# schedules a `repaint` for the next time the system is idle,
# where as `repaint` repaints the window immediately. The
# risk is if `self.draw` gets called with in another `repaint`
# method there will be an infinite recursion. Thus, we only
# expose windows users to this risk.
if sys.platform.startswith('win'):
self._priv_update = self.repaint
else:
self._priv_update = self.update

def drawRectangle( self, rect ):
self.rect = rect
Expand Down Expand Up @@ -152,7 +168,7 @@ def draw( self ):
# causes problems with code that uses the result of the
# draw() to update plot elements.
FigureCanvasAgg.draw(self)
self.update()
self._priv_update()

def blit(self, bbox=None):
"""
Expand Down

0 comments on commit 7feeb0e

Please sign in to comment.