【问题标题】:How to preserve button background and foreground color on tkinter button when pressed?按下时如何在 tkinter 按钮上保留按钮背景和前景色?
【发布时间】:2020-01-01 13:22:38
【问题描述】:

我在 tkinter 中有一个按钮,我已将 bg/fg 着色为。

我对它的外观感到满意,但是当按下按钮颜色时,我不满意的是灰色背景上的默认黑色文本。

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

有没有一种简单的方法可以在按下按钮时将颜色固定到位?我不介意按钮凹陷(实际上这很好),但颜色变化对我不利。

【问题讨论】:

    标签: python python-3.x tkinter


    【解决方案1】:

    你可以调整activebackgroundactiveforeground,它们负责激活时按钮的bg/fg颜色。

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

    【讨论】:

      猜你喜欢
      • 2013-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-07
      • 1970-01-01
      • 2021-07-24
      相关资源
      最近更新 更多