예제 #1
0
    def _close_open_dialogs(self):
        """ Close Giswater open dialogs """

        # Get all widgets
        allwidgets = QApplication.allWidgets()

        # Only keep Giswater widgets that are currently open
        windows = [
            x for x in allwidgets
            if not getattr(x, "isHidden", False) and (issubclass(
                type(x), GwMainWindow) or issubclass(type(x), GwDialog))
        ]

        # Close them
        for window in windows:
            try:
                tools_gw.close_dialog(window)
            except Exception as e:
                print(f"Exception in _close_open_dialogs: {e}")