Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

uncheck checkbox tkinter after a certain time interval

my program is based on independent checkboxes, that is, they do not depend on a booleanVar, I am using a setInterval created from a thread , and after a certain time I want the checkbox to ‘turn off’ and be able to receive another setInterval

self.timer = Checkbutton(command=session_timer ,text='Session Timer')
self.timer.grid(row=1,column=1, sticky='w')

currently my solution is to recreate the checkbox itself again in the same position as the previous one inside my timer function

if timer >= timer_interval_minutes:
    self.timer = Checkbutton(command=session_timer ,text='Session Timer')
    self.timer.grid(row=1,column=1, sticky='w')

however what I’m looking for is something to simply disable and change the text, something like this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if timer >= timer_interval_minutes:
    self.timer.configure(state='normal')

however the ‘state’ function only has 3 options, ‘active’, ‘disabled’, ‘normal’, none of them can only disable the checkbox

checkbox uncheck using configure, or something similar

>Solution :

The checkbutton has a documented method named deselect which does what the name implies.

if timer >= timer_interval_minutes:
    self.timer.deselect()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading