Home > database >  uncheck checkbox tkinter after a certain time interval
uncheck checkbox tkinter after a certain time interval

Time:12-02

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

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

CodePudding user response:

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

if timer >= timer_interval_minutes:
    self.timer.deselect()
  • Related