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-%27resize_event%27-tp34205981p34205981.html
Sent from the matplotlib - devel mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to