Package traylib :: Module config :: Class Config
[frames] | no frames]

Class Config

source code

object --+
         |
        Config

A Config is an object containing attributes. They can be added using the add_attribute() method, changed using set_attribute() and accessed using get_attribute(). If an attribute is changed, an update function is called on all configurable objects registered via add_configurable().

Instance Methods
 
__init__(self)
Creates a new Config.
source code
 
add_attribute(self, key, value, update_func=None, set_func=None)
Adds an attribute to the Config.
source code
 
set_attribute(self, key, value)
Sets the attribute identified by key to the value value.
source code
 
get_attribute(self, key)
Returns: The value associated with the given key.
source code
 
add_configurable(self, obj)
Registers a configurable object.
source code
 
remove_configurable(self, obj)
Unregisters a configurable object.
source code
 
has_configurable(self, obj)
Returns: True if the configurable object is registered with the Config.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

Creates a new Config.

Overrides: object.__init__

add_attribute(self, key, value, update_func=None, set_func=None)

source code 

Adds an attribute to the Config.

Parameters:
  • key - The key.
  • value - The value.
  • update_func - The name of a method that gets called on all configurable objects (registered via add_configurable()) when the value of the attribute has changed.
  • set_func - The name of a method with signature set_func(old_value, new_value) that gets called on the Config when the value of the attribute has changed.

set_attribute(self, key, value)

source code 

Sets the attribute identified by key to the value value.

Parameters:
  • key - The key.
  • value - The new value.

get_attribute(self, key)

source code 
Parameters:
  • key - The key.
Returns:
The value associated with the given key.

add_configurable(self, obj)

source code 

Registers a configurable object.

Parameters:
  • obj - The object.

remove_configurable(self, obj)

source code 

Unregisters a configurable object.

Parameters:
  • obj - The object.

has_configurable(self, obj)

source code 
Parameters:
  • obj - The configurable object.
Returns:
True if the configurable object is registered with the Config.