Package horizons :: Module extscheduler :: Class ExtScheduler
[hide private]
[frames] | no frames]

Class ExtScheduler

source code

The ExtScheduler is used for time based events that are not part of the simulation(gui, menu, scrolling). To start a timed callback, call add_new_object() to make the TimingThread Class create a CallbackObject for you.

Instance Methods [hide private]
 
__init__(self, pump) source code
 
tick(self)
Threads main loop
source code
 
add_object(self, obj)
Adds a new CallbackObject instance to the callbacks list
source code
 
add_new_object(self, callback, class_instance, run_in=1, loops=1)
Creates a new CallbackObject instance and calls the self.add_object() function.
source code
 
rem_all_classinst_calls(self, class_instance)
Removes all callbacks from the scheduler that belong to the class instance class_inst.
source code
 
rem_call(self, instance, callback)
Removes all callbacks of 'instance' that are 'callback'
source code
 
__del__(self) source code
Class Variables [hide private]
  NOOP = _ExtCallbackObject(lambda: 42* 1337-3.14, None)
Method Details [hide private]

__init__(self, pump)
(Constructor)

source code 
Parameters:
  • pump - pump list the scheduler registers itself with.

tick(self)

source code 

Threads main loop

Parameters:
  • tick_id - int id of the tick.

add_object(self, obj)

source code 

Adds a new CallbackObject instance to the callbacks list

Parameters:
  • object - CallbackObject type object, containing all necessary information

add_new_object(self, callback, class_instance, run_in=1, loops=1)

source code 

Creates a new CallbackObject instance and calls the self.add_object() function.

Parameters:
  • callback - function callback, which is called run_in time.
  • class_instance - class instance the function belongs to.
  • run_in - float number of seconds after which the callback is called. Standard is 1, run next second.
  • loops - How often the callback is called. -1 = infinite times. Standard is 1, run once.

rem_all_classinst_calls(self, class_instance)

source code 

Removes all callbacks from the scheduler that belong to the class instance class_inst.

Returns:
number of removed callbacks

rem_call(self, instance, callback)

source code 

Removes all callbacks of 'instance' that are 'callback'

Parameters:
  • instance - the instance that would execute the call
  • callback - the function to remove