J
Your main window is a classroom. Main and those,
I'm sorry that you've pumped into it. Ui_Start♪The objects of this main window are as follows:self.lineEdit1 ... например, self.lineEdit1.text()
self.textEdit ... например, self.textEdit.setHtml("<b>Привет Мир</b>")
self.pushButton_2 ... например, self.pushButton_2.clicked.connect(self.onClicked)
self.pushButton ... например, self.pushButton.clicked.connect(self.uch)
On the button self.pushButton_2 You create another window.
And it will be an object. self.inst♪
Attributes to this facility are as follows:self.inst.textEdit ...
self.inst.text_inctru ...
On the button self.pushButton You create another window.
And it will be an object. self.uch♪
Attributes to this facility are as follows:self.uch.lineEdit ...
self.uch.pushButton ...
self.uch.pushButton_2 ...
self.uch.label ...
These other windows will be ОКНАМИ ♪ 'cause he sees
The one who doesn't have a parent will be a window.
To show these other KONAs you must fulfil
self.inst.show() or self.uch.show() respectively.from PyQt5 import QtCore, QtGui, QtWidgets
from ui_inst import Ui_Inst
from ui_uch import Ui_Uch
class Ui_Start(object):
def setupUi(self, Ui_Start):
Ui_Start.setObjectName("Ui_Start")
Ui_Start.resize(443, 293)
self.lineEdit1 = QtWidgets.QLineEdit(Ui_Start)
self.lineEdit1.setGeometry(QtCore.QRect(50, 80, 321, 51))
self.lineEdit1.setStyleSheet("")
self.lineEdit1.setText("")
self.lineEdit1.setObjectName("lineEdit")
self.textEdit = QtWidgets.QTextEdit(Ui_Start)
self.textEdit.setGeometry(QtCore.QRect(10, 30, 421, 41))
self.textEdit.setObjectName("textEdit")
self.pushButton_2 = QtWidgets.QPushButton(Ui_Start)
self.pushButton_2.setGeometry(QtCore.QRect(150, 210, 141, 58))
self.pushButton_2.setStyleSheet("font: 16pt \"Molot\";")
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton = QtWidgets.QPushButton(Ui_Start)
self.pushButton.setGeometry(QtCore.QRect(50, 140, 321, 58))
self.pushButton.setStyleSheet("font: 20pt \"Molot\";")
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Ui_Start)
QtCore.QMetaObject.connectSlotsByName(Ui_Start)
def retranslateUi(self, Ui_Start):
_translate = QtCore.QCoreApplication.translate
Ui_Start.setWindowTitle(_translate("Ui_Start", "Ui_Start"))
self.textEdit.setHtml(_translate("Ui_Start", "<!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:16pt;\">Введите номер и букву класса:</span></p></body></html>"))
self.pushButton_2.setText(_translate("Ui_Start", "инструкция"))
self.pushButton.setText(_translate("Ui_Start", "Найти класс"))
class MyInst(QtWidgets.QWidget, Ui_Inst):
def init(self, parent=None):
super(MyInst, self).init(parent)
self.setupUi(self)
class MyUch(QtWidgets.QWidget, Ui_Uch):
def init(self, parent=None):
super(MyUch, self).init(parent)
self.setupUi(self)
class Main(QtWidgets.QWidget, Ui_Start):
def init(self, parent=None):
super(Main, self).init(parent)
self.setupUi(self)
self.pushButton_2.clicked.connect(self.onClicked)
self.pushButton.clicked.connect(self.uch)
def onClicked(self):
self.inst = MyInst()
self.inst.show()
def uch(self):
self.uch = MyUch()
self.uch.show()
self.lineEdit2.setText("1") # у вас нет объета self.lineEdit2 !
self.uch.lineEdit.setText(self.lineEdit1.text()) # <<<-----<
StyleSheet = '''
QPushButton {
font: bold italic 16pt 'Comic Sans MS';
background-color: silver;
width: 75px ;
height: 50px;
border: none;
text-align: center;
}
QPushButton:hover {
background: #C9C0BB;
}
QPushButton:pressed {
background-color: blue;
}
'''
if name == "main":
import sys
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(StyleSheet)
file = QtCore.QFile("dark.qss")
file.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text)
stream = QtCore.QTextStream(file)
app.setStyleSheet(stream.readAll())
w = Main()
w.show()
sys.exit(app.exec_())