x = Button(root, text='...', padx=50, bg='red', fg='black',
highlightcolor="pink",
highlightbackground="pink",
highlightthickness=4,
relief=SOLID)
Here's an example with a pink border of thickness 4, which works on Linux (and should work on macOS)
EDIT:
It seems it's a Windows specific issue. It can be resolved by calling the following code after instantiating your root
:
root = Tk()
bindings = {
'<FocusIn>': {'default':'active'},
'<FocusOut>': {'default': 'active'}
}
for k, v in bindings.items():
root.bind_class('Button', k, lambda e, kwarg=v: e.widget.config(**kwarg))
root.title('Calculator')
root.config(bg='red')
Which I found in [this](https://stackoverflow.com/a/58396480/10489787) thread. In short, Windows isn't triggering events correctly, and here what we call ```highlightXXX``` actually have to do with what the button looks like when it's being focused or unfocused (here we want a pink border whether it's focused, with ```highlightcolor```, or unfocused, with ```highlightbackground```).
Instead, we modify Button
's internal workings to make our own events which declare that focusing/unfocusing always activate the button, and so activate its pink border.
EDIT 2: An easier fix for Windows is simply to set the button as active
by default.
root = Tk()
root.title('Calculator')
root.config(bg='red')
x = Button(root, text='...', padx=50, bg='red', fg='black',
highlightcolor='blue',
highlightbackground='blue',
highlightthickness=4,
relief=SOLID,
default='active' #THIS LINE IS NEW
)
x.grid(row=0, column=0)
root.mainloop()