Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter Checkbutton wont keep its check mark post color change

So I have a black and white GUI and I need to use check boxes, well I set it up and the check box looks ok until I click it and then suddenly the check mark wont stay past my click. The issue comes from the line that starts changing the color of the button. But I need this color scheme, I also need to be able to see the checkmark though.

from Tkinter import *

master = Tk()

checkCmd= IntVar()
checkCmd.set(False)

test = Checkbutton(master, variable=checkCmd, onvalue=True, offvalue=False, text="Old Testament", \
            bg='black', fg='white', activebackground='black', activeforeground='white')
test.pack()
buttonCmd = Button(master, text="Run Checked Items").pack()


mainloop()
like image 347
wowwee Avatar asked Oct 27 '25 11:10

wowwee


1 Answers

The check icon shares the foreground color which is white, and your activeforeground is also white.

A simple way is to change the selectcolor which adjusts the background of the selector:

test = Checkbutton(master, variable=checkCmd, onvalue=True, offvalue=False, text="Old Testament",
            bg='black', fg='white', activebackground='black', activeforeground='white',selectcolor="black")
like image 154
Henry Yik Avatar answered Oct 30 '25 00:10

Henry Yik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!