Base

class pygame_menu._base.Base(object_id, verbose=True)[source]

Base object.

clear_attributes()[source]

Remove all stored attributes.

Return type:

None

Returns:

None

get_attribute(key, default=None)[source]

Get an attribute value.

Parameters:
  • key (str) – Key of the attribute

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

Return type:

Any

Returns:

Attribute data

get_attributes()[source]

Return a copy of all stored attributes.

Return type:

dict[str, Any]

Returns:

Attributes dictionary

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 value to start with, by default it’s zero

Return type:

Union[int, float]

Returns:

New increased 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