from PyQt5 import QtWidgets from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QDialog, QTreeView, QFileSystemModel from PyQt5.QtCore import QModelIndex import sys class MyWindow(QWidget): def __init__(self): super(MyWindow, self).__init__() self.setGeometry(200, 200, 300, 300) self.initUI() def initUI(self): self.b1 = QtWidgets.QPushButton(self) self.b1.setText("First") self.b1.clicked.connect(self.openSecondDialog) self.b1.setGeometry(30, 130, 100, 30) class SecondDialog(MyWindow): def __init__(self): super(SecondDialog, self).__init__() def openSecondDialog(self): self.myDialog = QDialog(self) self.myDialog.setGeometry(600, 100, 500, 500) self.b2 = QtWidgets.QPushButton(self) self.b2.setText("Second") self.myDialog.show() def window(): app = QApplication(sys.argv) win = SecondDialog() win.show() sys.exit(app.exec_()) window()
In this code, I have a window that has one button named First. When I press it, the second window appears. The problem that I am facing is to put the second button in the second window but it is not appearing in it. I made two classes to add other features in another window separately.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)