class documentation

QTableView2 class.

Method __init__ Initializes a table.
Method focusInEvent Gets called when the table gained focus. This highlights the border and selects the last-selected cell (if any).
Method focusOutEvent Gets called when the table lost focus, or when a cell is being edited. When not editing, this clears the selection, triggering on_selection_changed().
Method get_selected_row Returns the currently selected row index.
Method on_combobox_cell_edited Gets called when a combobox cell has been edited.
Method on_data_changed Gets called when the data in a selection changed. Note: Always assuming only a single cell is selected.
Method on_row_deleted Gets called when a row was deleted.
Method on_selection_changed Gets called when the selection changed.
Method select_cell Selects a cell. Any parameter may be left set to None in order to load its value from the selection model.
Method select_last_row Selects the last row.
Method set_data Sets the table contents.
Method set_style Sets this widget's style.
Instance Variable gui Undocumented
Instance Variable _allow_delete Undocumented
Instance Variable _col_keys Undocumented
Instance Variable _col_options Undocumented
Instance Variable _col_types Undocumented
Instance Variable _on_cell_edited Undocumented
Instance Variable _on_row_deleted Undocumented
Instance Variable _on_selection_changed Undocumented
Instance Variable _row_count_minimum Undocumented
Instance Variable _row_prefix Undocumented
def __init__(self, gui: GUI, col_keys: list[str], col_types: dict | None = None, col_options: list | None = None, row_allow_delete: bool = True, row_count_minimum: int = 0, row_prefix: str = '', on_cell_edited: Callable | None = None, on_selection_changed: Callable | None = None, on_row_deleted: Callable | None = None):

Initializes a table.

Parameters
gui:GUIGUI
col_keys:list[str]List of horizontal header strings
col_types:dict | NonePer-column cell types used for binding cells to configuration. Ordered dictionary of key-value pairs (column key : column type) or None to disable binding. Note: Currently, *only the keys* are used for binding cells to project configuration; the cell options actually determine the cell type, i.e. numerical or combobox.
col_options:list | NonePer-column cell options. This determines the cell type, i.e. numerical or combobox. List of options for every column; items may be set to None to use numerical cells.
row_allow_delete:boolEnable to add an extra column for row delete buttons
row_count_minimum:intMinimum number of rows (no further rows can be deleted)
row_prefix:strPer-row prefix used for binding cells to configuration (key = prefix + column key + "_" + row index)
on_cell_edited:Callable | NoneSet this to make cells editable
on_selection_changed:Callable | NoneUsed to inform the GUI that another row was selected
on_row_deleted:Callable | NoneSet this to make rows deletable
def focusInEvent(self, _event: QFocusEvent):

Gets called when the table gained focus. This highlights the border and selects the last-selected cell (if any).

Parameters
_event:QFocusEventQFocusEvent
def focusOutEvent(self, _event: QFocusEvent):

Gets called when the table lost focus, or when a cell is being edited. When not editing, this clears the selection, triggering on_selection_changed().

Parameters
_event:QFocusEventQFocusEvent
def get_selected_row(self) -> int | None:

Returns the currently selected row index.

Returns
int | NoneIndex of currently selected row (None if none selected)
def on_combobox_cell_edited(self, combobox: QComboBox, row: int, column: int):

Gets called when a combobox cell has been edited.

Parameters
combobox:QComboBoxQCombobox
row:intRow index
column:intColumn index
def on_data_changed(self, top_left_index: QtCore.QModelIndex, _bottom_right_index: QtCore.QModelIndex):

Gets called when the data in a selection changed. Note: Always assuming only a single cell is selected.

Parameters
top_left_index:QtCore.QModelIndexModel index of the top left selection bounds
_bottom_right_index:QtCore.QModelIndexModel index of the bottom right selection bounds
def on_row_deleted(self, row: int):

Gets called when a row was deleted.

Parameters
row:intRow
def on_selection_changed(self, _selected: QItemSelection, _deselected: QItemSelection):

Gets called when the selection changed.

Parameters
_selected:QItemSelectionCurrently selected QItemSelection
_deselected:QItemSelectionCurrently deselected QItemSelection
def select_cell(self, row: int | None = None, col: int | None = None):

Selects a cell. Any parameter may be left set to None in order to load its value from the selection model.

Parameters
row:int | NoneRow
col:int | NoneColumn
def select_last_row(self, focus: bool = True):

Selects the last row.

Parameters
focus:boolEnable to focus the table, disable to explicitly clear the visual selection
def set_data(self, data: list[list[str]], row_keys: list[str]):

Sets the table contents.

Parameters
data:list[list[str]]Data (2D)
row_keys:list[str]List of vertical header strings
def set_style(self, border_color: str, border_width: int):

Sets this widget's style.

Parameters
border_color:strBorder color
border_width:intBorder width
gui =

Undocumented

_allow_delete =

Undocumented

_col_keys =

Undocumented

_col_options =

Undocumented

_col_types =

Undocumented

_on_cell_edited =

Undocumented

_on_row_deleted =

Undocumented

_on_selection_changed =

Undocumented

_row_count_minimum =

Undocumented

_row_prefix =

Undocumented