I have 2 windows: MainWindow and a normal window, I have a button in MainWindow that open the second window and I have a button in the second window, I want when clicked the button in the second window close the MainWindow. The two windows are in separate class and files.
This is the MainWindow
from select_company_controller import SelectCompany
from views.main_window_view import MainWindowForm
from PySide2 import QtWidgets, QtCore, QtGui
import sys
class MainWindow(QtWidgets.QMainWindow, MainWindowForm):
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
self.button.clicked.connect(self.open_select_company_window)
def open_select_company_window(self):
self.window = SelectCompany()
self.window.show()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.showMaximized()
sys.exit(app.exec_())
And this is the second window
from PySide2 import QtWidgets, QtCore, QtGui
from views.select_company_view import SelectCompanyForm
class SelectCompany(QtWidgets.QWidget, SelectCompanyForm):
def __init__(self):
super(SelectCompany, self).__init__()
self.setupUi(self)
self.button.clicked.connect(close_main_window)
def close_main_window(self):
pass