Win7上的Tkinter highlightcolor选项

JDM*_*JDM 6 tkinter windows-7 python-2.7

我正在构建一个Tkinter GUI(Python 2.7)并在Win7机器上运行它.我想做的其中一件事就是按钮和复选框等控件在突出显示时采用不同的颜色(因为高亮标记本身有点模糊,特别是默认的灰色背景).但是,设置highlightcolor为不同的颜色(例如'cyan')对GUI没有任何影响; 无论是否有焦点,控件都保持灰色.作为交叉检查,我尝试将所有highlightblah选项设置为不同的选项,但仍显示为灰色,厚度也没有明显变化.

这仅仅是Win7上Tkinter的限制吗?它只是不回应这些选项吗?

Mr.*_*ero -1

这是你想要的一个简单的例子

from Tkinter import *
from time import sleep
from random import choice


class TestColor():

    def __init__(self):
        self.root = Tk()
        self.button = Button(self.root, text = "buggton", command = self.ChangeColor, bg = "green", fg = "Black", activebackground = "Red", highlightbackground="Black")
        self.button.grid(row=0, column=0)
        self.RanDomiZeColor = ["blue", "black", "white", "yellow"]
        self.root.mainloop()

    def ChangeColor(self):
        self.button = Button(self.root, text = "buggton", command = self.ChangeColor, bg = choice(self.RanDomiZeColor), fg = choice(self.RanDomiZeColor), activebackground = choice(self.RanDomiZeColor), highlightbackground = choice(self.RanDomiZeColor))
        self.button.grid(row=0, column=0)

try: TestColor()
except Exception as why: print why; sleep(10)
Run Code Online (Sandbox Code Playgroud)

它在 Windows 10 上运行 100%。所以在 Windows 7 上尝试一下我将颜色设置为随机,这样你就可以用你的“颜色”定义每一个,以了解发生了什么,但事实并非highlightbackground如此highlightcolor