I have two windows in my code first I want to open class first() window which contains btn1. When I click btn1, I want to open a new window and replace it with my previous window (i.e. open new window in the current window itself) so upon clicking btn1, a new window of class second() is showing up which contains btn2. Now when I press btn2, I want to print "hi" on terminal but somehow the connect slot or something is not working. Can you please help me out? Here's my code
class first(loginWindow.Ui_MainWindow):
def __init__(self, MainWindow):
super(first, self).setupUi(MainWindow)
self.btn1.clicked.connect(self.loginFunc)
def loginFunc(self):
MainWindow.setAttribute(QtCore.Qt.WA_DeleteOnClose)
displayUi = second(MainWindow)
MainWindow.show()
class second(displayWindow.Ui_MainWindow):
def __init__(self, MainWindow2):
super(second, self).setupUi(MainWindow2)
self.btn2.clicked.connect(self.dispTable)
def dispTable(self):
print("hi")
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
loginUi = first(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
The first() and second() class inherit from other classes which are created from qt-designer tool.