PythonListModel

class glue.utils.qt.PythonListModel(items, parent=None)[source]

Bases: PyQt4.QtCore.QAbstractListModel

A Qt Model that wraps a python list, and exposes a list-like interface

This can be connected directly to multiple QListViews, which will stay in sync with the state of the container.

Create a new model

Parameters:

items : list

The initial list to wrap

parent : QObject

The model parent

Methods Summary

append(value)
data(index, role) Retrieve data at each index
extend(values)
headerData(section, orientation, role) Column labels
insert(row, value)
pop([row]) Remove and return an item (default last item)
removeRow(row[, parent]) Remove a row from the table
rowCount([parent]) Number of rows
row_label(row) The textual label for the row
setData(index, value, role) Update the data in-place
set_list(values) Set the model to a new list

Methods Documentation

append(value)[source]
data(index, role)[source]

Retrieve data at each index

extend(values)[source]
headerData(section, orientation, role)[source]

Column labels

insert(row, value)[source]
pop(row=None)[source]

Remove and return an item (default last item)

Parameters:

row : int (optional)

Which row to remove. Default=last

Returns:

popped : object

removeRow(row, parent=None)[source]

Remove a row from the table

Parameters:

row : int

Row to remove

Returns:

successful : bool

rowCount(parent=None)[source]

Number of rows

row_label(row)[source]

The textual label for the row

setData(index, value, role)[source]

Update the data in-place

Parameters:

index : QModelIndex

The location of the change

value : object

The new value

role : QEditRole

Which aspect of the model to update

set_list(values)[source]

Set the model to a new list