Class p.u.r.u.ListSpec:

Part of pida.utils.rat.util View In Hierarchy

This class is used to help the manipulation of C{gtk.ListStore}s. Here's an example on how to create one:

my_spec = ListSpec(
    ("STATE", gobject.TYPE_INT),
    ("FILENAME", gobject.TYPE_STRING),
)

To create a ListStore, just do the following:

store = my_spec.create_list_store()

To add data to a store you can access it directly:

store.append((1, "fooo"))

Or by creating a dict object and converting it:

row = {
    my_spec.STATE: 2,
    my_spec.FILENAME: "bar"
}
store.append(my_spec.to_tree_row(row))

To access a column on a given row:

for row in store:
    print "State:", row[my_spec.STATE]
    print "Filename:", row[my_spec.FILENAME]
So here are its features:
  • helps you centralize the specs of a given C{gtk.ListStore}
  • makes your code more readable and less error-prone thanks to the created constants
Line # Kind Name Docs
52 Method __init__ Undocumented
64 Method create_list_store Creates a new C{gtk.ListStore}
70 Method to_tree_row Converts a L{dict} like object to a list suitable for adding to a
def __init__(self, *columns):
Undocumented
def create_list_store(self):
Creates a new C{gtk.ListStore} @rtype: C{gtk.ListStore}
def to_tree_row(self, mapping):
Converts a L{dict} like object to a list suitable for adding to a C{gtk.ListStore}.

@rtype: C{ListType}

API Documentation for PIDA, generated by pydoctor.