OpenGLContext.events.timer
EventManager providing vcr-like control of an InternalTime object
Classes
class Timer(
EventManager
):
Event manager providing VCR-like control of an InternalTime
Timer objects are currently the only end-user friendly
timing mechanism available within OpenGLContext. They
provide simple VCR-like control of an InternalTime.
This allows the Timer to run forward, backward, fast,
slow, pause, or resume. The class allows you to register
for events (fractional, cyclic or one-shot) as normal
for eventmanager classes.
Attributes:
timerClass -- the class of InternalTime object used
active -- Boolean flag indicating whether we are
"active", that is, whether we are currently
advancing through the internal time.
internal -- the instantiated InternalTime object we
are using to implement ourselves
active
Delegate to internal
__init__(
self
,
*
arguments
,
**
namedarguments
)
Initialize the Timer
arguments, namedarguments -- passed directly to
our timerClass to instantiate the InternalTime.
See documentation on InternalTime for details.
_doAndDispatch(
self
,
function
,
realTime
,
*
arguments
,
**
namedarguments
)
Internal function to get and dispatch events from internal function
- function
- the internaltime method which will generate the events
- realTime
- external time passed to the internal time, if absent will use systemtime.systemTime()arguments, namedarguments -- passed to the function after realTime
addEventHandler(
self
,
timetype
= 'fraction'
,
function
= None
)
Add/remove handler for the given timetype from this Timer object
- timetype
- string value describing the event type, currently valid types are: "start" "stop" "resume" "pause" "cycle" "fraction" see the timeevents module for description of the individual types.
- function
- callback function taking single argument, a Context time event
deregister(
self
,
context
)
De-register this timer with a given context's time event manager
See:
timeeventgeneratormanager.TimeEventGeneratorManager
poll(
self
,
realTime
= None
)
Poll the internal timer for pending events
Returns the number of events dispatched
ProcessEvent(
self
,
event
)
Dispatch an incoming event
This sub-class sets the Timer as the sender of the
messages.