Sep-18-2018, 02:09 PM
My program opens a main window with an investigation button, once that is clicked a second window opens and the first one is hidden.
The second window has a button and when it is clicked it is suppose to hide, however, it crashes.
If I run the second window by itself, not going through the first window, I can click the button and that window will hide. So I'm not sure why they're not working together.
Test.py
The second window has a button and when it is clicked it is suppose to hide, however, it crashes.
If I run the second window by itself, not going through the first window, I can click the button and that window will hide. So I'm not sure why they're not working together.
Test.py
from PyQt5 import QtCore, QtGui, QtWidgets from Test2 import * class Ui_MainWindow(object): def ipDombtn(self): self.window=QtWidgets.QMainWindow() self.ui=Ui_MainWindow1() self.ui.setup(self.window) self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(412, 440) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setObjectName("pushButton") self.verticalLayout.addWidget(self.pushButton) self.pushButton.clicked.connect(self.ipDombtn) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 412, 31)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(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", "Investigation")) 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_())Test2.py
from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow1(object): def exIpDomInv_clicked(self): print("You clicked a button...") def setup(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(412, 440) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.exIpDomInv = QtWidgets.QPushButton(self.centralwidget) self.exIpDomInv.setObjectName("exIpDomInv") self.verticalLayout.addWidget(self.exIpDomInv) MainWindow.setCentralWidget(self.centralwidget) self.Menu = QtWidgets.QMenuBar(MainWindow) self.Menu.setGeometry(QtCore.QRect(0, 0, 412, 31)) self.Menu.setObjectName("Menu") MainWindow.setMenuBar(self.Menu) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.exIpDomInv.clicked.connect(self.exIpDomInv_clicked) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "Investigation")) MainWindow.setAccessibleName(_translate("MainWindow", "InvestigationMenu")) self.exIpDomInv.setText(_translate("MainWindow", "External IP/ Domain Investigation")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) MainWindow1 = QtWidgets.QMainWindow() ui2 = Ui_MainWindow1() ui2.setup(MainWindow1) MainWindow1.show() sys.exit(app.exec_())