madgui.widget.tableview module

Table widget specified by column behaviour.

Classes

TableItem([data])

Cell item data for a tree widget.

TableModel(titles, rowitems[, data])

Table data model.

TableView(*args, **kwargs)

A table widget based on Qt’s QTableView for our TableModel.

TreeView(*args, **kwargs)

A tree widget based on Qt’s QTableView for our TableModel.

NodeItem([data])

Descriptor/type information for a TreeNode.

TreeNode(item[, parent])

Proxy class for accessing contents/properties of a table cell.

ItemView([parent])

Mixin class for shared code of TableView and TreeView.

ItemViewDelegate

ItemDelegate(*[, default, fmtspec])

Wrap a value of a specific type for string rendering and editting.

StringDelegate(*[, default, fmtspec])

Bare string value.

IntDelegate(*[, default, fmtspec])

Integer value.

BoolDelegate(*[, default, fmtspec])

Boolean value.

QuantityDelegate([unit])

ExpressionDelegate([unit])

ListDelegate(*[, default, fmtspec])

List value.

EnumDelegate(*[, default, fmtspec])

ReadOnlyDelegate

AffixLineEdit(*args, **kwargs)

Single-line edit control with prefix/suffix text.

Functions

lookupDelegate(value)

class madgui.widget.tableview.AffixLineEdit(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QWidget

Single-line edit control with prefix/suffix text.

Methods

focusInEvent(self, QFocusEvent)

focusInEvent(self, QFocusEvent)[source]
class madgui.widget.tableview.BoolDelegate(*, default=None, fmtspec=None)[source]

Bases: madgui.widget.tableview.ItemDelegate

Boolean value.

Attributes

default

bool(x) -> bool

default = False
class madgui.widget.tableview.EnumDelegate(*, default=None, fmtspec=None)[source]

Bases: madgui.widget.tableview.StringDelegate

Methods

createEditor(self, QWidget, …)

setEditorData(self, QWidget, QModelIndex)

setModelData(self, QWidget, …)

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
class madgui.widget.tableview.ExpressionDelegate(unit=None)[source]

Bases: madgui.widget.tableview.QuantityDelegate

Methods

createEditor(self, QWidget, …)

edit(cell)

setEditorData(self, QWidget, QModelIndex)

setModelData(self, QWidget, …)

Attributes

default

str(object=’’) -> str

textAlignment

Qt.Alignment()

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
default = ''
edit(cell)[source]
setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
textAlignment = <PyQt5.QtCore.Qt.Alignment object>
class madgui.widget.tableview.IntDelegate(*, default=None, fmtspec=None)[source]

Bases: madgui.widget.tableview.ItemDelegate

Integer value.

Methods

createEditor(self, QWidget, …)

setEditorData(self, QWidget, QModelIndex)

setModelData(self, QWidget, …)

Attributes

default

int(x=0) -> integer

textAlignment

Qt.Alignment()

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
default = 0
setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
textAlignment = <PyQt5.QtCore.Qt.Alignment object>
class madgui.widget.tableview.ItemDelegate(*, default=None, fmtspec=None)[source]

Bases: PyQt5.QtWidgets.QStyledItemDelegate

Wrap a value of a specific type for string rendering and editting.

Attributes

default

str(object=’’) -> str

fmtspec

str(object=’’) -> str

textAlignment

Qt.Alignment()

Methods

display(value)

Render the value as string.

edit(cell)

default = ''
display(value)[source]

Render the value as string.

edit(cell)[source]
fmtspec = ''
textAlignment = <PyQt5.QtCore.Qt.Alignment object>
class madgui.widget.tableview.ItemView(parent=None, **kwargs)[source]

Bases: object

Mixin class for shared code of TableView and TreeView. Do not use directly.

Attributes

allow_delete

bool(x) -> bool

rows

List-like access to the data.

selectionChangedSignal

Signal<>

Methods

connectClearButton(button)

connectRemoveButton(button)

format_changed()

keyPressEvent(event)

removeSelectedRows()

resizeEvent(event)

Resize all sections to content and user interactive

selectionChanged(selected, deselected)

set_viewmodel(rowitems[, data, unit, titles])

sizeHint()

sizeHintForColumn(column)

allow_delete = False
connectClearButton(button)[source]
connectRemoveButton(button)[source]
format_changed()[source]
keyPressEvent(event)[source]
removeSelectedRows()[source]
resizeEvent(event)[source]

Resize all sections to content and user interactive

property rows

List-like access to the data.

selectionChanged(selected, deselected)[source]
selectionChangedSignal

Signal<>

set_viewmodel(rowitems, data=None, unit=(), titles=None)[source]
sizeHint()[source]
sizeHintForColumn(column)[source]
class madgui.widget.tableview.ItemViewDelegate[source]

Bases: PyQt5.QtWidgets.QStyledItemDelegate

Methods

createEditor(self, QWidget, …)

delegate(index)

setEditorData(self, QWidget, QModelIndex)

setModelData(self, QWidget, …)

sizeHint(self, QStyleOptionViewItem, QModelIndex)

updateEditorGeometry(self, QWidget, …)

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
delegate(index)[source]
setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
sizeHint(self, QStyleOptionViewItem, QModelIndex) → QSize[source]
updateEditorGeometry(self, QWidget, QStyleOptionViewItem, QModelIndex)[source]
class madgui.widget.tableview.ListDelegate(*, default=None, fmtspec=None)[source]

Bases: madgui.widget.tableview.ItemDelegate

List value.

Methods

createEditor(self, QWidget, …)

display(value)

Render the value as string.

formatValue(value)

setEditorData(self, QWidget, QModelIndex)

setModelData(self, QWidget, …)

Attributes

textAlignment

Qt.Alignment()

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
display(value)[source]

Render the value as string.

formatValue(value)[source]
setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
textAlignment = <PyQt5.QtCore.Qt.Alignment object>
class madgui.widget.tableview.NodeItem(data=None, **kwargs)[source]

Bases: object

Descriptor/type information for a TreeNode.

Methods

get_children()

List of child rows (for expandable data).

get_parent()

get_row()

rowitems(idx, data)

get_children()[source]

List of child rows (for expandable data).

get_parent()[source]
get_row()[source]
rowitems(idx, data)[source]
class madgui.widget.tableview.QuantityDelegate(unit=None)[source]

Bases: madgui.widget.tableview.ItemDelegate

Methods

createEditor(self, QWidget, …)

display(value)

Render the value as string.

setEditorData(self, QWidget, QModelIndex)

setModelData(self, QWidget, …)

Attributes

default

float(x) -> floating point number

fmtspec

str(object=’’) -> str

textAlignment

Qt.Alignment()

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
default = 0.0
display(value)[source]

Render the value as string.

property fmtspec

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
textAlignment = <PyQt5.QtCore.Qt.Alignment object>
class madgui.widget.tableview.ReadOnlyDelegate[source]

Bases: PyQt5.QtWidgets.QStyledItemDelegate

Methods

createEditor(self, QWidget, …)

setEditorData(self, QWidget, QModelIndex)

setModelData(self, QWidget, …)

createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex) → QWidget[source]
setEditorData(self, QWidget, QModelIndex)[source]
setModelData(self, QWidget, QAbstractItemModel, QModelIndex)[source]
class madgui.widget.tableview.StringDelegate(*, default=None, fmtspec=None)[source]

Bases: madgui.widget.tableview.ItemDelegate

Bare string value.

class madgui.widget.tableview.TableItem(data=None, **kwargs)[source]

Bases: madgui.widget.tableview.NodeItem

Cell item data for a tree widget.

Methods

get_checkState()

get_checkable()

get_checked()

get_columns()

get_delegate()

get_display()

Render the value as string.

get_edit()

Obtain value for the editor.

get_editable()

get_flags()

get_mutable()

get_row()

get_rows()

get_textAlignment()

get_ui_value()

get_value()

set_checked(value)

Implement setting BoolDelegate via checkbox.

set_ui_value(value)

get_checkState()[source]
get_checkable()[source]
get_checked()[source]
get_columns()[source]
get_delegate()[source]
get_display()[source]

Render the value as string.

get_edit()[source]

Obtain value for the editor.

get_editable()[source]
get_flags()[source]
get_mutable()[source]
get_row()[source]
get_rows()[source]
get_textAlignment()[source]
get_ui_value()[source]
get_value()[source]
set_checked(value)[source]

Implement setting BoolDelegate via checkbox.

set_ui_value(value)[source]
class madgui.widget.tableview.TableModel(titles, rowitems, data=None)[source]

Bases: PyQt5.QtCore.QAbstractItemModel

Table data model.

Column specifications are provided as TableItem instances. The data can be accessed and changed via the list-like rows.

Methods

cell(index)

columnCount(self, parent)

data(self, QModelIndex, role)

flags(self, QModelIndex)

headerData(self, int, Qt.Orientation, role)

index(self, int, int, parent)

parent(self, QModelIndex)

parent(self) -> QObject

rowCount(self, parent)

setData(self, QModelIndex, Any, role)

Attributes

rows

cell(index)[source]
columnCount(self, parent: QModelIndex = QModelIndex())int[source]
data(self, QModelIndex, role: int = Qt.DisplayRole) → Any[source]
flags(self, QModelIndex) → Qt.ItemFlags[source]
headerData(self, int, Qt.Orientation, role: int = Qt.DisplayRole) → Any[source]
TableModel.index(self, int, int, parent: QModelIndex = QModelIndex()) -> QModelIndex[source]
parent(self, QModelIndex) → QModelIndex[source]

parent(self) -> QObject

rowCount(self, parent: QModelIndex = QModelIndex())int[source]
property rows
setData(self, QModelIndex, Any, role: int = Qt.EditRole)bool[source]
class madgui.widget.tableview.TableView(*args, **kwargs)[source]

Bases: madgui.widget.tableview.ItemView, PyQt5.QtWidgets.QTableView

A table widget based on Qt’s QTableView for our TableModel.

  • does not support expandable items

  • supports vertical header

  • currently supports background colors (since we don’t use css for QTableView)

Methods

header()

header()[source]
class madgui.widget.tableview.TreeNode(item, parent=None)[source]

Bases: object

Proxy class for accessing contents/properties of a table cell. Delegates data queries to attributes of the associated :class`NodeItem`.

Attributes

children

col

row

Methods

data(role)

index()

invalidate()

setData(value, role)

property children
property col
data(role)[source]
index()
invalidate()[source]
property row
setData(value, role)[source]
class madgui.widget.tableview.TreeView(*args, **kwargs)[source]

Bases: madgui.widget.tableview.ItemView, PyQt5.QtWidgets.QTreeView

A tree widget based on Qt’s QTableView for our TableModel.

  • supports expandable items

  • does not show item background color (apparently due to an incompatibility with css styling).

Methods

resizeColumnsToContents()

set_viewmodel(rowitems[, data, unit, titles])

resizeColumnsToContents()[source]
set_viewmodel(rowitems, data=None, unit=(), titles=None)[source]
madgui.widget.tableview.lookupDelegate(value)[source]