SShield
SShield

Reputation: 37

How to get rid of annoying border around buttons when changing the background of a window in Tkinter

I want to change the background of a window from Tkinter, but a white border is showing up around the button. I tried the bd=0 argument, but it only removed the bottom border piece, not the side border and top border. Could someone please help me get rid of the whole border? Thanks.

from tkinter import *
import os
window=Tk()
window.geometry("400x400")
window['background']='#9ed7c3'
def printt():
    print(2+2)
editbtn=Button(text='Edit Settings', command=printt, bd=0)
editbtn.pack()

Upvotes: 0

Views: 69

Answers (1)

Rory
Rory

Reputation: 694

That is the default appearance of the Button widget. You could use the FLAT option for the button appearance and make the background the same color as your window, but then it is very hard to tell that it is a button because you loose the border.

from tkinter import *
import os # this isn't being used


window = Tk()
window.geometry("400x400")
window['background']='#9ed7c3'


def printt():
    print(2+2)

    
editbtn = Button(text='Edit Settings', relief=FLAT, bg='#9ed7c3', command=printt )
editbtn.pack()


window.mainloop()

enter image description here

Upvotes: 1

Related Questions