5

It works with some other widgets, but not with Buttons.

from Tkinter import *
root = Tk()
root.geometry("600x300+400+50")

btn_up = Button(root, text='Go UP')
btn_up.config(highlightbackground="red", highlightcolor="red", highlightthickness=10, relief=SOLID)
btn_up.pack()

root.mainloop()

Python 2.7 - Windows 10

Maicon Erick
  • 127
  • 1
  • 11
  • Does it error or does it just not give it a thickness with a color? – Goralight Nov 17 '17 at 14:26
  • Oh, I left a `bd=3` by mistake there, I'll take it out. – Maicon Erick Nov 17 '17 at 14:28
  • 1
    It just shows the black border, no errors and no colors. – Maicon Erick Nov 17 '17 at 14:29
  • Also, `highlightthickness` doesn't work, it is displayed just the 2px border. – Maicon Erick Nov 17 '17 at 14:30
  • `highlightthickness` isn't the border. It's a separate thing. Tkinter provides no control over the border color. Do you _really_ need to change the color of the border, or do you simply want to surround it with a line of a specific color? In other words, there may be a way to do what you want, just not in the way you want to do it. – Bryan Oakley Nov 17 '17 at 14:35
  • Yeah, I could put the button within a frame with a color I guess, I was just wondering why these options I saw in the documentation weren't working. It'd be nice to have a border that isn't black, though. – Maicon Erick Nov 17 '17 at 14:43

1 Answers1

4

I am using linux and when I run your code, I get a button with a thick red border, so it looks like that the default Windows theme does not support highlightthickness while the default linux theme does.

screenshot

If you want to change the border color, it is possible with some ttk themes like 'clam':

from Tkinter import *
import ttk
root = Tk()

style = ttk.Style(root)
style.theme_use('clam')
style.configure('my.TButton', bordercolor="red")

ttk_button = ttk.Button(root, text='Go UP', style='my.TButton')
ttk_button.pack()

root.mainloop()

screenshot clam

However, changing the borderwidth, with style.configure('my.TButton', borderwidth=10) does not increase the width of the red border as expected.

j_4321
  • 15,431
  • 3
  • 34
  • 61
  • If python 3.x, replace `Tkinter` with `tkinter` and `import ttk` with `from tkinter import ttk`. – Nae Dec 23 '17 at 21:36