これは、uは
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)
それはので、私は「そうuはウルで一人一人を定義することができますランダムに色を設定するWindows 7の 上でそれを試してのWindows 10で100%を働いて欲しいもののために簡単な例でありますあなたが何か起こったかを理解するために「色」を選択してください。highlightbackground
ではありません。highlightcolor
これはあなたの質問にお答えします。 http://stackoverflow.com/questions/14264819/how-to-change-colors-of-multiple-widgets-after-hovering-in-tkinter – shivsn
いいえ、それは背景色(bg)についてのみ話しています。フォーカスを取得/失うことに関連した色の変化(ハイライト)を探しています。 – JDM