Matplotlib Qt4Agg backend ignores 'resize_event'


It appears that the Qt4Agg backend ignores any user defined 'resize_event'.
This program reproduces the issue (I am using the development version of
matplotlib from github):

import matplotlib
import matplotlib.pyplot as plt

def say_hello(event):
    print "Hello"

fig = plt.figure()
fig.canvas.mpl_connect('resize_event', say_hello)

Resizing the figure does not result in "Hello" outputs, as it should.

The issue seems to be in lib/matplotlib/backends/, where
resizeEvent() looks like:

def resizeEvent( self, event ):
        if DEBUG: print('resize (%d x %d)' % (event.size().width(),
        w = event.size().width()
        h = event.size().height()
        if DEBUG: print("FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")")
        dpival = self.figure.dpi
        winch = w/dpival
        hinch = h/dpival
        self.figure.set_size_inches( winch, hinch )
        QtGui.QWidget.resizeEvent(self, event)
By comparison with the other surrounding event handlers, the callback to
FigureCanvasBase.resize_event() is manifestly missing. Indeed, adding


at the end of resizeEvent() solves the problem.



View this message in context:'resize_event'-tp34205981p34205981.html
Sent from the matplotlib - devel mailing list archive at