1

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.

Joe
  • 2,641
  • 5
  • 22
  • 43
  • Unreproducible problem - your code works for me. I can check and uncheck the Checkbutton repeatedly - check/uncheck state appear in stable states. (Of course I had to add the import statements and call the `mainloop()` as a function, but everything else worked as expected) – chickity china chinese chicken Jun 27 '17 at 23:26

1 Answers1

2

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')
PRMoureu
  • 12,817
  • 6
  • 38
  • 48
  • OMG I am so mad. I have had it white with NO problem for days. I dont know why today it acted up. I just completely rewrote all the button code and couldnt recreate it. Until the very end. Thank You!!!! – Joe Jun 27 '17 at 23:36