I'd like to embed pyqtgraph window into my GUI which was created in 
QtDesiger. At first I just created new window and defined everything inside 
main GUI class (MyApp) and everything is working fine this way.

Now I created a Plotter class for GraphicsWindow, saved it to file 
pyqtwindow.py, and promoted it in Designer so now when I run my GUI, the 
window of pyqtgraph is there. 
The rest of GUI stuff is inside MyApp class in GUI.py file. How can I 
connect signals between these classes? I also have different class in 
different file for storing the data (dataframes.py, which is defined as dfs 
in MyApp), how do I read the results from this class inside my Plotter 
class?

class Plotter(pg.GraphicsWindow):
    def __init__(self, parent=None, **kargs):
        pg.GraphicsWindow.__init__(self, **kargs)
        self.setParent(parent)
        self.plt = self.addPlot(row=1, col=0, title="Plot",
                                    labels={'left': 'Voltage [V]',
                                            'bottom': 'time [s]'})
        self.curve = self.plt.plot(pen='b')
        self.label_cords = pg.LabelItem(justify="right")
        self.addItem(self.label_cords)
        self.proxy = pg.SignalProxy(self.plt.scene().sigMouseMoved, 
rateLimit=60,
                                    slot=self.mouseMoved)
        self.plot_timer = pg.QtCore.QTimer()
        self.plot_timer.timeout.connect(self.updatePlot)
        
    def startPlot(self):
    self.plot_timer.start(1000) # how can I trigger it from main class 
MyApp, which has all other signals/slots connected ?
    def stopPlot(self):
    self.plot_timer.stop() # I'd like to stop the trigger the same way 
(pushing STOP button which is in MyApp class)
    def mouseMoved(self, evt):
        self.mousePoint = self.plt.vb.mapSceneToView(evt[0])
        self.label_cords.setText("<span style='font-size: 8pt; color: 
white'> x = %0.4f, <span style='color: white'> y = %0.4f</span>"
           % (self.mousePoint.x(), self.mousePoint.y()))
    
    def updatePlot(self):
        self.curve.clear()
        self.curve.setData(dfs.data_dictionary['time'], 
dfs.data_dictionary['Voltage'])

if __name__ == '__main__':
    w = Plotter()
    w.show()
    QtGui.QApplication.instance().exec_()


-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/7221e320-f762-4760-8a99-d80b276db5e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to