2014-10-29 125 views
0

我用Tkinter在一個按鈕中建立了一個背景色,但是當我點擊這個按鈕時,背景色會變成系統顏色,在我的情況下是windows 8.1。有什麼辦法解決這個問題嗎? 代碼:帶tkinter的按鈕的正確背景顏色?

compute = tk.Button(rframe, text='Equals', command=comp_s, relief='flat', font=MY_FONT, background='blue', foreground='white') 
compute.pack(side='left') 

我使用Python 3.4.2 64位

謝謝!

回答

4

當按住鼠標左鍵時,屏幕按鈕變爲其「活動」顏色。下面這種方式適用於我(Win7,3.4.2)。

from tkinter import * 
r= Tk() 
b= Button(text='hello', foreground='white', background='green', 
      activeforeground='red', activebackground='blue') 
b.pack()