Reputation: 4355
When I put a button in on a colored background TKinter leaves this weird white box around the widget. For example the code below:
from Tkinter import *
root = Tk()
root.geometry("300x100+300+300")
root.configure(bg="red")
button = Button(root, text="Connect", highlightthickness=0)
button.pack()
root.mainloop()
What can I do to get rid of the white spacing?
Upvotes: 4
Views: 6001
Reputation: 3030
For anyone looking for something similar in ttkbootstrap
, you can use:
button = Button(root, text="Connect", takefocus=0)
This should work on OSX too.
Upvotes: 0
Reputation: 5754
This problem has been plaguing Macs for years. But as of Python 3.7 it's safe-ish to install from Python.org instead of Homebrew. This problem disappears when Python is installed from Python.org instead of running the Homebrew version.
Upvotes: 2
Reputation: 385970
The extra border is caused by the highlightthickness
attribute. The default value is 1 (one); set it to zero to remove the border. This border shows when the button has keyboard focus.
However, it appears you're running this on OSX. OSX buttons are a bit less configurable than on other platforms. Setting highlightthickness to zero won't help. The best you can do is set highlightbackground
to the same color as your background so that it blends in.
Upvotes: 10