我已经用tkinter构建了一个应用程序来在一个平台上执行不同的分析,但是现在我正试图将它转换为PyQT,以提高演示的可视化效果。我的应用程序由两个不同的框架组成,它们可以通过我的主框架的按钮访问。在
在tkinter中,我创建了一个用于切换帧的控制器类,但我对PyQt还是个新手,我无法实现它或任何合理的错误代码。我简化了下面的代码。在
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class MainWindow(object):
def setupUi(self, MainFrame):
MainFrame.setObjectName("MainFrame")
MainFrame.resize(870, 230)
MainFrame.setFrameShape(QFrame.Box)
self.Function1Button = QPushButton(MainFrame)
#I want to go Function 1's frame with this button
self.Function1Button.clicked.connect(????)
self.Function2Button = QPushButton(MainFrame)
#I want to go Function 2's frame with this button
self.Function2Button.clicked.connect(????)
class Function1(object):
def setupUi(self, Frame):
Frame.setObjectName("Frame")
Frame.resize(870, 230)
self.BackButton = QPushButton(MainFrame)
# I want to go previous frame with this button
self.BackButton.clicked.connect(????)
self.Function2Button = QPushButton(MainFrame)
#I want to go Function 2's frame with this button
self.Function2Button.clicked.connect(????)
self.ExecuteButton = QPushButton(MainFrame)
self.ExecuteButton.clicked.connect(self.runfunc)
def runfunc(self):
# Computations
class Function2(object):
def setupUi(self, Frame):
Frame.setObjectName("Frame")
Frame.resize(870, 230)
self.BackButton = QPushButton(MainFrame)
self.BackButton.clicked.connect(????)
self.Function1Button = QPushButton(MainFrame)
#I want to go Function 1's frame with this button
self.Function1Button.clicked.connect(????)
self.ExecuteButton = QPushButton(MainFrame)
self.ExecuteButton.clicked.connect(self.runfunc)
def runfunc(self):
# Computations
我想在开始时打开主窗口,然后用主窗口上的按钮打开函数的框架。 有了后退按钮,我想返回上一帧。 我还想用function1按钮从函数1到达函数2的帧,反之亦然。在
在PyQt5(或PySide2)中,需要将QFrame设置为“容器”。在里面你会放其他的Qframe。在
相关问题 更多 >
编程相关推荐