1

I am trying to add a checkbox to customtkinter table widget which is CTkTable but I don't know how to get it inside. the first row have to be all list of checkboxes or what widget should I use that accept that

    def checkbox_event():
        print("checkbox toggled, current value:", check_var.get())

    check_var = StringVar(value="on")
    checkbox =  CTkCheckBox(master=scrollable_frame_search, text="CTkCheckBox", 
    command=checkbox_event, variable=check_var, onvalue="on", offvalue="off")
    
    #table for show
    value = [['SELECT','TITLE','DOWNLOAD'], [1,2,3], [1,2,3], [1,2,3], [1,2,3]]

    table = CTkTable(master=scrollable_frame_search, row=3, column=3, values=value, header_color='gray',corner_radius=4)
    table.pack(expand=True, fill="both")

1 Answer 1

1

According to the CTkTable Documentation, currently, there's no way to add a widget inside a cell. I tried this, and here's what I gotShows .!ctktable.!ctkbutton Here's my code:

import customtkinter
from CTkTable import *

root = customtkinter.CTk()

table = CTkTable(master=root, row=5, column=5)

table.configure(values=[[customtkinter.CTkButton(table),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.pack(expand=True, fill="both", padx=20, pady=20)

root.mainloop()

This shows that currently, you can only add text to cells in CTkTable


What you can do

This is surely going to be a long method, but worth it. This method also comes with some setbacks, like the corners won't be rounded anymore.

You can make frames for each value, change their colours and use frame.grid_propagate(False) (There might be a different code for pack or place).

If you want the same colours as of the cells, change the filled colour and the outlined colour in alternate row cells.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.