我如何更改按钮边框 tkinter 的颜色 [英] How do i change the colour of a button border tkinter

查看:63
本文介绍了我如何更改按钮边框 tkinter 的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 tkinter 中更改边框的颜色

How do i change the colour of a border in tkinter

我查看了推荐使用 highlightcolorhighlightbackground 的其他解决方案,但是这些都不起作用.

I have looked at other solutions which recommended using highlightcolor and highlightbackground, however these did not work.

excercises_button = Button(canvas, width=327, height=150, image=dumbell_img,borderwidth=4, relief="ridge", bg = "gray55", command = Excercises)
canvas_excercises_button = canvas.create_window(168, 724, window=excercises_button)

我希望此按钮的边框为橙色.

I would like the border of this button to be orange.

这是它目前的样子:https://i.stack.imgur.com/3QX8X.png

推荐答案

我找到了解决方案!

我所做的是创建了一个围绕按钮的矩形.

What i did is I created a rectangle which surrounded the buttons.

canvas.create_rectangle(0, 638, 1100, 900, fill=colour)

然后我将三个按钮缩小了几个像素,以显示矩形的背景.

I then made the three buttons a few pixels smaller to allow the background of the rectangle to show.

这篇关于我如何更改按钮边框 tkinter 的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆