def closeDialog(self, close): """ :param close: False => Close only the Dialog True => Close the entire Application :return: None """ self.lineEdit_identity.setText("Closing ...") """ Without QTest.qWait(10) the precedent line is ignored ! Pause to show the MsgDialog closing sequence. """ if PYSIDE2: time.sleep(10 / 1000) # [s] (ms >= 10) Process events while waiting else: QTest.qWait(10) # [ms] # # if not close: # Close only Dialog v.close_button = "" # Reset references to QPushButtons v.yes_button = "" v.no_button = "" self.close() else: # Close GeoAnalyzer print("MsgDialog.closeDialog returned: Program terminated") QtWidgets.QApplication.instance( ).quit # See /home/lorenzo/Python3/PyQt5/examples/widgets/tetrix.py sys.exit()
def qWaitForWindowExposed(self, window, timeout=None): """Waits until the window is shown in the screen. See QTest.qWaitForWindowExposed for details. """ result = qWaitForWindowExposedAndActivate(window, timeout) if self.TIMEOUT_WAIT: QTest.qWait(self.TIMEOUT_WAIT) return result
def qWait(cls, ms=None): """Waits for ms milliseconds, events will be processed. See QTest.qWait for details. """ if ms is None: ms = cls.DEFAULT_TIMEOUT_WAIT if qt.BINDING == 'PySide2': # PySide2 has no qWait, provide a replacement timeout = int(ms) endTimeMS = int(time.time() * 1000) + timeout qapp = qt.QApplication.instance() while timeout > 0: qapp.processEvents(qt.QEventLoop.AllEvents, maxtime=timeout) timeout = endTimeMS - int(time.time() * 1000) else: QTest.qWait(int(ms) + cls.TIMEOUT_WAIT)