Replies: 2 comments 7 replies
-
That actually sounds like it might be a bug. Do you think you could produce a code snippet (MRE) that reproduces the issue? |
Beta Was this translation helpful? Give feedback.
2 replies
-
Just to clarify: the generated Here's a quick example to demonstrate: from textual.app import App, ComposeResult
from textual.widgets import DataTable
class TableApp(App):
def compose(self) -> ComposeResult:
yield DataTable()
def on_mount(self) -> None:
table = self.query_one(DataTable)
col_1_key = table.add_column("C1")
col_2_key = table.add_column("C2")
self.notify(f"{col_1_key == col_2_key = }")
row_1_key = table.add_row("R1C1", "R1C2")
row_2_key = table.add_row("R2C1", "R2C2")
self.notify(f"{row_1_key == row_2_key = }")
self.notify(f"{table.get_cell(row_1_key, col_1_key) = }")
self.notify(f"{table.get_cell(row_2_key, col_2_key) = }")
if __name__ == "__main__":
app = TableApp()
app.run() |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
While building a table using
add_columns
I encountered issues when I wanted to useget_cell
. I started debugging since I couldn't understand what it was, then I found that all the column keys had the value None**. This surprised me a bit since the docs said that column_key will be automatically generated if none were provided, however I have later understood this to simply be a misunderstanding others have encountered as well.The issue with this becomes apparent when you then try to use other built-in functions such as in my case
get_cell
. You have to provide the row key and the column key. But if all the column keys are identical, it is impossible to get a particular cell value. In the docs the description of a ColumnKey is "Uniquely identifies a column in the DataTable." and I have a hard time understanding how setting all the keys to "None" would make them unique.The solution for now has been to simply use
add_column
for every column I want to have in the table. However it would be smoother to be able to useadd_columns
for purposes like this.My suggestion would be on of the following:
Appreciate any comments, maybe I am missing something.
Beta Was this translation helpful? Give feedback.
All reactions