Example #1
0
    def _ParentMovedOrResized(self):

        if self._float_mode:

            if HydrusData.TimeHasPassedFloat(self._last_move_event_occurred +
                                             1.0):

                self._last_move_event_started = HydrusData.GetNowFloat()

            self._last_move_event_occurred = HydrusData.GetNowFloat()

            # we'll do smoother move updates for a little bit to stop flickeryness, but after that we'll just hide

            NICE_ANIMATION_GRACE_PERIOD = 0.25

            time_to_delay_these_calls = HydrusData.TimeHasPassedFloat(
                self._last_move_event_started + NICE_ANIMATION_GRACE_PERIOD)

            if time_to_delay_these_calls:

                self._HideDropdown()

                if self._ShouldShow():

                    if self._move_hide_job is None:

                        self._move_hide_job = HG.client_controller.CallRepeatingWXSafe(
                            self._dropdown_window, 0.25, 0.0,
                            self._DropdownHideShow)

                    self._move_hide_job.Delay(0.25)

            else:

                self._DropdownHideShow()
Example #2
0
    def Wake(self, next_work_time=None):

        if next_work_time is None:

            next_work_time = HydrusData.GetNowFloat()

        self._next_work_time = next_work_time

        self._scheduler.WorkTimesHaveChanged()
Example #3
0
    def Work(self):

        SchedulableJob.Work(self)

        if not self._stop_repeating.is_set():

            self._next_work_time = HydrusData.GetNowFloat() + self._period

            self._scheduler.AddJob(self)
Example #4
0
    def __init__(self, controller, scheduler, initial_delay, work_callable):

        self._controller = controller
        self._scheduler = scheduler
        self._work_callable = work_callable

        self._next_work_time = HydrusData.GetNowFloat() + initial_delay

        self._work_lock = threading.Lock()

        self._currently_working = threading.Event()
        self._is_cancelled = threading.Event()
Example #5
0
    def __init__(self,
                 pausable=False,
                 cancellable=False,
                 only_when_idle=False,
                 only_start_if_unbusy=False,
                 stop_time=None,
                 cancel_on_shutdown=True):

        self._key = HydrusData.GenerateKey()

        self._creation_time = HydrusData.GetNowFloat()

        self._pausable = pausable
        self._cancellable = cancellable
        self._only_when_idle = only_when_idle
        self._only_start_if_unbusy = only_start_if_unbusy
        self._stop_time = stop_time
        self._cancel_on_shutdown = cancel_on_shutdown

        self._start_time = HydrusData.GetNow()

        self._deleted = threading.Event()
        self._deletion_time = None
        self._begun = threading.Event()
        self._done = threading.Event()
        self._cancelled = threading.Event()
        self._paused = threading.Event()

        self._yield_pause_period = 10
        self._next_yield_pause = HydrusData.GetNow() + self._yield_pause_period

        self._bigger_pause_period = 100
        self._next_bigger_pause = HydrusData.GetNow(
        ) + self._bigger_pause_period

        self._longer_pause_period = 1000
        self._next_longer_pause = HydrusData.GetNow(
        ) + self._longer_pause_period

        self._urls = []
        self._variable_lock = threading.Lock()
        self._variables = dict()
Example #6
0
    def Delay(self, delay):

        self._next_work_time = HydrusData.GetNowFloat() + delay

        self._scheduler.WorkTimesHaveChanged()
Example #7
0
    def MoveNextWorkTimeToNow(self):

        self._next_work_time = HydrusData.GetNowFloat()

        self._scheduler.WorkTimesHaveChanged()
Example #8
0
    def __repr__(self):

        return repr(self.__class__) + ': ' + repr(
            self._work_callable
        ) + ' next in ' + HydrusData.TimeDeltaToPrettyTimeDelta(
            self._next_work_time - HydrusData.GetNowFloat())