Part of vmc.contrib.gtkmvc.adapters.basic View In Hierarchy
Known subclasses: vmc.contrib.gtkmvc.adapters.basic.RoUserClassAdapter, vmc.contrib.gtkmvc.adapters.containers.StaticContainerAdapter
Method | __init__ | Creates a new adapter that handles setting of value of a |
Inherited from Adapter:
Method | connect_widget | Called when the widget is instantiated, and the adapter is |
Method | update_model | Forces the property to be updated from the value hold by |
Method | update_widget | Forces the widget to be updated from the property |
Method | _connect_model | Used internally to connect the property into the model, and |
Method | _add_method | Private service to add a new method to the instance, |
Method | _read_property | Returns the (possibly transformed) value that is stored |
Method | _write_property | Sets the value of property. Given val is transformed |
Method | _read_widget | Returns the value currently stored into the widget, after |
Method | _write_widget | Writes value into the widget. If specified, user setter |
Method | _cast_value | Casts given val to given totype. Raises TypeError if not able to cast. |
Method | _on_wid_changed | Called when the widget is changed |
Creates a new adapter that handles setting of value of a model single model property when a corresponding widgets set is changed and viceversa when the property is also observable.
This class handles only assignments to properties. For other kinds of setting (e.g. user-defined classes used as observable properties, containers, etc.) use other types of Adapters derived from this class.
prop_name is the model's property name (as a string). It is possible to use a dotted notation to identify a property contained into a hierarchy of models. For example 'a.b.c' identifies property 'c' into model 'b' inside model 'a', where model 'a' is an attribute of given top level model. Last name must be an observable or non-observable attribute, and previous names (if specified) must all refer to instances of class Model. First name from the left must be the name of a model instance inside the given model.
prop_{write,read} are two optional functions that apply custom modifications to the value of the property before setting and reading it. Both take a value and must return a transformed value whose type must be compatible with the type of the property.
value_error can be a function (or a method) to be called when a ValueError exception occurs while trying to set a wrong value for the property inside the model. The function will receive: the adapter, the property name and the value coming from the widget that offended the model.