Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTkTable dimensions when used inside a ScrollableFrame #2655

Open
TrinitySolver opened this issue Dec 8, 2024 · 0 comments
Open

CTkTable dimensions when used inside a ScrollableFrame #2655

TrinitySolver opened this issue Dec 8, 2024 · 0 comments

Comments

@TrinitySolver
Copy link

Hi,

I have a CTkTable in a CTkScrollableFrame which is in a CTkTabview but I meet several issues. Here is a simpler version of my code, with all the problems, the default size of the window is the one I will keep in the future (I did not fix it here to show some problems) :

import customtkinter
from CTkTable import *

root = customtkinter.CTk()
root.geometry("400x200")
row_nums = []
deleted_values = []

tabview = customtkinter.CTkTabview(root, height=100)
tabview.grid(row=0, column=0, padx=(5, 5), sticky="new")
tabview.add("A")
tabview.add("B")
tabview.add("C")
tabview.tab("A").grid_columnconfigure(0, weight=1)

tabA_scrol = customtkinter.CTkScrollableFrame(tabview.tab("A"))
tabA_scrol.grid(row=0, column=0, sticky="new")

def show(cell):
    if cell["row"] not in row_nums:
        table.select_row(cell["row"])
        row_nums.append(cell["row"])
        deleted_values.append(table.get_row(cell["row"]))
    else:
        table.deselect_row(cell["row"])
        row_nums.remove(cell["row"])
        deleted_values.remove(table.get_row(cell["row"]))


def delete():
    global row_nums
    if len(row_nums) == 0:
        return
    else:
        table.delete_rows(row_nums)
        row_nums = []
    print(deleted_values)


value = [["A", "B", "C", "D", "E"], [1, 2, 3, 4, 5], [0, 0, 0, 0, 0], [1, 2, 0, 0, 0], [3, 4, 5, 6, 7], [4, 2, 3, 4, 5], [5, 0, 0, 0, 0], [6, 2, 0, 0, 0], [7, 2, 3, 4, 5]]

table = CTkTable(tabA_scrol, column=5, values=value, command=show, header_color="green")
table.grid(row=1, column=0)

btn = customtkinter.CTkButton(root, text='Delete', width=150, command=delete)
btn.grid(row=2, column=0)
root.mainloop()

First one : I don't know how to modify the Table/ScrollableFrame height to fit this window size, I tried putting "height = ..." everywhere but it never changes it and I always end up with the button hidden below.

Second one : The width of the table change when I put it directly inside the window, based on the window size, but once I put it inside a ScrollableFrame, everything is messed up.

Third one : This may just be a feature that doesn't exist but when I scroll down the table, the header end up disappearing as I scroll down, is there a way like freeze in excel to always keep the header visible on top even when scrolling ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant