Tables

Contents

Summary

Table

Adds a simple table that can hold text.

TableSelection

Get/set which cells are selected in a Table.

Simple Tables

class dearpygui_obj.tables.Table(headers: Union[int, Iterable[str]] = 2, **config: Any)[source]

Bases: dearpygui_obj.wrapper.widget.Widget, dearpygui_obj.wrapper.widget.ItemWidgetMx

Adds a simple table that can hold text.

A Table’s data consists of a sequence of rows, each row being a sequence of strings.

Note that a Table has two different kinds of “columns”. A Table will have a number of data columns and a number of header columns.

These won’t always match. If you have more data columns than header columns, only a subsection of the data will actually get shown. This will be the case even if hide_headers is True.

Parameters

headers – can be an iterable of header strings or an integer. If an integer is used, it will set the number of header columns and the hide_headers property will be set to True.

To get/set values in the table, indexing syntax can be used. For example:

table[2, 3] = 'cell content'
table[3, :] = ['sets', 'an', 'entire', 'row']
table[:, 4] = ['sets', 'an', 'entire', 'column']
table[:, :] = [['first', row'], ['second', 'row'], ['third', 'row]]

Cell selection state can also be modified in a similar manner.

table.selection[1, :] = True  # selects the entire second row.
hide_headers: bool

If True, table headers will not be displayed.

selected: TableSelection

A TableSelection instance that can be used to get or modify the table’s cell selection state.

set_headers(headers: Union[Iterable[str], int]) None[source]

Set the table headers.

This determines the number of displayed columns (distinct from the number of data columns!). If an integer is passed, the headers will be replaced with empty strings and hidden.

property rows: int

The number of data rows.

property columns: int

The number of data columns.

__getitem__(indices: Tuple[int, int]) str[source]
__getitem__(indices: Tuple[int, slice]) Sequence[str]
__getitem__(indices: Tuple[slice, int]) Sequence[str]
__getitem__(indices: Tuple[slice, slice]) Sequence[Sequence[str]]

Get table data using indices or slices.

__setitem__(indices: Tuple[int, int], value: str) None[source]
__setitem__(indices: Tuple[int, slice], value: Iterable[str]) None
__setitem__(indices: Tuple[slice, int], value: Iterable[str]) None
__setitem__(indices: Tuple[slice, slice], value: Iterable[Iterable[str]]) None

Set table data using indices or slices. The shape of the value argument must match the provided indices/slices.

clear() None[source]

Clear the table.

This will remove all rows from the table. It does NOT change the table headers and therefore the number of visible columns.

append_row(row: Iterable[str]) None[source]
insert_row(row_idx: int, row: Iterable[str]) None[source]
remove_row(row_idx: int) None[source]
append_column(header: str, column: Iterable[str]) None[source]
insert_column(col_idx: int, header: str, column: Iterable[str]) None[source]
remove_column(col_idx: int) None[source]
class dearpygui_obj.tables.TableSelection(table: dearpygui_obj.tables.Table)[source]

Bases: object

Get/set which cells are selected in a Table.

__iter__() Iterable[Tuple[int, int]][source]

Iterate the selected cells as (row, col) pairs.

__setitem__(indices: Tuple[Union[int, slice], Union[int, slice]], selected: bool) None[source]

Modify the cell selection state.

Uses the same syntax as table indexing, allowing the selection of multiple cells to be modified at once using slices.