GUI Properties#

class arcade.gui.DictProperty[source]#

Bases: Property

Property that represents a dict. Only dict are allowed. Any other classes are forbidden.

set(instance, value: dict)[source]#
default_factory#
name: str#
obs: WeakKeyDictionary[Any, _Obs]#
class arcade.gui.ListProperty[source]#

Bases: Property

Property that represents a list. Only list are allowed. Any other classes are forbidden.

set(instance, value: dict)[source]#
default_factory#
name: str#
obs: WeakKeyDictionary[Any, _Obs]#
class arcade.gui.Property(default: P | None = None, default_factory: Callable[[Any, Any], P] | None = None)[source]#

Bases: Generic[P]

An observable property which triggers observers when changed.

Parameters:
  • default – Default value which is returned, if no value set before

  • default_factory – A callable which returns the default value. Will be called with the property and the instance

bind(instance, callback)[source]#
dispatch(instance, value)[source]#
get(instance) P[source]#
set(instance, value)[source]#
default_factory#
name: str#
obs: WeakKeyDictionary[Any, _Obs]#
arcade.gui.bind(instance, property: str, callback)[source]#

Binds a function to the change event of the property. A reference to the function will be kept, so that it will be still invoked, even if it would normally have been garbage collected.

def log_change():

print(“Something changed”)

class MyObject:

name = Property()

my_obj = MyObject() bind(my_obj, “name”, log_change)

my_obj.name = “Hans” # > Something changed

Parameters:
  • instance – Instance owning the property

  • property – Name of the property

  • callback – Function to call

Returns:

None