Joe
Joe

Reputation: 3007

Tkinter Checkbutton stuck Unchecked

I have a small app that uses tkinter. I had everything working perfectly then made some changes and I have no idea what I did. In my gui there is one check box. If I click the checkbox once nothing happens. If I click it a second time the check mark flashes then disappears. My code follows this format for the most part.

Using Python 3.6 on Windows 10

def foo():
    x = chk.get()
    if x:
        print('hello')

root = Tk()
chk = IntVar()

c = Checkbutton(root, text='Check for CSV Instead', variable=chk, bg='#45484c', fg='white')
c.grid(row=3, column=3)
root.mainloop

I did not make any direct changes to the checkbutton or any variable connected to it. There are no errors. The flashing makes me suspect that the variable is somehow being overwritten but like I said it was working before.

In my research I came across this Which I feel is what is happening to me but I have checked the code and I do not believe I am doing that.

Upvotes: 1

Views: 1695

Answers (1)

PRMoureu
PRMoureu

Reputation: 13347

The color white is guilty, it makes the check sign invisible it's more reproducible with

c = Checkbutton(root, text='Check for CSV Instead', variable=chk, bg='#45484c', fg='#e5e5e5')

Upvotes: 2

Related Questions