From: AI <tri...@gm...> - 2012-05-25 16:51:23
|
Hi, same problem with ipython 0.12 and matplotlib 1.1.1rc. To recall, I'm trying to add a QT4 widget to a matplotlib figure (MPL is using Qt4 as backend). However, in the attached example the widget callback (or slot) is not called. Oddly, if I add the qt4 widget manually calling qt4_interface() from ipython it works. Basically I want to preserve the maplotlib+ipython interactive workflow, but using some "enhanced" figures (i.e. mpl figure+qt4 widgets). Thank you for any suggestion. Antonio 2012/5/24 AI <tri...@gm...> > Hi, > > I want to add a QT4 widget to a matplotlib figure, but the widget does not > react to user input. > > Here it is a test case: > > from PyQt4 import QtGui, QtCore > from pylab import * > > def test(): > plot([1,2,3], lw=2) > qt4_interface(gcf()) > > class qt4_interface: > def __init__(self,fig): > QMainWin = fig.canvas.parent() > toolbar = QtGui.QToolBar(QMainWin) > QMainWin.addToolBar(QtCore.Qt.BottomToolBarArea, toolbar) > > self.line_edit = QtGui.QLineEdit(parent=toolbar) > self.line_edit.editingFinished.connect(self.do_something) > toolbar.addWidget(self.line_edit) > > def do_something(self, *args): > f = open('l','a'); f.write('yes\n'); f.flush(); f.close() > #close() > > I run the script as "run -i qt4_test.py" from ipython. Then running test() > I get the figure with the additional widget but the do_something method is > never called. > > Incidentally if I do a plot from ipython and then I type interactively > qt4_interface(gcf()), the qt4 widget is added to the figure and works > properly. > > Any hints on how can I resolve this problem? > > BTW, I'm running matplotlib official package (1.0.1) included in ubuntu > 11.10. > > Thanks, > Antonio > > > > |