pyplanet.core.ui¶
- class pyplanet.core.ui.template.Template(file)[source]¶
Template class manages the template file source and the rendering of it.
Will also take care of the loader of the Jinja2 template engine.
Some notable prefixes:
core.views:
pyplanet.views.templates
.core.pyplanet:
pyplanet.apps.core.pyplanet.templates
.core.maniaplanet:
pyplanet.apps.core.pyplanet.templates
.core.trackmania:
pyplanet.apps.core.trackmania.templates
.core.shootmania:
pyplanet.apps.core.shootmania.templates
.[app_label]:
[app path]/templates
.
- class pyplanet.core.ui.AppUIManager(instance, app)[source]¶
The App UI manager is here to maintain the context of the app and have it destroy all the listeners when the app is unloaded.
The UI Properties will be set and hold in the class definition bellow.
- class pyplanet.core.ui.ui_properties.UIProperties(instance)[source]¶
Set the custom Script UI Properties.
Tip
Look at the possible UI Properties right here:
Trackmania: https://github.com/maniaplanet/script-xmlrpc/blob/master/XmlRpcListing.md#trackmaniauisetproperties
Shootmania: https://github.com/maniaplanet/script-xmlrpc/blob/master/XmlRpcListing.md#shootmaniauisetproperties
TM2020: Undocumented by Nadeo, check in-game tool OpenPlanet and discover what properties exist and what it means.
Access this class with:
self.instance.ui_manager.properties
- get_attribute(element: str, attribute: str, default=<object object>)[source]¶
Get an attribute value of an element.
- Parameters:
element – Element name
attribute – Attribute name
default – Default if not found.
- Returns:
Boolean if it’s set correctly.
- get_visibility(element: str, default=<object object>)[source]¶
Set the visibility of the UI Property and don’t complain about failing to set. Must be set at the start of the app(s).
- Parameters:
element – Element name, such as notices, map_info and chat. Full list: https://github.com/maniaplanet/script-xmlrpc/blob/master/XmlRpcListing.md#shootmaniauisetproperties
default – The default value, or an exception if not given.
- Returns:
The boolean if it’s visible or raise exception if not exists (or the default if default is given).
- set_attribute(element: str, attribute: str, value)[source]¶
Set an attribute of an element and silent if it’s not found. Useful to change positions but unsure if it will and still exists. Returns boolean if it’s set successfully.
- Parameters:
element – Element name
attribute – Attribute name
value – New value of the attribute.
- Returns:
Boolean if it’s set correctly.
- set_visibility(element: str, visible: bool)[source]¶
Set the visibility of the UI Property and don’t complain about failing to set. Must be set at the start of the app(s).
- Parameters:
element – Element name, such as notices, map_info and chat. Full list: https://github.com/maniaplanet/script-xmlrpc/blob/master/XmlRpcListing.md#shootmaniauisetproperties
visible – Boolean if the element should be visible.
- Returns:
Boolean, true if is set, false if failed to set.
- class pyplanet.core.ui.components.DynamicManiaLink(id)[source]¶
The DynamicManiaLink is a special manialink with data-bindings and automatically updates via maniascript. Please use the
View
classes instead!Warning
This feature is not yet implemented.
- async destroy()¶
Destroy the Manialink with it’s handlers and references. Will also hide the Manialink for all users!
- destroy_sync()¶
Destroy the Manialink with it’s handlers and references. Will also hide the Manialink for all users!
This method is sync and will call a async method (destroying of the manialink at our players) async but will not be executed at the same time. Be aware with this one!
- async display(player_logins=None, **kwargs)¶
Display the manialink. Will also render if no body is given. Will show per player or global. depending on the data given and stored!
- Parameters:
player_logins – Only display to the list of player logins given.
- async handle_catch_all(player, action, values, **kwargs)¶
Override this class to handle all other actions related to this view/manialink.
- Parameters:
player – Player instance.
action – Action name/string
values – Values provided by the user client.
kwargs –
- async hide(player_logins=None)¶
Hide manialink globally of only for the logins given in parameter.
- Parameters:
player_logins – Only hide for list of players, None for all players on the server.
- async render(player_login=None, data=None, player_data=None, template=None)¶
Render template. Will render template and return body.
- Parameters:
player_login – Render data only for player, set to None to globally render (and ignore player_data).
data – Data to append.
player_data – Data to append.
template (pyplanet.core.ui.template.Template) – Template instance to use.
- Returns:
Body, rendered manialink + script.
- subscribe(action, target)¶
Subscribe to a action given by the manialink.
- Parameters:
action – Action name.
target – Target method.
- Returns:
- class pyplanet.core.ui.components.StaticManiaLink(manager=None, id=None, version='3', body=None, template=None, timeout=0, hide_click=False, data=None, player_data=None, disable_alt_menu=False, throw_exceptions=False, relaxed_updating=False)[source]¶
The StaticManiaLink is mostly used in PyPlanet for general views. Please use the
View
classes instead of this core ui component!- async destroy()¶
Destroy the Manialink with it’s handlers and references. Will also hide the Manialink for all users!
- destroy_sync()¶
Destroy the Manialink with it’s handlers and references. Will also hide the Manialink for all users!
This method is sync and will call a async method (destroying of the manialink at our players) async but will not be executed at the same time. Be aware with this one!
- async display(player_logins=None, **kwargs)¶
Display the manialink. Will also render if no body is given. Will show per player or global. depending on the data given and stored!
- Parameters:
player_logins – Only display to the list of player logins given.
- async handle_catch_all(player, action, values, **kwargs)¶
Override this class to handle all other actions related to this view/manialink.
- Parameters:
player – Player instance.
action – Action name/string
values – Values provided by the user client.
kwargs –
- async hide(player_logins=None)¶
Hide manialink globally of only for the logins given in parameter.
- Parameters:
player_logins – Only hide for list of players, None for all players on the server.
- async render(player_login=None, data=None, player_data=None, template=None)¶
Render template. Will render template and return body.
- Parameters:
player_login – Render data only for player, set to None to globally render (and ignore player_data).
data – Data to append.
player_data – Data to append.
template (pyplanet.core.ui.template.Template) – Template instance to use.
- Returns:
Body, rendered manialink + script.
- subscribe(action, target)¶
Subscribe to a action given by the manialink.
- Parameters:
action – Action name.
target – Target method.
- Returns:
- exception pyplanet.core.ui.exceptions.ManialinkMemoryLeakException[source]¶
Is thrown when a memory leak is detected in a view. Raised when a manialink responds to a view, but the view is vanished for the specified player(s).