Skip to content

TableRow

ttkbootstrap.tableview.TableRow

Represents a row in a Tableview object

iid property readonly

A unique record identifier

values property writable

The table row values

__init__(self, tableview, values) special

Parameters:

Name Type Description Default
tableview Tableview

The Tableview widget that contains this row

required
values List[Any, ...]

A list of values to display in the row

required
Source code in ttkbootstrap/tableview.py
def __init__(self, tableview, values):
    """
    Parameters:

        tableview (Tableview):
            The Tableview widget that contains this row

        values (List[Any, ...]):
            A list of values to display in the row
    """
    self.view: ttk.Treeview = tableview.view
    self._values = values
    self._iid = None
    self._sort = TableRow._cnt + 1
    self._table = tableview

    # increment cnt
    TableRow._cnt += 1

build(self)

Create the row object in the Treeview and capture the resulting item id (iid).

Source code in ttkbootstrap/tableview.py
def build(self):
    """Create the row object in the `Treeview` and capture
    the resulting item id (iid).
    """
    if self._iid is None:
        self._iid = self.view.insert("", END, values=self.values)
        self._table.iidmap[self.iid] = self

configure(self, opt=None, **kwargs)

Configure the row. If opt is provided, the current value is returned, otherwise, sets the widget options specified in kwargs. See the documentation for Tableview.insert_row for configurable options.

Parameters:

Name Type Description Default
opt str

A configuration option to query.

None
**kwargs { values, tags }

Optional keyword arguments used to configure the row.

{}
Source code in ttkbootstrap/tableview.py
def configure(self, opt=None, **kwargs):
    """Configure the row. If opt is provided, the
    current value is returned, otherwise, sets the widget
    options specified in kwargs. See the documentation for
    `Tableview.insert_row` for configurable options.

    Parameters:

        opt (str):
            A configuration option to query.

        **kwargs { values, tags }:
            Optional keyword arguments used to configure the
            row.
    """
    if self._iid is None:
        self.build()

    if opt is not None:
        return self.view.item(self.iid, opt)
    elif 'values' in kwargs:
        values = kwargs.pop('values')
        self.values = values
    else:
        self.view.item(self.iid, **kwargs)

delete(self)

Delete the row from the dataset

Source code in ttkbootstrap/tableview.py
def delete(self):
    """Delete the row from the dataset"""
    if self.iid:
        self._table.iidmap.pop(self.iid)
        self._table.tablerows_visible.remove(self)
        self._table._tablerows.remove(self)
        self._table.load_table_data()
        self.view.delete(self.iid)

hide(self)

Remove the row from the data table view

Source code in ttkbootstrap/tableview.py
def hide(self):
    """Remove the row from the data table view"""
    self.view.detach(self.iid)

refresh(self)

Syncs the tableview values with the object values

Source code in ttkbootstrap/tableview.py
def refresh(self):
    """Syncs the tableview values with the object values"""
    if self._iid:
        self.view.item(self.iid, values=self.values)

show(self, striped=False)

Show the row in the data table view

Source code in ttkbootstrap/tableview.py
def show(self, striped=False):
    """Show the row in the data table view"""
    if self._iid is None:
        self.build()
    self.view.reattach(self.iid, "", END)

    # remove existing stripes
    tags = list(self.view.item(self.iid, "tags"))
    try:
        tags.remove("striped")
    except ValueError:
        pass

    # add stripes (if needed)
    if striped:
        tags.append("striped")
    self.view.item(self.iid, tags=tags)