Hello,
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
matplotlib.use('Qt4Agg')
import matplotlib.pyplot as plt
def say_hello(event):
print "Hello"
fig = plt.figure()
fig.canvas.mpl_connect('resize_event', say_hello)
plt.show()
Resizing the figure does not result in "Hello" outputs, as it should.
The issue seems to be in lib/matplotlib/backends/backend_qt4.py, where
resizeEvent() looks like:
def resizeEvent( self, event ):
if DEBUG: print('resize (%d x %d)' % (event.size().width(),
event.size().height()))
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 )
self.draw()
self.update()
QtGui.QWidget.resizeEvent(self, event)
By comparison with the other surrounding event handlers, the callback to
FigureCanvasBase.resize_event() is manifestly missing. Indeed, adding
FigureCanvasBase.resize_event(self)
at the end of resizeEvent() solves the problem.
Thanks,
Stefan
···
--
View this message in context: http://old.nabble.com/Matplotlib-Qt4Agg-backend-ignores-'resize_event'-tp34205981p34205981.html
Sent from the matplotlib - devel mailing list archive at Nabble.com.