Search code examples
python-2.7user-interfacettk

ttk Checkbutton select and readonly?


I am using Python 2.7, is there a way to preselect/deselect a Checkbutton in ttk?? As well as making it read-only?

I am trying to display the selected option from a file.


Solution

  • I figured it out myself, the correct syntax would be something like

        self.mon = ttk.Checkbutton(self.dow, text = 'MON')
        self.mon.state(['selected'])
        self.mon.grid(column = 0, row = 0)
    

    I've seen it on a couple of sites, but their syntax are off, this is the correct way to do it!