Connecting to to iplt Qt Widget signals in Python
To connect in Python to a signal of an IPLT widget we can again take advantage of PyQt4 bindings we have seen in the last example.
We can for example connect a python slot to the DataClicked signal of the PlotViewer:
class PlotViewer: public QMainWindow { ... signals: void DataClicked(double x, double y, double ex, double ey, double q,const QString& info); ... };
For this we wrap the PlotViewer instance in sip and use the PyQt4 mechanism for connecting a slot:
import sip from PyQt4.QtCore import * from PyQt4.QtGui import * # first we define our slot def my_slot(x,y,ex,ey,,q,infotext): mlogn(0,"Data clicked in plot viewer:%f,%f,%f,%f,%f,%s" % (x,y,ex,ey,q,str(infotext))) # creates a IPLT plot viewer widget plotviewer=gui.CreatePlotViewer() # converts the widget to sip sip_plotviewer=sip.wrapinstance(plotviewer.SipHandle(),QWidget) # connects the slot QObject.connect(sip_plotviewer,SIGNAL("DataClicked(double,double,double,double,double,const QString&)"),my_slot)
