如何在customtkinter中向CTkTable添加复选框

问题描述 投票:0回答:1

我正在尝试向 customtkinter 表小部件添加一个复选框,即 CTkTable,但我不知道如何将其放入其中。第一行必须是所有复选框列表或我应该使用什么小部件来接受这一点

    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")
python customtkinter
1个回答
0
投票

根据CTkTable文档,目前无法在单元格内添加小部件。我尝试了这个,这就是我得到的Shows .!ctktable.!ctkbutton这是我的代码:

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()

这表明目前,您只能向 CTkTable 中的单元格添加文本

© www.soinside.com 2019 - 2024. All rights reserved.