Base

class pygame_menu._base.Base(object_id)[source]

Base object.

get_attribute(key, default=None)[source]

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()[source]

Return the Class+ID as a string.

Return type

str

Returns

Class+ID format

get_counter_attribute(key, incr=0, default=0)[source]

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()[source]

Return the object ID.

Return type

str

Returns

Object ID

has_attribute(key)[source]

Return True if the object has the given attribute.

Parameters

key (str) – Key of the attribute

Return type

bool

Returns

True if exists

remove_attribute(key)[source]

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

set_attribute(key, value=None)[source]

Set an attribute.

Parameters
  • key (str) – Key of the attribute

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

Return type

Base

Returns

Self reference