TermTk.TTkWidgets.TTkModelView.table

TTkTable

class TTkTable(*, parent=None, visible=True, **kwargs)[source]

A TTkTable implements a table view (TTkTableWidget) that displays items from a model.

    Customer Id     ╿First Name ╿Last Name   ╿Company                         ╿City                ╿
1  │DD37Cf93aecA6Dc │Sheryl     │Baxter      │Rasmussen Group                 │East Leonard        │
╾╌╌┼────────────────┼───────────┼────────────┼────────────────────────────────┼────────────────────┤
2  │1Ef7b82A4CAAD10 │Preston    │Lozano      │Vega-Gentry                     │East Jimmychester   │
╾╌╌┼────────────────┼───────────┼────────────┼────────────────────────────────┼────────────────────┤
3  │6F94879bDAfE5a6 │Roy        │Berry       │Murillo-Perry                   │Isabelborough       │
╾╌╌┼────────────────┼───────────┼────────────┼────────────────────────────────┼────────────────────┤
4  │5Cef8BFA16c5e3c │Linda      │Olsen       │Dominguez, Mcmillan and Donovan │Bensonview          │
╾╌╌┼────────────────┼───────────┼────────────┼────────────────────────────────┼────────────────────┤
5  │053d585Ab6b3159 │Joanna     │Bender      │Martin, Lang and Andrade        │West Priscilla      │
╾╌╌┼────────────────┼───────────┼────────────┼────────────────────────────────┼────────────────────┤
6  │2d08FB17EE273F4 │Aimee      │Downs       │Steele Group                    │Chavezborough       │
╾╌╌┴────────────────┴───────────┴────────────┴────────────────────────────────┴────────────────────┘

please refer to TTkTableWidget for a detailed descriptoin of all the available methods and init params

Signals

signal cellChanged(row, col)

This signal is emitted whenever the data of the item in the cell specified by row and column has changed.

Parameters
  • row (int) – the row

  • col (int) – the column

signal cellClicked(row, col)

This signal is emitted whenever a cell in the table is clicked. The row and column specified is the cell that was clicked.

Parameters
  • row (int) – the row

  • col (int) – the column

signal cellDoubleClicked(row, col)

This signal is emitted whenever a cell in the table is double clicked. The row and column specified is the cell that was double clicked.

Parameters
  • row (int) – the row

  • col (int) – the column

signal cellEntered(row, col)

This signal is emitted when the mouse cursor enters a cell. The cell is specified by row and column.

Parameters
  • row (int) – the row

  • col (int) – the column

signal currentCellChanged(currRow, currCol, prevRow, prevCol)

This signal is emitted whenever the current cell changes. The cell specified by prevRow and prevCol is the cell that previously had the focus, the cell specified by currRow and currCol is the new current cell.

Parameters
  • currRow (int) – the current row

  • currColumn (int) – the current column

  • prevRow (int) – the previous row

  • prevCol (int) – the previous column

undo()

This method is forwarded to undo()

redo()

This method is forwarded to redo()

isUndoAvailable()

This method is forwarded to isUndoAvailable()

isRedoAvailable()

This method is forwarded to isRedoAvailable()

copy()

This method is forwarded to copy()

cut()

This method is forwarded to cut()

paste()

This method is forwarded to paste()

setSortingEnabled()

This method is forwarded to setSortingEnabled()

isSortingEnabled()

This method is forwarded to isSortingEnabled()

sortByColumn()

This method is forwarded to sortByColumn()

clearSelection()

This method is forwarded to clearSelection()

selectAll()

This method is forwarded to selectAll()

setSelection()

This method is forwarded to setSelection()

selectRow()

This method is forwarded to selectRow()

selectColumn()

This method is forwarded to selectColumn()

unselectRow()

This method is forwarded to unselectRow()

unselectColumn()

This method is forwarded to unselectColumn()

rowCount()

This method is forwarded to rowCount()

currentRow()

This method is forwarded to currentRow()

columnCount()

This method is forwarded to columnCount()

currentColumn()

This method is forwarded to currentColumn()

verticalHeader()

This method is forwarded to verticalHeader()

horizontalHeader()

This method is forwarded to horizontalHeader()

hSeparatorVisibility()

This method is forwarded to hSeparatorVisibility()

vSeparatorVisibility()

This method is forwarded to vSeparatorVisibility()

setHSeparatorVisibility()

This method is forwarded to setHSeparatorVisibility()

setVSeparatorVisibility()

This method is forwarded to setVSeparatorVisibility()

model()

This method is forwarded to model()

setModel()

This method is forwarded to setModel()

setColumnWidth()

This method is forwarded to setColumnWidth()

resizeColumnToContents()

This method is forwarded to resizeColumnToContents()

resizeColumnsToContents()

This method is forwarded to resizeColumnsToContents()

setRowHeight()

This method is forwarded to setRowHeight()

resizeRowToContents()

This method is forwarded to resizeRowToContents()

resizeRowsToContents()

This method is forwarded to resizeRowsToContents()

addWidget(widget)

Warning

Method Deprecated,

use TTkWidget -> layout -> addWidget

i.e.

parentWidget.layout().addWidget(childWidget)
close()
dragEnterEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dragLeaveEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dragMoveEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dropEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

enterEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse enter events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

getPadding() -> (<class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>)

Retrieve the widget padding sizes

Returns

list[top, bottom, left, right]: the 4 padding sizes

hide()
keyEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive key events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

keyPressEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive key press events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

keyReleaseEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive key release events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

layout()

Get the layout

Returns

The layout used

Return type

TTkLayout or derived

leaveEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse leave events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

lowerWidget()
mouseDoubleClickEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseDragEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse drag events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseEvent(evt)

Caution

Don’t touch this!

mouseMoveEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse move events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mousePressEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse press events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseReleaseEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse release events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseTapEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

move(x: int, y: int)

Move the widget

Parameters
  • x (int) – x position

  • y (int) – y position

moveEvent(x: int, y: int)

Event Callback triggered after a successful move

name() str
paintChildCanvas()

Caution

Don’t touch this!

paintEvent(canvas: TTkCanvas)

Paint Event callback, this need to be overridden in the widget.

raiseWidget(raiseParent=True)
removeWidget(widget)

Warning

Method Deprecated,

use TTkWidget -> layout -> removeWidget

i.e.

parentWidget.layout().removeWidget(childWidget)
resize(w: int, h: int)

Resize the widget

Parameters
  • w (int) – the new width

  • h (int) – the new height

resizeEvent(w: int, h: int)

Event Callback triggered after a successful resize

setDisabled(disabled=True)
setEnabled(enabled: bool = True)
setFocus()
setGeometry(x: int, y: int, w: int, h: int)

Resize and move the widget

Parameters
  • x (int) – x position

  • y (int) – y position

  • w (int) – the new width

  • h (int) – the new height

setName(name: str)
setPadding(top: int, bottom: int, left: int, right: int)

Set the padding of the widget

Parameters
  • top (int) – top padding

  • bottom (int) – bottom padding

  • left (int) – left padding

  • right (int) – right padding

setVisible(visible: bool)
show()
wheelEvent(evt) bool

This event handler, can be reimplemented in a subclass to receive mouse wheel events for the widget.

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool