Tkinter Checkbutton 不会在颜色更改后保留其复选标记 [英] Tkinter Checkbutton wont keep its check mark post color change

查看:32
本文介绍了Tkinter Checkbutton 不会在颜色更改后保留其复选标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个黑白图形用户界面,我需要使用复选框,我设置了它,复选框看起来没问题,直到我点击它,然后突然间复选标记不会停留在我点击之后.问题来自开始更改按钮颜色的行.但是我需要这个配色方案,不过我也需要能够看到复选标记.

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()

推荐答案

勾选图标共享前景色为白色,你的活动前景色也是白色.

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

一个简单的方法是改变 selectcolor 来调整选择器的背景:

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")

这篇关于Tkinter Checkbutton 不会在颜色更改后保留其复选标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆