Interaction with Tkinter Checkbutton widgets in python3

Asked

Viewed 140 times

-1

I am creating a system in python3 using the Tkinter library, I need that when checking the Checkbutton widget "Mark All" the others are marked and when unchecking, the others are unchecked.

follows below the code:

from tkinter import *
master = Tk()

check01 = Checkbutton(master, text="Marcar Todos")
check01.place(x=50,y=50)
check01.deselect()

check02 = Checkbutton(master, text='Opcao 01')
check02.place(x=50,y=90)
check02.deselect()

check03 = Checkbutton(master, text='Opcao 02')
check03.place(x=50,y=110)
check03.deselect()

master.geometry("200x200")

master.mainloop()

1 answer

0

I managed to find the solution, below:

from Tkinter import * master = Tk()

def marks all(): overall state, stage 2 if state.get() > 0: check02.select() check03.select() Else: check02.deselect() check03.deselect()

def desmarca(): check01.deselect()

state = Intvar() check01 = Checkbutton(master, text="Mark All", command=tag all, variable=status) check01.place(x=50,y=50) check01.deselect()

check02 = Checkbutton(master, text='Option 01', command=uncheck) check02.place(x=50,y=90) check02.deselect()

check03 = Checkbutton(master, text='Option 02', command=uncheck) check03.place(x=50,y=110) check03.deselect()

master.Geometry("200x200") master.mainloop()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.