Closed maicol07 closed 3 years ago
I must confess that I don't know which widget you are referring to. I don't have a Table
class!
Could you be more specific?
If you are referring to the LabelGrid
, then this should do:
root = tk.Tk()
lg = tk_tools.LabelGrid(root, num_of_columns=3, headers=['h1', 'h2', 'h3'])
lg.grid()
lg.add_row([1, 2, 3])
lg.add_row([5, 6, 7])
root.mainloop()
This will print headers h1
, h2
, and h3
with data.
No, I mean in Buttongrid
add a row title (a label for row) at the start like column headers.
I can do that. Thanks!
After having a look, the ButtonGrid
already accomplishes this task!
@slightlynybbled but that are headers for columns not rows...
I don't know why I kept reading 'row' as 'column', but I did. Still looking at this!
j
I'm not sure how to maintain the API well. For instance, what happens at initialization? What happens when a row is added but no corresponding label is attached?
button_grid = tk_tools.ButtonGrid(
root,
columns=3,
headers=['Column0', 'Column1', 'Column2'],
row_labels=['row 0', 'row 1'])
button_grid.add_row(['a', 'b', 'c']) # row labeled with 'row 0'
button_grid.add_row(['d', 'e', 'f']) # row labeled with 'row 1'
button_grid.add_row(['g', 'h', 'i']) # what happens when this row is added without a label?
button_grid.grid(row=0, column=0)
What about keep the current row if there isn't an assigned label?
I concede that there are multiple ways to procede... but the behavior of the API is not absolutely clear... What about using the ButtonGrid.remove_row()
method? Does that remove the row label as well or just the data? Are the row labels always visible? If row labels are added, does that "lock" the rows in the same way that the columns are locked?
What do you mean by are the row labels always visible?
The column headers are always visible. Same thing. It seems to me that if a user makes row labels, then the table has now become static in size. The columns are fixed, thus, the rows should be as well for consistency... agree?
Yes!
K, that's good. I like consistency in APIs and this discussion has given me a direction to move into.
Hi, is it possible to add text as first element in table? Thanks