U
vi| @ s d dl Z d dlmZ d dlmZmZmZmZ d dlm Z mZ d dl
mZmZm
Z
ddlmZ edZe eZG d d
d
eZdS ) N) timedelta)AnyOptionalSetTypeVar)abctyping)CompositeDisposable
DisposableSingleAssignmentDisposable )PeriodicScheduler_TStatec s e Zd ZdZed fddZdeje e e e
jdddZdej
eje e e e
jd d
dZdejeje e e e
jd dd
Zdej
eje e e e
jdddZ ZS )QtSchedulerz+A scheduler for a PyQt5/PySide2 event loop.)qtcorec s t || _t | _dS )zCreate a new QtScheduler.
Args:
qtcore: The QtCore instance to use; typically you would get this by
either import PyQt5.QtCore or import PySide2.QtCore
N)super__init___qtcoreset_periodic_timers)selfr __class__ Y/opt/alt/python38/lib/python3.8/site-packages/reactivex/scheduler/mainloop/qtscheduler.pyr s
zQtScheduler.__init__N)actionstatereturnc C s | j d||dS )a! Schedules an action to be executed.
Args:
action: Action to be executed.
state: [Optional] state to be given to the action function.
Returns:
The disposable object used to cancel the scheduled action
(best effort).
g r )schedule_relative)r r r r r r schedule! s
zQtScheduler.schedule)duetimer r r c sx t dt|d }t ddd fdd}td| jj|| ddfd d
}t t
|S )au Schedules an action to be executed after duetime.
Args:
duetime: Relative time after which to execute the action.
action: Action to be executed.
state: [Optional] state to be given to the action function.
Returns:
The disposable object used to cancel the scheduled action
(best effort).
r @@FNr c s s _ d S N)Z
disposabler r is_disposedsadr r r r
invoke_actionE s z4QtScheduler.schedule_relative.