Menu

UI_LIST

Benedict Jäggi

UI_LIST

Import from appdata/CodeLibs/UI/UI_LIST.py

With UI_LIST you can make scrollable listboxes (UI_LISTBOX) with customizable content.

First create an instance of UI_LISTBOX.
Create instances of UI_LIST_ITEM and add one or more UI_ELEMENTs to them. Then add the UI_LIST_ITEMs to the listbox.
Define the content of each UI_LIST_ITEM with one or more UI_ELEMENTs
If the text of an UI_ELEMENT is longer than the width of the UI_LIST_ITEM/UI_LIST it belongs to,
it will scroll sidewards.

The Music Player uses a UI_LIST for reference.

UI_LISTBOX

Create an instance of this and update it in your update call.
Add UI_LIST_ITEMS (containing UI_ELEMENTS) to the created listbox.

_ _ init _ _ (self, promilleposx, promilleposy, promillewidth, promilleheight, orientation, pixelsitemheight, fgcol,bgcol)

Called when an instance is created.

  • promilleposx, promilleposy: The position of the listbox on the screen in promille.
  • promillewidth, promilleheight: The size of the listbox on the screen in promille.
  • orientation: The orientation on the screen. (0-3) Default: -1 - take the default orientation.
  • pixelsitemheight: The default height of a list item in pixels. Default: 100
  • fgcol, bgcol: The foreground and background color of this listbox. Default: UITools.fgcol, UITools.bgcol

clearItems(self)

Removes all items from the list.

addItem(self, item: UI_LIST_ITEM)

Add a UI_LIST_ITEM to the listbox.

update(self, screen, deltatime)

Call this in your update function when you want to show and process the listbox.

UI_LIST_ITEM

An item which can be added to a UI_LISTBOX-instance, with some UI_ELEMENTS to show and a function to be called with a value when the item is clicked on.

_ _ init _ _ (self, func, value, text)

The constructor function, called when the UI_LIST_ITEM is created.
It maybe adds one UI_ELEMENT with the given text to it.

  • func: The function to call when clicked on. Default: 0
  • value: Maybe the function needs a value. This is it. Default: 0
  • text: The added UI_ELEMENT will show this text on the list item. Default: "@NotSet@"

If text is set, then the UI_ELEMENT will be created on position 500, 500 (centered), else no UI_ELEMENT will be created and they have to be added "manually".

createElement(self, textorpath, promillex, promilley, typ)

Creates an UI_ELEMENT with the given textorpath on the position promillex, promilley and adds it to this UI_LIST_ITEM-instance.

  • textorpath: The text to be shown or the path to the image if typ is "image".
  • promillex, promilley: The position on the list item in promille.
  • typ: "text" for text, "image" for image. NOT IMPLEMENTED YET.

addElement(self, element: UI_ELEMENT)

You do NOT need to use this if you add UI_ELEMENTS with createElement.
Else, add your element to the list item with this function.

UI_ELEMENT

An UI_ELEMENT is a graphical element on a UI_LIST_ITEM. It can have a text to be shown with the type "text" or a path to an image to be shown with the type "image".

_ _ init _ _ (self, textorpath, promilleposx, promilleposy, typ)

The constructor function, called when the UI_ELEMENT is created. Don't forget to add it to the right UI_LIST_ITEM.

  • textorpath: The text to be shown or the path to the image to be shown.
  • promillex, promilley: The position on the UI_LIST_ITEM in promille.
  • typ: The type of the UI_ELEMENT. Can be "text" or "image" (not implemented yet). Default: "text"

setAnchor(self, anchorx, anchory)

Set the anchor of the UI_ELEMENT.
0 = centered
1 = left/up
-1 = right/down


Related

Wiki: Home

MongoDB Logo MongoDB