samedi 25 mars 2023

Python tkinter get the value of multiple checkbox

For my tkinter/customtkinter gui, i have several checkbox and i want to automatically see if they are checked or not.

All my checkbox have a name like "box0", "box1", "box2", etc.

(https://i.stack.imgur.com/8Bbez.png)

After that, i have a button, and when you click, i call my function named "check"

(https://i.stack.imgur.com/COSP7.png)

My function is like this, it check if the box0 is checked of not:

(https://i.stack.imgur.com/3dO3z.png)

But i don't want to copy paste and type 4 times the same code, i want to automatize it, with something like that:

def check():
     for i in range(4):
          if box+i == 1: 
               print(f"Box{i} is checked")

How can i do that ?




Aucun commentaire:

Enregistrer un commentaire