Я пытаюсь перейти от окна к окну, назад и вперед.
Я пытался использовать while True: похоже, не получается заставить его работать.Он просто печатает HOME миллион раз и вылетает окно.
from PyQt5 import QtCore, QtGui, QtWidgets
import IMAGE_rc
import sys
from GUIWINDOW1 import *
import time
class Ui_MainWindow(object):
def setup(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setEnabled(True)
MainWindow.resize(800, 480)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
MainWindow.setMinimumSize(QtCore.QSize(800, 480))
MainWindow.setMaximumSize(QtCore.QSize(800, 480))
MainWindow.setMouseTracking(False)
MainWindow.setStyleSheet("background-color: rgb(170, 255, 127);")
MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
MainWindow.setTabShape(QtWidgets.QTabWidget.Rounded)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setMinimumSize(QtCore.QSize(800, 480))
self.centralwidget.setMaximumSize(QtCore.QSize(800, 480))
self.centralwidget.setObjectName("centralwidget")
self.TOUCH1 = QtWidgets.QPushButton(self.centralwidget)
self.TOUCH1.setGeometry(QtCore.QRect(70, 10, 662, 200))
self.TOUCH1.setStyleSheet("border-image: url(/PROGRAMMING/QT DESIGNER/GUIIMAGES/LOGO.png);")
self.TOUCH1.setText("")
self.TOUCH1.setObjectName("TOUCH1")
self.TOUCH2 = QtWidgets.QPushButton(self.centralwidget)
self.TOUCH2.setGeometry(QtCore.QRect(210, 220, 360, 200))
self.TOUCH2.setStyleSheet("border-image: url(/PROGRAMMING/QT DESIGNER/GUIIMAGES/1200px-Florida_Atlantic_Owls_logo.svg.png);\n"
"background-color: rgb(170, 255, 127);")
self.TOUCH2.setText("")
self.TOUCH2.setObjectName("TOUCH2")
self.TOUCH4 = QtWidgets.QPushButton(self.centralwidget)
self.TOUCH4.setGeometry(QtCore.QRect(0, 0, 801, 481))
self.TOUCH4.setStyleSheet("")
self.TOUCH4.setObjectName("TOUCH4")
self.TOUCH3 = QtWidgets.QPushButton(self.centralwidget)
self.TOUCH3.setGeometry(QtCore.QRect(70, 430, 611, 41))
font = QtGui.QFont()
font.setPointSize(16)
self.TOUCH3.setFont(font)
self.TOUCH3.setStyleSheet("")
self.TOUCH3.setObjectName("TOUCH3")
self.TOUCH4.raise_()
self.TOUCH1.raise_()
self.TOUCH2.raise_()
self.TOUCH3.raise_()
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.TOUCH1.clicked.connect(self.BEGIN)
self.TOUCH2.clicked.connect(self.BEGIN)
self.TOUCH3.clicked.connect(self.BEGIN)
self.TOUCH4.clicked.connect(self.BEGIN)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.TOUCH4.setText(_translate("MainWindow", "PushButton"))
self.TOUCH3.setText(_translate("MainWindow", "TAP ANYWHERE TO BEGIN"))
def BEGIN(self):
print("HOME")
self.WINDOW1=QtWidgets.QMainWindow()
self.ui = Ui_WINDOW1()
self.ui.setup(self.WINDOW1)
self.WINDOW1.showFullScreen()
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setup(MainWindow)
MainWindow.showFullScreen()
sys.exit(app.exec_())
Окно закрывается, когда я возвращаюсь назад и вперед от MainWindow к WINDOW1 и пытаюсь вернуться к WINDOW1