customtkinter.CTkCheckbox get value of checked items (python)

Viewed 29

I am trying to get the checked value from the list of checkboxes but I am not sure how to get those values. If the user checks option1 and option3, I am looking to grab that info and run those options

    checkboxList = ["Option 1", "Option 2", "Option 3", "Option 4"]
    
    for x,y in zip(checkboxList,range(len(checkboxList))):

        self.check_box_1 = customtkinter.CTkCheckBox(master=self.frame_right,text=x)
        self.check_box_1.grid(row=y+1, column=0, pady=5, padx=5,sticky="w")
        self.check_box_1.configure(state=tkinter.DISABLED)
                    
        if self.index == 1:
            self.check_box_1.configure(state=tkinter.DISABLED)
            self.check_box_1.select()
            label_1 = customtkinter.CTkLabel(master=self.frame_right,
                                          text="Automated",
                                          text_font=("Roboto Medium", -24))
            label_1.grid(column=0, row=0, sticky="nwe", padx=15, pady=15)
            self.checkedList.append(x)
        elif self.index == 2:
            self.check_box_1.configure(state=tkinter.NORMAL)
            label_1 = customtkinter.CTkLabel(master=self.frame_right,
                                          text="Manual",
                                          text_font=("Roboto Medium", -24))
            label_1.grid(column=0, row=0, sticky="nwe", padx=15, pady=15)

        button_2 = customtkinter.CTkButton(master=self.frame_right,
                                            text="GetCheckedItems",
                                            command=self.checkBoxList)
        button_2.grid(row=10, column=0, pady=10, padx=20)

    def checkBoxList(self):
        ### Not sure how to get the checked value from the checkbox ###
0 Answers
Related