Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Here is an example of aggregation in python in this case i can't use inheritanceimport os
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtCore import Qt
class EnterName(QWidget):
text_value = pyqtSignal(str)
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 300, 50)
self.setWindowTitle('Введите имя')
self.button = QPushButton('Сохранить', self)
self.button.clicked.connect(self.bEvent)
self.button.move(120, 30)
self.lEdid = QLineEdit(self)
self.lEdid.setGeometry(0, 0, 300, 30)
@pyqtSlot()
def bEvent(self):
self.text_value.emit(self.lEdid.text())
self.hide()
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 420, 280)
self.setWindowTitle('Exsample')
self.setWindowModality(Qt.WindowModal)
self.button = QPushButton('Имя', self)
self.button.move(180, 260)
self.button.clicked.connect(self.bEvent)
self.tb = QTextBrowser(self)
self.tb.setGeometry(0, 0, 420, 260)
self.eName = EnterName()
self.eName.text_value.connect(self.signalHandler)
def bEvent(self):
self.eName.show()
def signalHandler(self, text):
self.tb.append(text)
if __name__ == '__main__':
app = QApplication(sys.argv)
example = Example()
example.show()
sys.exit(app.exec_())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question