I'm trying to learn the basic usage of emitting/receiving signals and I'm running into some trouble.
I wanted to start with something basic so I created a MainWindow and put a QPushButton called "plot".
When the button is pushed it takes the arguments (self, xdata, ydata) and runs the method initiatePlot from my class MainWindow(QMainWindow)
self.plotbtn = QPushButton("Plot")
self.plotbtn.clicked.connect(partial(self.initiatePlot, xdata, ydata))
def initiatePlot(self,x,y):
PlotSignal = pyqtSignal(list, list)
self.PlotSignal.emit(x, y)
Afterwards I tried to connect it to my plotter class, but I just get "Process finished exit code 1" I believe the error to be coming from this particular line of code in my below class.
self.PlotSignal.connect(self.plotData)
CODE FOR PLOTTER CLASS
class createFIG(FigureCanvas):
def __init__(self):
#super().__init__(Figure(tight_layout=True))
self.figure = plt.figure()
self.axes = self.figure.add_subplot(111)
self.name = ""
# xdata = [1,2,3,4,5]
# ydata = [12,4,56,78,9]
plt.figure()
self.axes.set_xlabel('x label')
#self.plotData(xdata,ydata)
self.PlotSignal.connect(self.plotData)
def plotData(self, xdata,ydata):
print("plotting")
self.axes.plot(xdata, ydata)
self.draw()
plt.show()
Sorry the whitespace might be a little messed up.
The current issue is how I go about receiving the signal I emit from my initiatePlot method.
The end goals is to be able to click the plot button and create a new window with a new plot figure each time.
If there is an easier way to link the button in my mainwindow to plotting class that would be helpful.
Here is a link to my full code: https://github.com/Silvuurleaf/InteractiveGraphing/blob/master/LiveGraphing.py