scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Tkinter How to set CheckButton either true or false

Wed Jan 25, 2017 3:05 pm

Here is an example of setting a ttk.Checkbutton 5 second after the application loads.
Basically you need to use an IntVar to set/get the status of tkinter widgets.

Code: Select all

try:
    import tkinter as tk
    import tkinter.ttk as ttk
except:
    import Tkinter as tk
    import ttk

import time
    
class App(tk.Frame):
    def __init__(self,master=None,**kw):
        tk.Frame.__init__(self,master=master,**kw)
        self.value = tk.IntVar()
        self.checkBox1 = ttk.Checkbutton(self, text="Invisible", variable = self.value)
        self.checkBox1.grid()
        self.after(5000,self.setBox)
    def setBox(self):
        self.value.set(1)

if __name__ == '__main__':
    root = tk.Tk()
    App(root).grid()
    root.mainloop()
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “Graphics programming”