Algo mas o menos así
Código Python:
Ver originalimport sys
from PyQt4 import QtGui, QtCore
class ChildWindow(QtGui.QWidget):
def __init__(self, name=None):
super(ChildWindow, self).__init__()
self.name = name
self.initUI()
def initUI(self):
btn1 = QtGui.QPushButton("%s" % self.name, self)
btn1.move(30, 50)
self.setGeometry(300, 300, 250, 180)
self.setWindowTitle('Child Window %s' % self.name)
self.show()
class MainWindow(QtGui.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.children = []
self.initUI()
def initUI(self):
btn1 = QtGui.QPushButton("Start", self)
btn1.move(30, 50)
self.le = QtGui.QLineEdit(self)
self.le.move(30, 20)
btn1.clicked.connect(self.buttonClicked)
self.setGeometry(300, 300, 290, 150)
self.setWindowTitle('Multiple windows example')
self.show()
def buttonClicked(self):
child = ChildWindow(name=self.le.text())
self.children.append(child)
def main():
app = QtGui.QApplication(sys.argv)
main_window = MainWindow()
sys.exit(app.exec_())
if __name__ == '__main__':
main()