Menu

APP_BASE

Benedict Jäggi

APP_BASE.py

Go back [Home]

This is the main system file which has to be imported "everywhere": In the App files and in the [MAIN] file.
It provides the basic functionalities of this system and the base application class where all Apps are derived from.

Internal used variables and functions are described at the end of this page.


Global Variables

HOME_PATH

The FULL path to the MAIN.py script and all other scripts provided here.
Used for saving and loading stuff from and to the userdata and appdata directories.
Needs a / at the end: HOME_PATH="/mypath/"

underlyingApp

The internal name of the App to be called when an (other) App gets closed.


Functions

def registerApplication(appname, appinstance)

Use that function to register an instance of an App into the system.

appname is the (internal) name to be referenced to. Usually the file name without ".py"
appinstance is an instance to your App. Usually myAppFile.App() where myAppFile is the name of the file where your App resides.

If you want to RESTART an App completely, just use registerApplication again with a new instance of your App.

def setCurrentApp(appname)

Switches to the App with the given appname or to a new BaseAppClass-instance if not found. It then shows the empty application screen.

def setCurrentApplication / setApplication / setApp (appname)

Other names to call SetCurrentApp.

def initialize()

Initialize the system. Needs to be called in [MAIN] just before the main loop.

def update()

Updates the whole system (and the actual running App).
Call this inside the main loop. (See at the end of [MAIN])
Returns True when running and False when exiting the program.

def quit()

Ends the program.
Call this at the very end of [MAIN].


Classes

BaseAppClass

The basic App class which provides the functions used by this system.
Derive your App-class from that class.
You may overwrite all of the functions except for the __initialize__ (with lower case - ) function.
See [APP_TEMPLATE] for further information.


INTERNAL USED STUFF

This is just here for reference. DO NOT USE, itŝ already used by the system itself.

screensurface

The pygame display surface used for drawing directly to the screen.
Passed to the update function of an App.

applicationList

The array containing the Application instances with their internal names.

CURRENT_APP

The current running App(-instance).

deltaTime

The time passed since the last frame in seconds
This variable is passed to the current running Apps update function, so you don't have to use it directly.

deltaOldTime

The time stamp of the frame previous to the last one.
Used to calculate deltaTime.

def updateDeltaTime()

Called in APP_BASE.update after each frame. Counts the time passed since the last frame in seconds and sets it to APP_BASE.deltaTime.


Do you want to create your very own menu App? Because that is the next section: [APP_MENU]


Related

Wiki: APP_MENU
Wiki: APP_TEMPLATE
Wiki: Home
Wiki: MAIN
Wiki: UITools

MongoDB Logo MongoDB