I'm in big trouble, I can't figure it out how to open my window "PlotWindow" with my "OpendPlotWindow" function. I'm new in PyQt so it is a dumb question, but I really don't understand what's wrong in my code
PlotWindow:
class PlotWindoW(QDialog):
def __init__(self,x,y, parent=None):
super(Window, self).__init__(parent)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.plot(x,y)
layout = QVBoxLayout()
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
self.setLayout(layout)
self.show()
def plot(self,x,y):
self.figure.clear()
ax = self.figure.add_subplot(111)
ax.plot(x,y)
self.canvas.draw()
PlotSetting:
class PlotSetting(QWidget):
def __init__(self,fileNameFm,fileNameMesh,fileNameSmry,fileNameXY, parent=None):
super(QWidget, self).__init__(parent)
print("setting start")
donnees.fileFm=fileNameFm
donnees.fileMesh=fileNameMesh
donnees.fileSmry=fileNameSmry
donnees.fileXY=fileNameXY
self.layout = QVBoxLayout(self)
self.tabs = QTabWidget()
self.tab1 = QWidget()
self.tabs.sizeHint()
self.tabs.addTab(self.tab1,"Setting Mesh")
LabelFm = QLabel(donnees.fileFm)
LabelMesh = QLabel(donnees.fileMesh)
btnNe=QPushButton("Choose Ne", self)
btnNe.clicked.connect(self.getInteger)
FmPlotBtn=QPushButton("Plot Mesh File", self)
FmPlotBtn.clicked.connect(self.GetDataFm)
self.tab1.layout = QVBoxLayout(self)
self.tab1.layout.addWidget(LabelFm)
self.tab1.layout.addWidget(LabelMesh)
self.tab1.layout.addWidget(btnNe)
self.tab1.layout.addWidget(FmPlotBtn)
self.tab1.setLayout(self.tab1.layout)
self.layout.addWidget(self.tabs)
self.setLayout(self.layout)
def getInteger(self):
donnees.Ne, okPressed = QInputDialog.getInt(self, "Get integer","Ne:", 66, 66, 98, 2)
if okPressed:
print(donnees.Ne)
def GetDataFm(self):
print('plot start')
data = {}
data = Fm( donnees.fileFm , donnees.fileMesh )
x,y=PloterFm(data,donnees.Ne)
print(x[0],y[0])
self.OpenPlotWindow(x,y)
def OpenPlotWindow(self, x, y):
print("OpenPlotWIndow is running")
print(x[0],y[0])
self.ThirdWindow = PlotWindoW(x,y)
self.ThirdWindow.show()
The problem: when I run my code, it comes to OpenPlotWindow which get all data needed, but it never enter into PlotWindow...
Please can you help me?
As per the docs for QPushButton
's super class QAbstractButton
, clicked
takes one argument, bool checked = false
. It's actually pretty useless on QPushButton as far as I've seen, but nevertheless, your function needs to account for this. Try this line instead
def GetDataFm(self, clicked=False):
....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.