MenuLink
- class pygame_menu.widgets.MenuLink(menu, menu_opener_handler, link_id='')[source]
Bases:
NoneWidget
Menu link widget; adds a link to another Menu. The behaviour is similar to a button, but this widget is invisible, and cannot be selectable.
Note
MenuLink does not accept any transformation.
- Parameters
- force_menu_surface_cache_update()
Forces menu surface cache to update after next drawing call. This also updates widget decoration.
Note
This method only updates the surface cache, without forcing re-rendering of all Menu widgets as
pygame_menu.widgets.core.widget.Widget.force_menu_surface_update()
does.- Return type
- Returns
Self reference
- force_menu_surface_update()
Forces menu surface update after next rendering call. This method automatically updates widget decoration cache as Menu render forces it to re-render.
This method also should be aclled by each widget after render.
Note
This method is expensive, as menu surface update forces re-rendering of all widgets (because them can change in size, position, etc…).
- Return type
- Returns
Self reference
- get_attribute(key, default=None)
Get an attribute value.
- get_col_row_index()
Get the Widget column/row position.
- get_controller()
Return the widget controller. Each widget has their own controller object.
- Return type
- Returns
Controller object
- get_counter_attribute(key, incr=0, default=0)
Get counter attribute.
- get_menu()
Return the Menu reference,
None
if it has not been set.
- get_scrollarea()
Return the scrollarea object.
- Return type
- Returns
ScrollArea object
- has_attribute(key)
Return
True
if the object has the given attribute.
- is_visible(check_frame=True)
Return
True
if the Widget is visible.
- on_remove_from_menu()
Function executed if the Widget is removed from the Menu.
- Return type
- Returns
Self reference
- remove_attribute(key)
Removes the given attribute from the object. Throws
IndexError
if the given key does not exist.- Parameters
key (
str
) – Key of the attribute- Return type
Base
- Returns
Self reference
- render()
Public rendering method.
Note
Unlike private
_render
method, public method forces widget rendering (callingpygame_menu.widgets.core.widget.Widget._force_render()
). Use this method only if the widget has changed the state. Running this function many times may affect the performance.Note
Before rendering, check out if the widget font/title/values are set. If not, it is probable that a zero-size surface is set.
- scroll_to_widget(margin=(0, 0), scroll_parent=True)
The container ScrollArea scrolls to the Widget.
- set_attribute(key, value=None)
Set an attribute.
- set_col_row_index(col, row, index)
Set the (column, row, index) position. If the column or row is
-1
then the widget is not assigned to a certain column/row (for example, if it’s hidden).
- set_controller(controller)
Set a new controller object.
- Parameters
controller (
Controller
) – Controller- Return type
- Returns
Self reference
- set_menu(menu)
Set the Widget menu reference.
- set_scrollarea(scrollarea)
Set scrollarea reference. Mostly used for events.
- Parameters
scrollarea (
Optional
[ScrollArea
]) – Scrollarea object- Return type
- shadow(*args, **kwargs)
Configure the widget shadow.
- Parameters
shadow_type – Shadow type, it can be rectangular or ellipse
shadow_width – Shadow width in px. If
0
the shadow is disabledcorner_radius – Shadow corner radius if rectangular in px
color – Shadow color
aa_amount – Antialiasing amout
- Return type
- Returns
Self reference