When I close an application window in PyQt the console is still left running in the background and python.exe process is present until I close the console. I think the sys.exit(app.exec_())
is not able to operate properly.
Mainscript (which opens Firstwindow):
if __name__ == '__main__':
from firstwindow import main
main()
Firstwindow
On button press:
self.close() #close firstprogram
Start() #function to open mainprogram
Start():
def Start():
global MainWindow
MainWindow = QtWidgets.QMainWindow()
ui = genui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
main() (suggested here):
def main_window():
return form
def main():
global form
app = QtWidgets.QApplication(sys.argv)
form = MyApp()
form.show()
app.exec_()
sys.exit(app.exec_())