-
-
Notifications
You must be signed in to change notification settings - Fork 990
Closed
Description
Currently the DataTable will only raise a CellDoesNotExist
error if the row key does not exist, but not if the column key does not exist.
Here's a simple example which also logs the table _data
:
from textual.app import App, ComposeResult
from textual.widgets import DataTable, RichLog
class TableApp(App):
CSS = """
DataTable {
height: 1fr;
border: double $primary;
}
RichLog {
height: 1fr;
border: double $primary;
}
"""
def compose(self) -> ComposeResult:
yield DataTable()
yield RichLog()
def on_mount(self) -> None:
table = app.query_one(DataTable)
table.border_title = "Table View"
table.add_column("Column1", key="C1")
table.add_row("TargetValue", key="R1")
log = self.query_one(RichLog)
log.border_title = "Table Data"
log.write("DataTable._data = ")
log.write(table._data)
def key_u(self) -> None:
table = self.query_one(DataTable)
table.update_cell("R1", "INVALID_COLUMN", "New Value")
log = self.query_one(RichLog)
log.write("\nDataTable._data = ")
log.write(table._data)
app = TableApp()
if __name__ == "__main__":
app.run()
Metadata
Metadata
Assignees
Labels
No labels