Package tdl :: Module event :: Class App
[frames] | no frames]

Class App

source code

object --+
         |
        App

Application framework.

Instance Methods
 
ev_QUIT(self, event)
Unless overridden this method raises a SystemExit exception closing the program.
source code
 
ev_KEYDOWN(self, event)
Override this method to handle a KeyDown event.
source code
 
ev_KEYUP(self, event)
Override this method to handle a KeyUp event.
source code
 
ev_MOUSEDOWN(self, event)
Override this method to handle a MouseDown event.
source code
 
ev_MOUSEUP(self, event)
Override this method to handle a MouseUp event.
source code
 
ev_MOUSEMOTION(self, event)
Override this method to handle a MouseMotion event.
source code
 
update(self, deltaTime)
Override this method to handle per frame logic and drawing.
source code
 
suspend(self)
When called the App will begin to return control to where App.run was called.
source code
 
run(self)
Delegate control over to this App instance.
source code
 
run_once(self)
Pump events to this App instance and then return.
source code
 
runOnce(*args, **kargs)
Deprecated version of the function run_once, you should prefer calling that function instead of this one.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

update(self, deltaTime)

source code 

Override this method to handle per frame logic and drawing.

Parameters:
  • deltaTime (float) - This parameter tells the amount of time passed since the last call measured in seconds as a floating point number.

    You can use this variable to make your program frame rate independent. Use this parameter to adjust the speed of motion, timers, and other game logic.

suspend(self)

source code 

When called the App will begin to return control to where App.run was called.

Some further events are processed and the App.update method will be called one last time before exiting (unless suspended during a call to App.update.)

run(self)

source code 

Delegate control over to this App instance. This function will process all events and send them to the special methods ev_* and key_*.

A call to App.suspend will return the control flow back to where this function is called. And then the App can be run again. But a single App instance can not be run multiple times simultaneously.

run_once(self)

source code 

Pump events to this App instance and then return.

This works in the way described in App.run except it immediately returns after the first update call.

Having multiple App instances and selectively calling runOnce on them is a decent way to create a state machine.