使用2 .show的PyQt5无法获得任何一个

问题描述

PyQt5应用程序,我正在构建此应用程序,并且在运行代码时必须使用2 .show(),显示2个GUI。一个空白的GUI以及我的信息。当我删除第一个.show()时,只有空白GUI出现;而我删除第二个.show()则没有任何想法。

import sys
from PyQt5.QtWidgets import QApplication,QMainWindow,QWidget,QGridLayout,`enter code here`QLineEdit,QLabel
from PyQt5.QtWidgets import QPushButton,QVBoxLayout,QFormLayout,QPushButton,`enter code here`QTableWidget,QTableWidgetItem
from PyQt5.QtCore import Qt
import sqlite3

class ExerciseTracker(QWidget):
    def __init__(self):
        super().__init__()
        self.myWindow = QWidget()
        self.title = 'Exercise Tracker'
        self.setWindowTitle(self.title)
        self.setGeometry(200,400,300,200)
        self.move(60,15)
        self.layout = QFormLayout()
        self.layout.addRow(QLabel('<h2>Welcome to the App!</h2>',parent=self.myWindow))
        line_edit1 = QLineEdit()
        self.layout.addRow('Day of the week: ',line_edit1)
        line_edit2 = QLineEdit()
        self.layout.addRow('Body Part: ',line_edit2)
        line_edit3 = QLineEdit()
        self.layout.addRow('Input Exercise: ',line_edit3)
        line_edit4 = QLineEdit()
        self.layout.addRow('Input Sets: ',line_edit4)
        line_edit5 = QLineEdit()
        self.layout.addRow('Input Reps: ',line_edit5)
        btn1 = QPushButton('Submit')
        self.layout.addRow(btn1)
        btn2 = QPushButton('Show Records')
        self.layout.addRow(btn2)

        self.myWindow.setLayout(self.layout)
        self.myWindow.show()

def main():
    exercise = QApplication(sys.argv)
    view = ExerciseTracker()
    view.show()
    sys.exit(exercise.exec_())

if __name__ =='__main__':
    main()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...