U vi@szddlZddlmZmZmZmZmZddlmZmZddl m Z m Z m Z ddl mZedZedZGd d d eZdS) N)AnyOptionalSetTypeVarcast)abctyping)CompositeDisposable DisposableSingleAssignmentDisposable)PeriodicScheduler_TStateZRxcseZdZdZeddfdd ZddddZdejej e e e e e jd d d Zdeje e e e jd ddZdejeje e e e jdddZdejeje e e e jdddZdejeje e e e jdddZZS) WxSchedulerz&A scheduler for a wxPython event loop.N)wxreturncs:t||_|jj}Gddd|}||_t|_dS)zCreate a new WxScheduler. Args: wx: The wx module to use; typically, you would get this by import wx cs4eZdZejddfdd ZddddZZS)z#WxScheduler.__init__..TimerN)callbackrcst||_dSN)super__init__r)selfr __class__Y/opt/alt/python38/lib/python3.8/site-packages/reactivex/scheduler/mainloop/wxscheduler.pyr"s z,WxScheduler.__init__..Timer.__init__rcSs |dSr)r)rrrrNotify&sz*WxScheduler.__init__..Timer.Notify)__name__ __module__ __qualname__rActionrr __classcell__rrrrTimer!sr"N)rr_wxr" _timer_classset_timers)rrZ timer_classr"rrrrs  zWxScheduler.__init__rcCs|jD] }|qdS)zCancel all scheduled actions. Should be called when destroying wx controls to prevent accessing dead wx objects in actions that might be pending. N)r&Stoprtimerrrr cancel_all,s zWxScheduler.cancel_allF)timeactionstateperiodicrcstddfdd }tdt|d}td||jrnj | dnjj j | dj ddfdd }t t|S) Nrcs6rttjtnttjt_dSr)rrScheduledPeriodicActionrScheduledAction disposabler)r,r.sad schedulerr-rrinterval@s z/WxScheduler._wxtimer_schedule..intervalg@@ztimeout wx: %s)ZoneShotcsjdSr)r'r&removerr(rrdisposeUsz.WxScheduler._wxtimer_schedule..dispose)r maxintZ to_secondslogdebugr$r#Z IsMainThreadZStart CallAfterr&addr r )rr+r,r-r.r4msecsr7r)r,r.r2r3rr-r)r_wxtimer_schedule5s     zWxScheduler._wxtimer_schedule)r,r-rcsPtdddfdd }j|ddfdd }tt|S)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). FNrcss_dSr)r1rr, is_disposedr2rr-rr invoke_actionksz+WxScheduler.schedule..invoke_actioncsddS)NTrr)rArrr7qsz%WxScheduler.schedule..dispose)r r#r<r r )rr,r-rBr7rr@rschedule[s  zWxScheduler.schedule)duetimer,r-rcCs|j|||dS)auSchedules 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-r?rrDr,r-rrrschedule_relativewszWxScheduler.schedule_relativecCs ||}|j||j||dS)aoSchedules an action to be executed at duetime. Args: duetime: Absolute time at 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). rE) to_datetimer?nowrGrrrschedule_absolutes zWxScheduler.schedule_absolute)periodr,r-rcCs|j|||ddS)aSchedules a periodic piece of work to be executed in the loop. Args: period: Period in seconds for running the work repeatedly. 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). T)r-r.rF)rrLr,r-rrrschedule_periodicszWxScheduler.schedule_periodic)NF)N)N)N)N)rrr__doc__rrr*rZAbsoluteOrRelativeTimeZScheduledSingleOrPeriodicActionrrboolrZDisposableBaser?r0rCZ RelativeTimerHZ AbsoluteTimerKr/rMr!rrrrrsN  '   r)loggingrrrrrrZ reactivexrZreactivex.disposabler r r Zperiodicschedulerr r getLoggerr:rrrrrs