Answer the question
In order to leave comments, you need to log in
QCoreApplication::exec: The event loop is already running?
As planned, this window should open first:
and then this (when you click on the second button):
But it opens the other way around
Here is the code:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
# from mainApp import MainApp
class Ui_MainWindow(object):
def open_per(self):
# from mainApp import MainApp
# self.window = QtWidgets.QMainWindow()
self.ui = MainApp()
# self.ui.setupUi(self.window)
# self.window.show()
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(500, 400)
MainWindow.setStyleSheet("background-color:white")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(0, 20, 501, 41))
self.label.setObjectName("label")
self.pb1 = QtWidgets.QPushButton(self.centralwidget)
self.pb1.setGeometry(QtCore.QRect(40, 110, 101, 21))
self.pb1.setStyleSheet("color: #4B657A;")
self.pb1.setObjectName("pb1")
self.pb2 = QtWidgets.QPushButton(self.centralwidget)
self.pb2.setGeometry(QtCore.QRect(40, 180, 101, 21))
self.pb2.setStyleSheet("color: rgb(75, 101, 122);")
self.pb2.setObjectName("pb2")
# if self.pb2.clicked:
self.pb2.clicked.connect(self.open_per)
self.pb3 = QtWidgets.QPushButton(self.centralwidget)
self.pb3.setGeometry(QtCore.QRect(40, 250, 101, 21))
self.pb3.setStyleSheet("color: rgb(75, 101, 122);")
self.pb3.setObjectName("pb3")
self.pb4 = QtWidgets.QPushButton(self.centralwidget)
self.pb4.setGeometry(QtCore.QRect(40, 310, 101, 21))
self.pb4.setStyleSheet("color: #4B657A;")
self.pb4.setObjectName("pb4")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(150, 70, 321, 301))
self.label_2.setText("")
self.label_2.setTextFormat(QtCore.Qt.AutoText)
self.label_2.setPixmap(QtGui.QPixmap("2znak.png"))
self.label_2.setScaledContents(True)
self.label_2.setObjectName("label_2")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:14pt; font-weight:600; color: #4B657A;\">База даних мешканців студентського гуртожитка</span></p></body></html>"))
self.pb1.setToolTip(_translate("MainWindow", "<html><head/><body><p align=\"center\">Реєстрація</p></body></html>"))
self.pb1.setText(_translate("MainWindow", "Реєстрація"))
self.pb2.setText(_translate("MainWindow", "Перегляд"))
self.pb3.setText(_translate("MainWindow", "Довідка"))
self.pb4.setText(_translate("MainWindow", "Про автора"))
if __name__ == "__main__":
import sys
from mainApp import MainApp
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question