Menu

APP_MENU

Benedict Jäggi

APP_MENU.py

Go back [Home]

A "widely" used menu app with a default of 6 buttons to touch on.
Each button has a name and can call a given function.

Use the cMenu class to create your own menus or set the buttons of the actual selected menu directly.
A cMenu instance will be created at startup automatically and be set to the CURRENT_MENU.

Global Variables

buttonIndex

The index of the last button where it was touched on.
Use it to use the same button function on several buttons. Determine what to do with this index.

CURRENT_MENU

The actual shown and processed cMenu-instance.
Set it directly to another one to change the menu.


Functions

def setMenuItem(buttonIdx, menuTitle, menuFunc, color)

Calls setMenuItem on the CURRENT_MENU-instance.
See below for further information.


Classes

cMenu

A menu class. It has a default of 6 button items containing the text shown on the button and the function to be called.
Use x and y on creating the menu to use another button configuration,
e.g. myMenu = APP_MENU.cMenu(4,2) creates 4 buttons on 2 lines = 8 buttons with index 0 to 7.

cMenu: def setMenuItem(self, buttonIdx, menuTitle, menuFunc, color)

Set the button with index buttonIdx (0 to 5) to the given menuTitle and menuFunc.

buttonIdx is the index of the button. Ranges from 0 to 5.
menuTitle is the text shown on the corresponding button.
menuFunc is the function that gets called when the button is touched. (Without () )
color is the foreground color of the button. It can be ommitted. Default is ui.fgcol.

App(APP_BASE.BaseAppClass)

The App. See [APP_TEMPLATE] for further information.
Draws the buttons and calls their functions when touched on.

App: def update(self, screen, deltatime)

  • Draws the buttons. If the display is touched, it draws the touched button in inverted colors.
  • Checks if the mouse is over a button when ui.isMouseDown is True to select the color-inverted button.
  • Also checks, if UITools.showMsg is True. It then does nothing except for drawing the buttons.

App: def onMouseUp(self)

  • Checks, if mouse is released over a button and calls the corresponding button function then.

That's all folks. Go back [Home] to have a look on the other Apps.


Related

Wiki: APP_BASE
Wiki: APP_TEMPLATE
Wiki: Home
Wiki: UITools

MongoDB Logo MongoDB