Skip to content Skip to sidebar Skip to footer

How Do I Change The Colour Of A Button Border Tkinter

How do i change the colour of a border in tkinter I have looked at other solutions which recommended using highlightcolor and highlightbackground, however these did not work. exce

Solution 1:

Here is an example of how one can have a kind of border created by using a frame and a button.

import tkinter as tk

root = tk.Tk()

frame = tk.Frame(root, highlightbackground="orange", highlightcolor="orange", highlightthickness=4, bd=0)
frame.grid(row=0, column=0)
# adding weights so the button is center on the frame.
frame.columnconfigure(0, weight=1)
frame.rowconfigure(0, weight=1)

btn = tk.Button(frame,text="test", borderwidth=4, relief="ridge", bg = "gray55").grid(row=0, column=0)
root.mainloop()

Results:

enter image description here

Solution 2:

I found a solution!

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.

Post a Comment for "How Do I Change The Colour Of A Button Border Tkinter"