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

#deselecting all checked CTkCheckboxes #2630

Open
coldsober-irene opened this issue Nov 8, 2024 · 2 comments
Open

#deselecting all checked CTkCheckboxes #2630

coldsober-irene opened this issue Nov 8, 2024 · 2 comments

Comments

@coldsober-irene
Copy link

how can I deselect all checked checkboxes?

@teijiIshida
Copy link

Use a for-loop. Loop through all your checkboxes and call deselect().

@MaxNiark
Copy link

        for i,v in enumerate(self.db_lic_sql_dict):
            command_1=partial(self._select_all_lic,self.db_lic_sql_dict[v])
            row_id+=1
            label=CTkLabel(self.lic_frame, text=v).grid(row=row_id)
            self.select_all=CTkCheckBox(self.lic_frame,text="all",command=command_1,textvariable="on")
            self.select_all.grid(row=row_id,column=1, pady=10)
            row_id+=1
            for j in self.db_lic_sql_dict[v]:
                lic,comment=j.split(";")
                self._checkbox_dict[lic]=CTkCheckBox(self.lic_frame,text=lic,command=lambda bouh=lic:self.radiobutton_event(bouh),)
                row_id+=1
                self._checkbox_dict[lic].grid(row=row_id,column=0,sticky="nw",pady=5)
    def _select_all_lic(self,db_sql, port=None):

        if self.select_all.cget("textvariable")=="on":
                        self.list_lic_select.clear()
                        for key in db_sql:
                            key_tmp,z=key.split(";")
                            str_port,str_lic= key_tmp.split("@")
                            if str_port == port :
                                self.list_lic_select.append([str_lic,str_port])
                                self._checkbox_dict[key].select()
                            if port == None:
                                self.list_lic_select.append([str_lic,str_port])
                                self._checkbox_dict[key_tmp].select()
                        self.select_all.configure(textvariable="off")
                        print("SELECTED ---- :",db_sql,'\n')


        elif self.select_all.cget("textvariable")=="off":          
                        for key in db_sql:
                            key_tmp,z=key.split(";")
                            str_port,str_lic= key_tmp.split("@")
                            self.list_lic_select.clear()
                            self._checkbox_dict[key_tmp].deselect()
                        self.select_all.configure(textvariable="on")
                        print("UNSELECTED ---- :",db_sql,'\n')
        print(self.list_lic_select)

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

3 participants