PythonListModel

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

Bases: PyQt5.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)
data(index, role)

Retrieve data at each index

extend(values)
headerData(section, orientation, role)

Column labels

insert(row, value)
pop(row=None)

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)

Remove a row from the table

Parameters:

row : int

Row to remove

Returns:

successful : bool

rowCount(parent=None)

Number of rows

row_label(row)

The textual label for the row

setData(index, value, role)

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)

Set the model to a new list