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:
classmethod applicable(object, attribute)[source]
classmethod extract(object, attribute, ignore_errors=True)[source]
get()[source]
Returns:value of the bound attribute
populate()[source]

Should update the UI with attribute’s value

set(value)[source]

Sets value of the bound attribute

unpopulate()[source]

Should revert UI to normal state

update()[source]

Should update the attribute with data from the UI

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 from bindtypes
populate()[source]
update()[source]
class ajenti.ui.binder.ListAutoBinding(object, attribute, ui)[source]

Binds values of a collection to UI element’s children consecutively, using Binder

populate()[source]
unpopulate()[source]
update()[source]
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

populate()[source]
unpopulate()[source]
update()[source]
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>
get_template(item, ui)[source]
on_add()[source]
on_delete(item)[source]
populate()[source]
set_page(page=0)[source]
unpopulate()[source]
update()[source]
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. If object is not None, the Binder is also initialized (see setup(object)) with this data object.

Parameters:
  • object – Python object
  • ui – UI hierarchy root
add(binding)[source]
autodiscover(object=None, ui=None)[source]
populate()[source]

Populates the bindings.

reset(object=None, ui=None)[source]

Cancels the binding and replaces Python object / UI root.

setup(object=None)[source]

Initializes the Binder with a data object. :type object: object

unpopulate()[source]

Unpopulates the bindings.

update()[source]

Updates the bindings.

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'
comments powered by Disqus