TableWidget#

class pyqtgraph.TableWidget(*args, **kwds)[source]#

Extends QTableWidget with some useful functions for automatic data handling and copy / export context menu. Can automatically format and display a variety of data types (see setData() for more information.

__init__(*args, **kwds)[source]#

All positional arguments are passed to QTableWidget.__init__().

Keyword Arguments

editable

(bool) If True, cells in the table can be edited by the user. Default is False.

sortable

(bool) If True, the table may be soted by clicking on column headers. Note that this also causes rows to appear initially shuffled until a sort column is selected. Default is True. (added in version 0.9.9)

clear()[source]#

Clear all contents from the table.

copyAll()[source]#

Copy all data to clipboard.

copySel()[source]#

Copy selected data to clipboard.

saveAll()[source]#

Save all data to file.

saveSel()[source]#

Save selected data to file.

serialize(useSelection=False)[source]#

Convert entire table (or just selected area) into tab-separated text values

setData(data)[source]#

Set the data displayed in the table. Allowed formats are:

  • numpy arrays

  • numpy record arrays

  • metaarrays

  • list-of-lists [[1,2,3], [4,5,6]]

  • dict-of-lists {‘x’: [1,2,3], ‘y’: [4,5,6]}

  • list-of-dicts [{‘x’: 1, ‘y’: 4}, {‘x’: 2, ‘y’: 5}, …]

setFormat(format, column=None)[source]#

Specify the default text formatting for the entire table, or for a single column if column is specified.

If a string is specified, it is used as a format string for converting float values (and all other types are converted using str). If a function is specified, it will be called with the item as its only argument and must return a string. Setting format = None causes the default formatter to be used instead.

Added in version 0.9.9.

setSortMode(column, mode)[source]#

Set the mode used to sort column.

Sort Modes

value

Compares item.value if available; falls back to text comparison.

text

Compares item.text()

index

Compares by the order in which items were inserted.

Added in version 0.9.9