I am starting with the topic of the graphical interface in PyQt5.
I have defined two windows, the first that would be the main one and a sub-window that contains a button, which calls a function to make a graph through its 'clicked' method for the respective event.
My problem is that when executing I get the following error: 'DataInput' object has no attribute 'graph'.
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.uic import loadUi
import matplotlib.pyplot as plt
# CLASS MAIN WINDOW
# ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
class mainWindowInicial(QMainWindow):
def __init__(self, parent=None):
super(mainWindowInicial,self).__init__(parent)
loadUi('Gui/mainwindow.ui', self)
self.actionData.triggered.connect(self.open_dataInput)
# EVENTS ==================================================================
def open_dataInput(self):
DataInput(self).show()
def graphics():
plt.plot((0,5),(0,5))
plt.show()
class DataInput(QMainWindow):
def __init__(self, parent=None):
super(DataInput,self).__init__(parent)
loadUi('Gui/datawindow.ui', self)
self.pushButton_Graph.clicked.connect(self.graph)
def graph():
graphics()
if __name__ == "__main__":
app = QApplication(sys.argv)
widget = mainWindowInicial()
widget.show()
sys.exit(app.exec_())
If anyone understands PyQt5 a bit more, I would appreciate your help, best regards.