Hi,
I think all this is fairly straightforward. You just need to connect your
GUI button signals to your startPlot/stopPlot mothods. From the init of
your MyApp class, something like:
self.startButton.clicked.connect(self.plotter.startPlot) # where plotter is
a reference to the Plotter window inside your GUI.
For getting the data to the Plotter class, you will need to pass in a
reference to your data structure somehow, either in init and/or a method.
So:
class Plotter(pg.GraphicsWindow):
def __init__(self, datasource, parent=None, **kargs):
# ...
# self.dfs = datasource
# ...
# ...
def setDataSource(self, datasource):
self.dfs = datasource
def updatePlot(self):
# self.curve.clear() # Note, you don't need to clear before doing a
setData
self.curve.setData(self.dfs.data_dictionary['time'], self.dfs.
data_dictionary['Voltage'])
Patrick
On Thursday, 31 January 2019 21:54:55 UTC+10:30, [email protected]
wrote:
>
> 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/94c0ac9b-a17f-4bba-be6c-af3b99cc0c84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.