import PyQt6
import sys
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QLabel, QLineEdit, QHBoxLayout
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
MainWindow.setStyleSheet("selection-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 196, 255), stop:1 rgba(255, 255, 255, 255));")
self.centralwidget = QtWidgets.QWidget(parent=MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.bt_reshat = QtWidgets.QPushButton(parent=self.centralwidget)
self.bt_reshat.setGeometry(QtCore.QRect(220, 180, 150, 100))
self.bt_reshat.setObjectName("bt_reshat")
self.bt_sost = QtWidgets.QPushButton(parent=self.centralwidget)
self.bt_sost.setGeometry(QtCore.QRect(420, 180, 150, 100))
self.bt_sost.setObjectName("bt_sost")
self.bt_sost.clicked.connect(self.solve_clicked)
self.bt_inf = QtWidgets.QPushButton(parent=self.centralwidget)
self.bt_inf.setGeometry(QtCore.QRect(220, 320, 150, 100))
self.bt_inf.setObjectName("bt_inf")
self.bt_istor = QtWidgets.QPushButton(parent=self.centralwidget)
self.bt_istor.setGeometry(QtCore.QRect(420, 320, 150, 100))
self.bt_istor.setObjectName("bt_istor")
self.new_window = None
self.bt_nastroy = QtWidgets.QPushButton(parent=self.centralwidget)
self.bt_nastroy.setGeometry(QtCore.QRect(720, 10, 50, 50))
self.bt_nastroy.setObjectName("bt_nastroy")
self.bt_exit_2 = QtWidgets.QPushButton(parent=self.centralwidget)
self.bt_exit_2.setGeometry(QtCore.QRect(40, 10, 50, 50))
self.bt_exit_2.setObjectName("bt_exit_2")
self.Lzagolov = QtWidgets.QLabel(parent=self.centralwidget)
self.Lzagolov.setGeometry(QtCore.QRect(190, 20, 421, 41))
self.Lzagolov.setStyleSheet("font: 63 14pt \"Yu Gothic UI Semibold\";")
self.Lzagolov.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.Lzagolov.setObjectName("Lzagolov")
self.Lmagkv = QtWidgets.QLabel(parent=self.centralwidget)
self.Lmagkv.setGeometry(QtCore.QRect(316, 282, 151, 31))
self.Lmagkv.setStyleSheet("font: 63 10pt \"Yu Gothic UI Semibold\";")
self.Lmagkv.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.Lmagkv.setObjectName("Lmagkv")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(parent=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.bt_reshat.setText(_translate("MainWindow", "Решать"))
self.bt_sost.setText(_translate("MainWindow", "Составлять "))
self.bt_inf.setText(_translate("MainWindow", "Информация"))
self.bt_istor.setText(_translate("MainWindow", "История"))
self.bt_nastroy.setWhatsThis(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><img src=\"https://s.pfst.net/2015.09/8299238634134583cfef1ea9a9d0ca6fc...\" /></p></body></html>"))
self.bt_nastroy.setText(_translate("MainWindow", "PushButton"))
self.bt_exit_2.setText(_translate("MainWindow", "PushButton"))
self.Lzagolov.setText(_translate("MainWindow", "Добро пожаловать в мир магии"))
self.Lmagkv.setText(_translate("MainWindow", "Магические квадраты"))
def solve_clicked(self):
# Создаем новое окно и сохраняем ссылку на него
self.new_window = NewWindow()
self.new_window.show()
class NewWindow(QWidget):
def __init__(self):
super().__init__()
self.setGeometry(150, 150, 200, 150)
self.setWindowTitle("Новое окно")
self.setStyleSheet("background-color: #ff0000;")
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec())
и оно при нажатии на кнопку составлять создает новое окно, если это просто пустое окно то все ок. но мне нужно чтобы открывалось вот это
import sys
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QLabel, QLineEdit, QHBoxLayout
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(parent=MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(parent=self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(510, 150, 75, 41))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(parent=self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(20, 10, 50, 50))
self.pushButton_2.setObjectName("pushButton_2")
self.label_2 = QtWidgets.QLabel(parent=self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(240, 10, 321, 41))
self.label_2.setStyleSheet("font: 63 11pt \"Yu Gothic UI Semibold\";")
self.label_2.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_2.setObjectName("label_2")
self.textBrowser = QtWidgets.QTextBrowser(parent=self.centralwidget)
self.textBrowser.setGeometry(QtCore.QRect(200, 150, 231, 41))
self.textBrowser.setObjectName("textBrowser")
self.spinBox = QtWidgets.QSpinBox(parent=self.centralwidget)
self.spinBox.setGeometry(QtCore.QRect(440, 150, 42, 41))
self.spinBox.setObjectName("spinBox")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(parent=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.pushButton.setText(_translate("MainWindow", "Составить"))
self.pushButton_2.setText(_translate("MainWindow", "PushButton"))
self.label_2.setText(_translate("MainWindow", "Составление магических квадратов"))
self.textBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt;\">Укажите порядок</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;\"><br /></p></body></html>"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec())
как это сделать, помоги плиз