Bases: gtkmvc.observer.Observer
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.
spurious controls if the adapter should receive spurious changes from the model (see spuriousness in class Observer for further information).
Called when the widget is instantiated, and the adapter is ready to connect the widget and the property inside the observed model. arg is the (optional) argument that will be passed when connecting the signal.
getter and setter are the (optional) methods used for reading and writing the widget’s value. When not specified, default getter and setter will be guessed by looking at the widget type the adapter will be connected with. Guessing is carried out by querying information specified into module ‘adapters.default’.
Finally, if update is false, the widget will not be updated
Bases: gtkmvc.adapters.basic.Adapter
This class handles the communication between a widget and a class instance (possibly observable) that is a property inside the model. The value to be shown is taken and stored by using a getter and a setter. getter and setter can be: names of user class methods, bound or unbound methods of the user class, or a function that will receive the user class instance and possible arguments whose number depends on whether it is a getter or a setter.
Bases: gtkmvc.adapters.basic.UserClassAdapter
This class is for Read-Only user classes. RO classes are those whose setting methods do not change the instance, but return a new instance that has been changed accordingly to the setters semantics. An example is python datetime class, whose replace method does not change the instance it is invoked on, but returns a new datetime instance.
This class is likely to be used very rarely.
Bases: gtkmvc.adapters.basic.UserClassAdapter
This class can be used to bound a set of widgets to a property that is a container, like a tuple, a list or a map, or in general a class that implements __getitem__ and __setitem__ methods.
From the other hand, the set of widgets can be a list provided by the user, or a container widget like a Box, a notebook, etc. Widgets will be linked by their position when the property is list-like, or by their name when the property is map-like.
This class supports only properties that are static containers, i.e. those containers that do not change their length dynamically. If the container grows up in length, no change will occur in the view-side.
Removes the given widget class information from the default set of adapters.
If widget_class had been previously added by using add_adapter, the added adapter will be removed, restoring possibly previusly existing adapter(s). Notice that this function will remove only one adapter about given wiget_class (the first found in order), even if many are currently stored.
Returns True if one adapter was removed, False if no adapter was removed.