def _postVisibilityChange(self, visible): """ Post a visibility changed event for the dock item. This method collapses the post on a timer and will not emit the event when the visibility temporarily toggles bettwen states. Parameters ---------- visible : bool True if the item was show, False if the item was hidden. """ area = self.rootDockArea() if area is not None and area.dockEventsEnabled(): vis_changed = self._vis_changed if vis_changed is None: timer = QTimer() timer.setSingleShot(True) timer.timeout.connect(self._onVisibilityTimer) self._vis_changed = (timer, visible) timer.start() else: timer, old_visible = vis_changed if old_visible != visible: self._vis_changed = None timer.stop()
def start_timer(self, name, duration, callback): log.debug('Starting %f sec. timer %s', duration, name) timer = QTimer() timer.timeout.connect(callback) timer.setSingleShot(True) timer.start(duration * 1e3) self._timers[name] = timer
def _default__band_timer(self): """ Create the default timer for the band state changes. """ timer = QTimer() timer.setSingleShot(True) timer.timeout.connect(self._on_band_timer) return timer
def start_timer(self, name, duration, callback): try: timer = QTimer() timer.timeout.connect(callback) timer.setSingleShot(True) timer.start(int(duration * 1e3)) self._timers[name] = timer except Exception as e: log.error( f'Attempt to start timer {name} with duration {duration} sec failed' ) raise
def __init__(self): self._reads = {} self._writes = {} self._notifiers = {} self._timer = QTimer() self._timer.setSingleShot(True) self._timer.timeout.connect(self.iterate) if QCoreApplication.instance() is None: # Application Object has not been started yet self.qApp = QCoreApplication([]) self._ownApp = True else: self.qApp = QCoreApplication.instance() self._ownApp = False self._blockApp = None posixbase.PosixReactorBase.__init__(self)
def alert(self, level, on=250, off=250, repeat=4, persist=False): """ Set the alert level on the dock item. This will override any currently applied alert level. Parameters ---------- level : unicode The alert level token to apply to the dock item. on : int The duration of the 'on' cycle, in ms. A value of -1 means always on. off : int The duration of the 'off' cycle, in ms. If 'on' is -1, this value is ignored. repeat : int The number of times to repeat the on-off cycle. If 'on' is -1, this value is ignored. persist : bool Whether to leave the alert in the 'on' state when the cycles finish. If 'on' is -1, this value is ignored. """ if self._alert_data is not None: self.clearAlert() app = QApplication.instance() app.focusChanged.connect(self._onAppFocusChanged) timer = QTimer() timer.setSingleShot(True) timer.timeout.connect(self._onAlertTimer) on, off, repeat = max(-1, on), max(0, off), max(1, repeat) self._alert_data = _AlertData(timer, level, on, off, repeat, persist) if on < 0: self.alerted.emit(level) else: self._onAlertTimer()