TTkTableπΆοΈ
- class TTkTable(*, tableWidget: TTkTableWidget = None, tableModel: TTkAbstractTableModel = None, vSeparator: bool = True, hSeparator: bool = True, vHeader: bool = True, hHeader: bool = True, sortingEnabled=False, dataPadding=1, **kwargs)[source]πΆοΈ
Bases:
TTkAbstractScrollArea
TTkTable
is a container widget which placeTTkTableWidget
in a scrolling area with on-demand scroll bars.A
TTkTableWidget
implements a table view 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 β βΎβββ΄βββββββββββββββββ΄ββββββββββββ΄βββββββββββββ΄βββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββ
The
TTkTableWidget
class is one of the Model/View Classes and is part of TermTkβs model/view framework.TTkTableWidget
implements the methods to allow it to display data provided by models derived from theTTkAbstractTableModel
class.Navigation
You can navigate the cells in the table by clicking on a cell with the mouse, or by using the arrow keys, you can also hit Tab and Backtab to move from cell to cell.
Visual Appearance
The table has a vertical header that can be obtained using the
verticalHeader()
function, and a horizontal header that is available through thehorizontalHeader()
function. The height of each row in the table can be set usingsetRowHeight()
; similarly, the width of columns can be set usingsetColumnWidth()
.They can be selected with
selectRow()
andselectColumn()
. The table will show a grid depending on thesetHSeparatorVisibility()
setVSeparatorVisibility()
methods.The items shown in a table view, like those in the other item views, are rendered and edited using standard delegates. However, for some tasks it is sometimes useful to be able to insert widgets in a table instead. Widgets are set for particular indexes with the setIndexWidget() function, and later retrieved with indexWidget().
By default, the cells in a table do not expand to fill the available space. You can make the cells fill the available space by stretching the last header section.
To distribute the available space according to the space requirement of each column or row, call the viewβs
resizeColumnsToContents()
orresizeRowsToContents()
functions.- Parameters:
tableWidget (
TTkTableWidget
, optional) β a custom Table Widget to be used instead of the default one.
TTkTableWidget
βs forwarded init params:- Parameters:
tableModel (
TTkAbstractTableModel
) β the model for the view to present.vSeparator (bool, optional) β show the vertical separators, defaults to True
hSeparator (bool, optional) β show the horizontal separators, defaults to True
vHeader (bool, optional) β show the vertical header, defaults to True
hHeader (bool, optional) β show the horizontal header, defaults to True
sortingEnabled (bool, optional) β enable the column sorting, defaults to False
dataPadding (int, optional) β the right column padding, defaults to 1
TTkContainer
βs inherited init params:- Parameters:
layout (
TermTk.TTkLayouts
) β the layout of this widget, optional, defaults toTTkLayout
padding (
TTkPadding
) β the padding (top, bottom, left, right) of the widget, defaults to (0,0,0,0)paddingTop (int) β the Top padding, override Top padding if already defined, optional, default=0 if padding is not defined
paddingBottom (int) β the Bottom padding, override Bottom padding if already defined, optional, default=0 if padding is not defined
paddingLeft (int) β the Left padding, override Left padding if already defined, optional, default=0 if padding is not defined
paddingRight (int) β the Right padding, override Right padding if already defined, optional, default=0 if padding is not defined
forwardStyle (bool) β [Experimental] any change of style will reflect the children, defaults to False
TTkWidget
βs inherited init params:- Parameters:
name (str, optional) β the name of the widget, defaults to ββ
parent (
TTkWidget
, optional) β the parent widget, defaults to Nonex (int, optional) β the x position, defaults to 0
y (int, optional) β the y position, defaults to 0
pos ((int,int), optional) β the [x,y] position (override the previously defined x, y), defaults to (x,y)
width (int, optional) β the width of the widget, defaults to 0
height (int, optional) β the height of the widget, defaults to 0
size ((int,int), optional) β the size [width, height] of the widget (override the previously defined sizes), defaults to (width,height)
maxWidth (int, optional) β the maxWidth of the widget, defaults to 0x10000
maxHeight (int, optional) β the maxHeight of the widget, defaults to 0x10000
maxSize ((int,int), optional) β the max [width,height] of the widget, optional, defaults to (maxWidth,maxHeight)
minWidth (int, optional) β the minWidth of the widget, defaults to 0
minHeight (int, optional) β the minHeight of the widget, defaults to 0
minSize ((int,int), optional) β the minSize [width,height] of the widget, optional, defaults to (minWidth,minHeight)
toolTip (
TTkString
, optional) β This property holds the widgetβs tooltip, defaults to ββstyle (dict, optional) β this field hold the custom style to be used by this widget
addStyle (dict, optional) β this field is required to override/merge the new style on top of the current one, useful if only few params need to be changed
visible (bool, optional) β the visibility, optional, defaults to True
enabled (bool, optional) β the ability to handle input events, optional, defaults to True
StyleπΆοΈ
classStyle = TTkTableWidget.classStyle
SignalsπΆοΈ
Signals linked to:
TTkTableWidget
This signal is emitted whenever the data of the item in the cell specified by row and column has changed.
This signal is emitted whenever a cell in the table is clicked.
This signal is emitted whenever a cell in the table is double clicked.
This signal is emitted when the mouse cursor enters a cell.
This signal is emitted whenever the current cell changes.
TTkTable
signals:This signal is emitted whenever the widget is closed
This signal is emitted whenever the widget stye change
This signal is emitted whenever the focus status change i.e. with the
setFocus()
orclearFocus()
methods.This signal is emitted whenever the widget size change
SlotsπΆοΈ
Slots linked to:
TTkTableWidget
Copies any selected cells to the clipboard.
Copies the selected ccells to the clipboard and deletes them from the table.
Pastes the text/cells from the clipboard into the table at the current cursor position.
Redoes the last operation if redo is available.
Resizes the given column based on the size hints of the delegate used to render each item in the column.
Resizes all columns based on the size hints of the delegate used to render each item in the columns.
Resizes the given row based on the size hints of the delegate used to render each item in the row.
Resizes all rows based on the size hints of the delegate used to render each item in the rows.
TTkTableWidget.setColumnWidth
(column,Β width)Sets the width of the given column.
TTkTableWidget.setRowHeight
(row,Β height)Sets the height of the given row.
TTkTableWidget.setSortingEnabled
(enable)If enable is true, enables sorting for the table and immediately trigger a call to
sortByColumn()
with the current sort section and orderTTkTableWidget.sortByColumn
(column,Β order)Sorts the model by the values in the given column and order.
Undoes the last operation if undo is available.
TTkTable
slots:Slots Inherited from:
TTkContainer
hide
()hide the widget
show
()show the widget
Slots Inherited from:
TTkWidget
close
()Close (Destroy/Remove) the widget
hide
()hide the widget
lowerWidget
()Lower the Widget below its relatives
raiseWidget
([raiseParent])Raise the Widget above its relatives
setDisabled
([disabled])This property holds whether the widget is disnabled
setEnabled
([enabled])This property holds whether the widget is enabled
setFocus
()Focus the widget
setVisible
(visible)Set the visibility status of this widget
show
()show the widget
update
([repaint,Β updateLayout,Β updateParent])Notify the drawing routine that the widget changed and needs to draw its new content.
MembersπΆοΈ
- closed: pyTTkSignalπΆοΈ
This signal is emitted whenever the widget is closed
- Parameters:
widget (TTkWidget) β the widget closed (=self)
- currentStyleChanged: pyTTkSignalπΆοΈ
This signal is emitted whenever the widget stye change
- Parameters:
style (dict) β the new style applied
- focusChanged: pyTTkSignalπΆοΈ
This signal is emitted whenever the focus status change i.e. with the
setFocus()
orclearFocus()
methods- Parameters:
status (bool) β the curent focus status
- sizeChanged: pyTTkSignalπΆοΈ
This signal is emitted whenever the widget size change
- Parameters:
width (int) β the new widget width
height (int) β the new widget height
MethodsπΆοΈ
Methods linked to:
TTkTableWidget
Deselects all selected items.
Returns the number of columns.
Copies any selected cells to the clipboard.
Returns the column of the current item.
Returns the row of the current item.
Copies the selected ccells to the clipboard and deletes them from the table.
Returns the visibility status of the horizontal separator
Returns the table view's horizontal header.
This property holds whether sorting is enabled If this property is true, sorting is enabled for the table.
Returns the model that this view is presenting.
Pastes the text/cells from the clipboard into the table at the current cursor position.
Redoes the last operation if redo is available.
Resizes the given column based on the size hints of the delegate used to render each item in the column.
Resizes all columns based on the size hints of the delegate used to render each item in the columns.
Resizes the given row based on the size hints of the delegate used to render each item in the row.
Resizes all rows based on the size hints of the delegate used to render each item in the rows.
Returns the number of rows.
Selects all items in the view.
Selects the given column in the table view
Selects the given row in the table view
TTkTableWidget.setColumnWidth
(column,Β width)Sets the width of the given column.
Set the the visibility of the horizontal separators (lines)
TTkTableWidget.setModel
(model)Sets the model for the view to present.
TTkTableWidget.setRowHeight
(row,Β height)Sets the height of the given row.
TTkTableWidget.setSelection
(pos,Β size,Β flags)Selects the items within the given rect and in accordance with the specified selection flags.
TTkTableWidget.setSortingEnabled
(enable)If enable is true, enables sorting for the table and immediately trigger a call to
sortByColumn()
with the current sort section and orderSet the the visibility of the vertical separators (lines)
TTkTableWidget.sortByColumn
(column,Β order)Sorts the model by the values in the given column and order.
Undoes the last operation if undo is available.
TTkTableWidget.unselectColumn
(column)Unselects the given column in the table view
Unselects the given row in the table view
Returns the visibility status of the vertical separator
Returns the table view's vertical header.
TTkTable
methods:Methods Inherited from:
TTkAbstractScrollArea
resizeEvent
(w,Β h)Convenience function, Event Callback triggered after a successful resize
setHorizontalScrollBarPolicy
(policy)setVerticalScrollBarPolicy
(policy)setViewport
(viewport)update
([repaint,Β updateLayout,Β updateParent])Notify the drawing routine that the widget changed and needs to draw its new content.
viewport
()Methods Inherited from:
TTkContainer
addWidget
(widget)getPadding
()Retrieve the
TTkContainer
's paddings sizes as shown in Layout TopologygetWidgetByName
(name)Return the widget from its name.
hide
()hide the widget
layout
()Get the Layout
maximumHeight
()maximumWidth
()minimumHeight
()minimumWidth
()mouseEvent
(evt)paintChildCanvas
()removeWidget
(widget)rootLayout
()This is a root layout mainly used to place items that are not supposed to be inside the main layout (i.e. the menu elements).
setCurrentStyle
(*args,Β **kwargs)setLayout
(layout)Set the Layout used by this widget to place all the child widgets.
setPadding
(top,Β bottom,Β left,Β right)Set the
TTkContainer
's paddings sizes as shown in Layout Topologyshow
()show the widget
update
([repaint,Β updateLayout,Β updateParent])Notify the drawing routine that the widget changed and needs to draw its new content.
Methods Inherited from:
TTkWidget
clearFocus
()Remove the Focus state of this widget
close
()Close (Destroy/Remove) the widget
currentStyle
()disableWidgetCursor
([disable])enableWidgetCursor
([enable])focusInEvent
()focusOutEvent
()focusPolicy
()geometry
()getCanvas
()getPixmap
()Convenience function which return a pixmap representing the current widget status
getWidgetByName
(name)Return the widget from its name.
hasFocus
()This property holds the focus status of this widget
height
()hide
()hide the widget
isEnabled
()This property holds whether the widget is enabled
isEntered
()isVisible
()Retrieve the visibility status of this widget
isVisibleAndParent
()lowerWidget
()Lower the Widget below its relatives
maxDimension
(orientation)maximumHeight
()maximumSize
()maximumWidth
()mergeStyle
(style)minDimension
(orientation)minimumHeight
()minimumSize
()minimumWidth
()mouseEvent
(evt)move
(x,Β y)Move the widget
moveEvent
(x,Β y)Convenience function, Event Callback triggered after a successful move
name
()paintChildCanvas
()paintEvent
(canvas)Paint Event callback, this need to be overridden in the widget.
parentWidget
()pasteEvent
(txt)Callback triggered when a paste event is forwarded to this widget.
pos
()raiseWidget
([raiseParent])Raise the Widget above its relatives
resize
(width,Β height)Resize the widget
resizeEvent
(w,Β h)Convenience function, Event Callback triggered after a successful resize
setCurrentStyle
(*args,Β **kwargs)setDefaultSize
(arg,Β width,Β height)setDisabled
([disabled])This property holds whether the widget is disnabled
setEnabled
([enabled])This property holds whether the widget is enabled
setFocus
()Focus the widget
setFocusPolicy
(policy)This property holds the way the widget accepts keyboard focus
setGeometry
(x,Β y,Β width,Β height)Resize and move the widget
setMaximumHeight
(maxh)setMaximumSize
(maxw,Β maxh)setMaximumWidth
(maxw)setMinimumHeight
(minh)setMinimumSize
(minw,Β minh)setMinimumWidth
(minw)setName
(name)Set the name of this Instance
setParent
(parent)setStyle
(style)setToolTip
(toolTip)setVisible
(visible)Set the visibility status of this widget
setWidgetCursor
([pos,Β type])show
()show the widget
size
()style
()toolTip
()update
([repaint,Β updateLayout,Β updateParent])Notify the drawing routine that the widget changed and needs to draw its new content.
widgetItem
()width
()x
()y
()Methods Inherited from:
TMouseEvents
enterEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse enter events for the widget.
leaveEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse leave events for the widget.
mouseDoubleClickEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.
mouseDragEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse drag events for the widget.
mouseMoveEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse move events for the widget.
mousePressEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse press events for the widget.
mouseReleaseEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse release events for the widget.
mouseTapEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.
wheelEvent
(evt)This event handler, can be reimplemented in a subclass to receive mouse wheel events for the widget.
Methods Inherited from:
TKeyEvents
keyEvent
(evt)This event handler, can be reimplemented in a subclass to receive key events for the widget.
Methods Inherited from:
TDragEvents
dragEnterEvent
(evt)This event handler, can be reimplemented in a subclass to receive drag events for the widget.
dragLeaveEvent
(evt)This event handler, can be reimplemented in a subclass to receive drag events for the widget.
dragMoveEvent
(evt)This event handler, can be reimplemented in a subclass to receive drag events for the widget.
dropEvent
(evt)This event handler, can be reimplemented in a subclass to receive drag events for the widget.
TTkTable AttributesπΆοΈ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|