簡體   English   中英

按下時如何在tkinter按鈕上保留按鈕背景和前景色?

[英]How to preserve button background and foreground color on tkinter button when pressed?

我在tkinter中有一個按鈕,已將bg / fg着色為。

我對它的外觀感到滿意,但是當按下按鈕時,顏色會恢復為我不滿意的灰色背景上的默認黑色文本。

begin_button = tk.Button(bottom_frame, text='Click me!', bg='blue', fg='red', font='Helvetica 10', command=begin)

按下按鈕時,是否有簡單的方法將顏色固定到位? 我不介意按鈕下沉(實際上非​​常不錯),但是顏色變化對我不利。

您可以調整activebackgroundactiveforeground ,它們在激活時負責按鈕的bg / fg顏色。

begin_button = tk.Button(root, text='Click me!', bg='blue', fg='red', font='Helvetica 10',
                         activebackground="blue",activeforeground="red")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM