Closed raff2145 closed 1 year ago
@raff2145 Use configure method to change the table dimensions.
self.table.configure(height=5)
Disregard, after studying a little closer it looks like the way to accomplish this is not to set the table to expand into its parent frame with sticky="nsew", but to do sticky="nw" or "ew" (basically, don't expand the y-axis and just let customtkinter do its job with the standard sticky parameter) and then let the row loop set the row height.
Here is the updated table code:
class TableFrame(customtkinter.CTkFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
# configure table container frame grid
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
self.configure(fg_color="transparent")
# table rows
self.rows = [[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5]]
# table column & row count
self.qty_columns = len(self.rows[0])
self.qty_rows = len(self.rows)
# add table to the frame
self.table = CTkTable(self, row=self.qty_rows, column=self.qty_columns, values=self.rows)
# set row height
for i in range(self.qty_rows):
self.table.edit_row(i, height=25)
# place table in the container frame
self.table.grid(row=0, column=0, padx=20, pady=20, sticky="nw")
I am trying to set the row height for a table, but can't seem to do so using the table method .edit_row().
I am assuming the row height can be set while the table is set to fill its parent frame (sticky="nsew").
Here is an example of what I'm attempting vs what I get:
Table code:
Result (row height unaffected):