Akascape / CTkTable

Customtkinter Table widget (extension/add-on)
MIT License
265 stars 15 forks source link

Example needed for using command to print row/column/value #6

Closed raff2145 closed 1 year ago

raff2145 commented 1 year ago

Can you provide an example of how to use the command attribute in table config to get the row/column/value?

Akascape commented 1 year ago

@raff2145

import customtkinter
from CTkTable import *

root = customtkinter.CTk()

def show(cell):
    print("row:", cell["row"])
    print("column:", cell["column"])
    print("value:", cell["value"])

value = [[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],]

frame = customtkinter.CTkFrame(root)
frame.pack(expand=True, fill="both")

table = CTkTable(master=frame, row=5, column=5, values=value, height=100, command=show)
table.pack(expand=True, fill="both", padx=20, pady=20)

root.mainloop()
raff2145 commented 1 year ago

Thanks again for the quick reply. For some reason attempting to configure the command with self.table.configure(command=......) doesn't work, but passing the command parameter to the table instance as you've done does work. Good enough for my needs!