Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 按下tkinter按钮时,如何保持按钮背景色和前景色?_Python_Python 3.x_Tkinter - Fatal编程技术网

Python 按下tkinter按钮时,如何保持按钮背景色和前景色?

Python 按下tkinter按钮时,如何保持按钮背景色和前景色?,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,我在tkinter中有一个按钮,我已将背景/前景涂上颜色 我对它的外观很满意,但是当按下按钮时,颜色会恢复为默认的灰色背景上的黑色文本,我对此不满意 begin_button = tk.Button(bottom_frame, text='Click me!', bg='blue', fg='red', font='Helvetica 10', command=begin) 按下按钮时,有没有简单的方法将颜色固定在适当的位置?我不介意按钮凹陷(事实上这很好),但颜色变化对我不好。你可以调整ac

我在tkinter中有一个按钮,我已将背景/前景涂上颜色

我对它的外观很满意,但是当按下按钮时,颜色会恢复为默认的灰色背景上的黑色文本,我对此不满意

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

按下按钮时,有没有简单的方法将颜色固定在适当的位置?我不介意按钮凹陷(事实上这很好),但颜色变化对我不好。

你可以调整
activebackground
activeforeground
,这两种颜色在按钮激活时负责按钮的背景/前景颜色

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

您可以调整
activebackground
activeforeground
,它们在按钮处于活动状态时负责按钮的背景/前景颜色

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