How to close the current window and open new window if condition is true(without any button clicked) and run the hole script again. I have tried so many method but not success
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
.....
if __name__ == "__main__":
# print(deivce_data)
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
if deivce_data == data:
'''if this condition is true close the current window and run script again'''