ajenti.ui.binder¶
-
class
ajenti.ui.binder.
Binding
(object, attribute, ui)[source]¶ A base class for bindings. Binding is a link between a Python object attribute and Ajenti UI element’s property.
Parameters: - object – a Python object
- attribute – attribute name
- ui – Ajenti
ajenti.ui.UIElement
-
class
ajenti.ui.binder.
PropertyBinding
(obj, attribute, ui, property=None)[source]¶ A simple binding between UI element’s property and Python object’s attribute
Parameters: property – UI property name. If None
, property is deduced frombindtypes
-
class
ajenti.ui.binder.
ListAutoBinding
(object, attribute, ui)[source]¶ Binds values of a collection to UI element’s children consecutively, using
Binder
-
class
ajenti.ui.binder.
DictAutoBinding
(object, attribute, ui)[source]¶ Binds values from a dict to UI element’s children mapping ‘bind’ attribute to dict key, using
Binder
-
class
ajenti.ui.binder.
CollectionAutoBinding
(object, attribute, ui)[source]¶ Binds values of a collection to UI element’s children using a template. The expected UI layout:
<xml xmlns:bind="bind"> <bind:collection id="<binding to this>"> <container-element bind="__items"> <1-- instantiated templates will appear here --> </container-element> <bind:template> <!-- a template for one collection item it will be bound to item using ajenti.ui.binder.Binder --> <label bind="some_property" /> <button id="__delete" /> <!-- a delete button may appear in the template --> </bind:template> <button id="__add" /> <!-- an add button may appear inside collection tag --> </bind:collection> </xml>
-
class
ajenti.ui.binder.
Binder
(object=None, ui=None)[source]¶ An automatic object-to-ui-hierarchy binder. Uses
bind
UI property to find what and where to bind. Ifobject
is not None, the Binder is also initialized (seesetup(object)
) with this data object.Parameters: - object – Python object
- ui – UI hierarchy root
-
class
ajenti.ui.binder.
BasicCollectionElement
(ui, typeid=None, children=[], **kwargs)[source]¶ -
binding
¶ Collection binding class to use
-
filter
¶ Called to filter collections values,
lambda value: bool
-
post_bind
¶ Called after binding is complete,
lambda object, collection, ui: None
-
post_item_bind
¶ Called after an item is bound,
lambda object, collection, item, item-ui: None
-
post_item_update
¶ Called after an item is updated,
lambda object, collection, item, item-ui: None
-
values
¶ Called to extract values from the collection,
lambda collection: []
-
-
class
ajenti.ui.binder.
ListElement
(ui, typeid=None, children=[], **kwargs)[source]¶ -
typeid
= 'bind:list'¶
-
-
class
ajenti.ui.binder.
CollectionElement
(ui, typeid=None, children=[], **kwargs)[source]¶ -
add_item
¶ Called to append value to the collection,
lambda item, collection: None
-
delete_item
¶ Called to remove value from the collection,
lambda item, collection: None
-
new_item
¶ Called to create an empty new item,
lambda collection: object()
-
pagesize
¶
-
sorting
¶ If defined, used as key function to sort items
-
typeid
= 'bind:collection'¶
-