GLXBob.EventBus.
EventBus
[source]¶Bases: object
get_data
(key)[source]¶The get_data() method returns the Python object associated with the specified key or None if there is no data associated with the key or if there is no key associated with the object.
Parameters: | key (str) – a string used as the key |
---|---|
Returns: | a Python object that is the value to be associated with the key |
set_data
(key, data)[source]¶The set_data() method associates the specified Python object (data) with key.
Parameters: |
|
---|
connect
(detailed_signal, handler, *args)[source]¶The connect() method adds a function or method (handler)to the end of the list of signal handlers (yet a dict()) for the named detailed_signal but before the default class signal handler. An optional set of parameters may be specified after the handler parameter. These will all be passed to the signal handler when invoked.
Parameters: |
|
---|---|
Returns: | handler_id |
Return type: |
disconnect
(handler_id)[source]¶The disconnect() method removes the signal handler with the specified handler_id from the list of signal handlers for the object.
Parameters: | handler_id (int) – an int handler identifier |
---|---|
Raises: | TypeError – if handler_id parameter is not a int type |
handler_disconnect
(handler_id)[source]¶The handler_disconnect() method removes the signal handler with the specified handler_id from the list of signal handlers for the object.
Parameters: | handler_id (int) – an int handler identifier |
---|---|
Raises: | TypeError – if handler_id parameter is not a int type |
handler_is_connected
(handler_id)[source]¶The handler_is_connected() method returns True if the signal handler with the specified handler_id is connected to the object.
Parameters: | handler_id (int) – an int handler identifier |
---|---|
Returns: | True if handler_id is found on signal handlers list |
Return type: | True or False |
Raises: | TypeError – if handler_id parameter is not a int type |
handler_block
(handler_id)[source]¶The handler_block() method blocks the signal handler with the specified handler_id from being invoked until it is unblocked.
Parameters: | handler_id (int) – an int handler identifier |
---|---|
Raises: | TypeError – if handler_id parameter is not a int type |
handler_unblock
(handler_id)[source]¶Remove a handler_id from the blocked list
Parameters: | handler_id (int) – an integer handler identifier |
---|---|
Raises: | TypeError – if handler_id parameter is not a int type |
handler_block_by_func
(callable_object)[source]¶The handler_block_by_func() method blocks the all signal handler connected to a specific callable from being invoked until the callable is unblocked.
Parameters: | callable_object (callable) – the method or function it should be add on the blocked list |
---|---|
Raises: | TypeError – if callable_object parameter is not a callable type |
GLXBob.MainLoop.
Signal
(msg, original_exception, callback=None)[source]¶Bases: exceptions.Exception
Generic Signal exception for Galaxie-BoB
The tips consist to use the Exception module as class parent
GLXBob.MainLoop.
MainLoop
[source]¶Bases: object
Description: |
---|
The MainLoop
object is a Alderson loop , it’s something close to a
infinity loop but with a MainLoop.run()
and
MainLoop.quit()
method’s.
The MainLoop
make it work and take a adaptive sleep for impose a
global Frame Rate. Default: 25
That loop , should be a low power consumption, that was our target for the beginning.
Property’s Details: | |
---|---|
timer
¶The GLXBob.Timer() object is stored on that property
Type GLXBob.Timer()
Flags Read / Write Default value GLXBob.Timer()
is_running
()[source]Checks if the MainLoop
is currently being run via
MainLoop.run()
method.
Returns: | True if the MainLoop is currently being run. |
---|---|
Return type: | bool |
run
()[source]¶Run the MainLoop
until
MainLoop.quit()
is called on the loop.
If this is called for the thread of the loop’s, it will process events from the loop,
otherwise it will simply wait.
quit
()[source]¶Stops the MainLoop
from running. Any calls to
MainLoop.quit()
for the loop will return.
Note that sources that have already been dispatched when
MainLoop.quit()
is called will still be executed.
A MainLoop.quit()
call will certainly cause the end
of you programme.
set_timer
(timer=None)[source]¶Set the timer
property.
Buy default the MainLoop
class initialization will create
automatically a Timer
object then store it in the timer
property.
You can set you own Timer
object with it method.
Parameters: | timer (GLXBob.Timer) – a object initialize by you self or None for a self created
Timer |
---|
get_timer
()[source]¶Return the timer property value
Returns: | a object Timer ready to be requested |
---|---|
Return type: | GLXBob.Timer |
set_event_bus
(event_bus=None)[source]¶Set the event_bus
property.
By default the MainLoop
class initialization will create
automatically a EventBus
object then store it in the
event_bus
property.
You can set you own EventBus
object with it method.
That event_bus
property object is available via
MainLoop.get_event_bus()
Parameters: | event_bus (GLXBob.EventBus) – a object initialize by you self or None for a self created
EventBus |
---|
get_event_bus
()[source]¶Return the event_bus property value
Returns: | a object EventBus ready to be requested |
---|---|
Return type: | GLXBob.EventBus |
instance
= None¶GLXBob.Timer.
Timer
(fps=60.0, fps_max=inf, fps_min=1.0, fps_increment=0.1, fps_min_increment=0.1, fps_max_increment=10.0)[source]¶Bases: object
Parameters: |
|
---|---|
Property’s Details: | |
fps
¶The number of Frames per second. (in fps)
Note that not correspond exactly to a true movies or game FPS, it’s similar but it’s not.
For the Timer
Class, it correspond more about how many time 1 second
is divided.
The value
passed as argument to
Timer.set_fps()
method is clamped
to lie between fps_min
and fps_max
property’s.
Type float
Flags Read / Write Default value 25.0
fps_min
¶The min Frames number per second allowed before the Timer
stop to apply
a rate limit to the fps
property. (in fps)
It can be considered as the min value of the CLAMP process
Type float
Flags Read / Write Default value 2.0
fps_max
¶The maximum Frames number per second allowed before the Timer
start to rate
limit the fps
property.
It can be considered as the max value of the CLAMP process.
By default it have no limit fps_max = float(“inf”)
Type float
Flags Read / Write Default value float(“inf”)
fps_increment
¶The self-correcting timing algorithms will try to increase or decrease fps
property
with the fps_increment
property value.
Note: the fps_increment
property will be not clamped
Type float
Flags Read / Write Default value 0.1
fps_min_increment
¶fps_min_increment
is the lower allowed increment value
The self-correcting timing will try to adjust fps
property
in range of fps_min_increment
to fps_max_increment
Type float
Flags Read / Write Default value 0.1
fps_max_increment
¶fps_max_increment
is the upper allowed increment value
The self-correcting timing will try to adjust fps
property
in range of fps_min_increment
to fps_max_increment
Type float
Flags Read / Write Default value 0.1
SPEED_STEP_PERCENTAGE
= 10¶DEFAULT_BE_FAST_MULTIPLICATOR
= 10¶MIN_BE_FAST_MULTIPLICATOR
= 0¶Description: |
---|
The Timer
object contain a self-correcting timing algorithms.
That self-correcting timing algorithms have associated property’s it permit to control the
Timer
object.
The power saving happen that because the loop try to use the minimum
The Timer
object update value itself and can be requested, via internal method’s.
tick
()[source]¶Return True
or False
“when necessary” , that mean according with all the self-correcting
timing algorithms and they configuration property’s
timer = Timer()
while True:
# Do stuff that might take significant time here
if timer.tick():
print('Hello World!')
Returns: | True when it’s time or False if a adjustment job of fps property
should be done |
---|---|
Return type: | bool |
get_time
()[source]¶Time should be take as a serious thing, you should try to impose only one time source in you program, then the
Timer
Class provide it own method for get the time by it self.
Returns: | Unix time |
---|---|
Return type: | int |
set_fps
(fps=25.0)[source]¶Parameters: | fps (float) – Frames number per second. (in fps) |
---|---|
Raises: | TypeError – if fps parameter is not a float type |
get_fps
()[source]¶Get the Timer
fps
property value.
Returns: | fps property value. (in fps) |
---|---|
Return type: | float |
set_fps_min
(fps_min=0.1)[source]¶Set the Timer
fps_min
property value.
It correspond to a imposed minimal amount of frame rate
Returns: | fps_min property value. (in fps) |
---|---|
Return type: | float |
Raises: | TypeError – if fps_min parameter is not a float type |
get_fps_min
()[source]¶Get the Timer
fps_min
property value.
Returns: | fps_min property value. (in fps) |
---|---|
Return type: | float |
set_fps_max
(max_fps=None)[source]¶Set the Timer
fps_max
property value.
It correspond to a imposed max amount of frame rate used during acceleration phase
Parameters: | max_fps (float or None ) – fps_max property value. (in fps) |
---|---|
Raises: | TypeError – if max_fps parameter is not a float type |
get_fps_max
()[source]¶Get the Timer
fps_max
property value.
Returns: | fps_max property value. (in fps) |
---|---|
Return type: | float |
set_fps_increment
(fps_increment=0.1)[source]¶Set the Timer
fps_increment
property.
The self-correcting timing algorithms will try to increase or decrease fps_increment
property
with it step increment.
Parameters: | fps_increment (float) – Frames number per second. (in fps) |
---|---|
Raises: | TypeError – if fps_increment parameter is not a float type |
get_fps_increment
()[source]¶Get the Timer
fps_increment
property value.
Returns: | fps_increment property value. (in fps) |
---|---|
Return type: | float |
set_fps_min_increment
(fps_min_increment=0.1)[source]¶Set the Timer
fps_min_increment
increment.
The algorithms will try to increase or decrease fps
property with
fps_increment
as step .
For fast limit rate stabilization the Timer
can use fps_min_increment
and fps_max_increment
property for make a gap in contain in a range, where
fps_min_increment
will force a minimal amount of increment and
fps_max_increment
will force a maximal amount of increment.
Parameters: | fps_min_increment (float) – Frames number per second. (in fps) |
---|---|
Raises: | TypeError – if fps_min_increment parameter is not a float type |
get_fps_min_increment
()[source]¶Get the smaller of step increment
The Timer
fps_min_increment
property value.
See Timer.set_fps_min_increment()
for more information’s
Returns: | fps_min_increment property value. (in fps) |
---|---|
Return type: | float |
set_fps_max_increment
(fps_max_increment=1.0)[source]¶Set the Timer
fps_max_increment
increment.
The self-correcting timing algorithms will try to increase or decrease fps
property with
fps_increment
as step .
For fast limit rate stabilization the Timer
can use fps_min_increment
and fps_max_increment
for make gap in a increment range, where fps_max_increment
will
fixe the limit .
Parameters: | fps_max_increment (float) – Frames number per second. (in fps) |
---|---|
Raises: | TypeError – if fps_max_increment parameter is not a float type |
get_fps_max_increment
()[source]¶Get the bigger of step increment
Get the Timer
fps_max_increment
property value.
Returns: | fps_max_increment property value. (in fps) |
---|---|
Return type: | float |