pygame-menu Logo
4.1.3

First steps

  • Creating menus
  • Adding widgets
  • Adding sounds
  • Creating themes
  • Gallery / Examples

Advanced usage

  • Package organization
  • Create a widget
  • Create a selection effect
  • Decorate a Menu / Widgets
  • Widget selection effects

Menu APIs

  • BaseImage
  • ScrollArea

Widgets API

  • Button
  • ColorInput
  • DropSelect
  • DropSelectMultiple
  • Frame
  • HMargin
  • Image
  • Label
  • MenuBar
  • MenuLink
  • NoneWidget
  • ProgressBar
  • RangeSlider
  • ScrollBar
  • Selector
  • SurfaceWidget
  • Table
  • TextInput
  • ToggleSwitch
  • VMargin

About pygame-menu

  • License
  • Contributors

Migration Guides

  • Migration Guide - v2 to v3
  • Migration Guide - v3 to v4
pygame-menu
  • »
  • MenuLink
  • Edit on GitHub

MenuLink¶

class pygame_menu.widgets.MenuLink(menu, menu_opener_handler, link_id='')[source]¶

Bases: pygame_menu.widgets.widget.none.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
  • link_id (str) – Link ID

  • menu_opener_handler (Callable) – Callback for opening the menu object

  • menu (Menu) – Menu object

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

Widget

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.

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

Widget

Returns

Self reference

get_attribute(key, default=None)¶

Get an attribute value.

Parameters
  • key (str) – Key of the attribute

  • default (Optional[Any]) – Value if does not exists

Return type

Any

Returns

Attribute data

get_class_id()¶

Return the Class+ID as a string.

Return type

str

Returns

Class+ID format

get_col_row_index()¶

Get the Widget column/row position.

Return type

Tuple[int, int, int]

Returns

(column, row, index) tuple

get_counter_attribute(key, incr=0, default=0)¶

Get counter attribute.

Parameters
  • key (str) – Key of the attribute

  • incr (Any) – Increase value

  • default (Any) – Default vale to start with, by default it’s zero

Return type

Union[int, float]

Returns

New increase value

get_id()¶

Return the object ID.

Return type

str

Returns

Object ID

get_menu()¶

Return the Menu reference, None if it has not been set.

Return type

Optional[Menu]

Returns

Menu reference

get_scrollarea()¶

Return the scrollarea object.

Return type

ScrollArea

Returns

ScrollArea object

has_attribute(key)¶

Return True if the object has the given attribute.

Parameters

key (str) – Key of the attribute

Return type

bool

Returns

True if exists

hide()[source]¶

Hides the Widget.

Return type

MenuLink

Returns

Self reference

is_floating()¶

Return True if the Widget is floating.

Return type

bool

Returns

Float status

is_visible(check_frame=True)¶

Return True if the Widget is visible.

Parameters

check_frame (bool) – If True check frame and sub-frames if they’re opened as well

Return type

bool

Returns

Visible status

on_remove_from_menu()¶

Function executed if the Widget is removed from the Menu.

Return type

Widget

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 (calling pygame_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.

Return type

Optional[bool]

Returns

True if widget has rendered a new state, None if the widget has not changed, so render used a cache

scroll_to_widget(margin=(0, 0), scroll_parent=True)¶

The container ScrollArea scrolls to the Widget.

Parameters
  • margin (Tuple[Union[int, float], Union[int, float]]) – Extra margin around the rect in px on x-axis and y-axis

  • scroll_parent (bool) – If True parent scroll also scrolls to widget

Return type

Widget

Returns

Self reference

set_attribute(key, value=None)¶

Set an attribute.

Parameters
  • key (str) – Key of the attribute

  • value (Optional[Any]) – Value of the attribute

Return type

Base

Returns

Self reference

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).

Parameters
  • col (int) – Column

  • row (int) – Row

  • index (int) – Index in Menu widget list

Return type

Widget

Returns

Self reference

set_menu(menu)¶

Set the Widget menu reference.

Parameters

menu (Optional[Menu]) – Menu object

Return type

Widget

Returns

Self reference

set_scrollarea(scrollarea)¶

Set scrollarea reference. Mostly used for events.

Parameters

scrollarea (Optional[ScrollArea]) – Scrollarea object

Return type

None

Returns

None

show()[source]¶

Set the Widget visible.

Return type

MenuLink

Returns

Self reference


© Copyright Copyright 2017-2021 Pablo Pizarro R. @ppizarror. Revision b3974f89.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: 4.1.3
Versions
master
latest
4.1.3
4.1.2
4.1.1
4.1.0
4.0.7
4.0.6
4.0.5
4.0.4
4.0.3
4.0.2
4.0.1
4.0.0
3.5.8
3.5.7
3.5.6
3.5.5
3.5.4
3.5.3
3.5.2
3.5.1
3.4.4
3.4.3
3.4.2
3.4.1
3.4.0
3.3.2
3.3.0
3.2.3
3.2.2
3.2.1
3.2.0
3.1.5
3.1.4
3.1.3
3.1.2
3.1.0
3.0.3
3.0.1
3.0.0
Downloads
On Read the Docs
Project Home
Builds