Note
The app package is experimental. Functionality and interface are still in flux and subject to change.
Bases: object
This class handles global application affairs. Among these are setting up a root node along with window size (and possibly screen resolution) and screen rotation, and creating an environment for the user’s MainDiv. Global user interface items such as a debug panel and keyboard manager are also set up. Additionally, App handles configuration settings and command line argument support.
App usually does not need to be subclassed. Instead, subclass MainDiv and pass an instance of the derived class to run().
An instance of debugpanel.DebugPanel.
DivNode that stands always on top of the MainDiv.
An instance of settings.Settings.
Dumps on the console the current number of initialized objects. Normally bound to the keypress CTRL-b.
Called just before starting the main loop (Player.play()). Useful only for subclassing. The display hasn’t been initialized at this point.
Starts the application using the provided mainDiv (an instance of MainDiv).
The optional additional kargs are used to set default settings - see settings.Settings.
Takes a screenshot of what is currently visible on the screen. Normally bound to the keypress CTRL-p. Screenshots are saved to the disk under the name ‘App-nnn.png’, where nnn is a sequence number.
Bases: libavg.avg.DivNode
This abstract class must be subclassed to write a libavg application. It is the main application entry point and should be the parent node for all application-created nodes. All the public methods are empty and don’t do anything if not overridden.
A version string. This is shown using the -v or --version command-line option.
This method is called after command-line arguments have been parsed and should be used to retrieve any application-specific options. The arguments options and args are the result of calling options, args = parser.parse_args(), where parser is an instance of optparse.OptionParser configured by calling onArgvParserCreated().
Called with an empty optparse.OptionParser instance. Allows the application to add additional command line options. App adds it’s own parameters as well. If this is overridden, onArgvParsed() should probably be overridden as well.
Called after the main loop exits. Release resources and run cleanups here.
Note
onExit() doesn’t get called if an exception is raised on the main thread.
Called every frame.
Called by a libavg timer as soon as the main loop starts. At this point in time, the window has been created and all render functions are available. Build the application node tree here.
Called before libavg has been setup, just after the App().run() call. The window has not been created at this time.
This module makes it possible to attach event handlers to individual keypresses. Keys that are bound through the keyboard manager are also be shown in the debug panel via the keyboard bindings widget along with their help string. libavg.app.App defines a range of keyboard bindings by default. The keyboardmanager is usually set up by libavg.app.App. libavg.app.App also reserves all keys modified by CTRL.
For all the binding methods, keystring can be a python string or a unicode object. Plain strings are matched to libavg.avg.KeyEvent.keystring, while unicode objects are matched to libavg.avg.KeyEvent.unicode. The modifiers are described under libavg.avg.KeyEvent.modifiers, with the additional modifiers KEYMOD_SHIFT, KEYMOD_CTRL and KEYMOD_ALT available to simplify checking for left and right modifier keys at one time.
Sets up a key handler so that handler is called whenever keystring is pressed.
Sets up a key handler so that handler is called whenever keystring is released.
Returns the currently assigned bindings as a list of named tuples.
Called by App. Should not be called by user programs.
Companion to push(), restores the non-modified key bindings previously pushed onto the stack via push().
Pushes all the non-modified key bindings onto a stack and clears them all. Useful when the application flow branches to a state where a different key bindings set is needed. The bindings can be then restored with pop().
Removes all the defined key bindings at once.
Removes a previously defined key binding for a KEY_DOWN event.
Removes a previously defined key binding for a KEY_UP event.
Simple user notification API to report information to the user
Bases: object
A FlashMessage is an easy way to show debug notification and similar text in the libavg window. The message can have an optional timeout or stay visible until clicked on by the user. It inserts itself into node tree at the top. Multiple FlashMessage instances are shown in the order they get created.
Parameters: |
|
---|