Tkinter Label background?

I have another problem with Tkinter.

As you can see in the image, the labels have a gray background by default. Now that I have the label set as the background, I would like the gray to disappear from the text labels for obvious reasons. How can I get the background transparency of the labels?

from Tkinter import *

# ***** Start of Gui *****
root = Tk()
root.title("Here could be your ad")
root.resizable(False, False)

# ***** Background *****
photo = PhotoImage(file="recycled.gif")
background_label = Label(root, image=photo), y=0, relwidth=1, relheight=1)
background_label.image = photo

# ***** Text *****
l1 = Label(root, text="Here could be your ad")
l2 = Label(root, text="Here could be your ad")
l3 = Label(root, text="Here could be your ad")
l4 = Label(root, text="Here could be your ad")

l1.grid(row=0, sticky=W)
l2.grid(row=1, sticky=W)
l3.grid(row=2, sticky=W)
l4.grid(row=3, sticky=W)

# ***** Variables for Input *****
var0 = StringVar()
var1 = StringVar()
var2 = StringVar()
var3 = StringVar()

# ***** Input Boxes *****
e1 = Entry(root, textvariable=var0)
e2 = Entry(root, textvariable=var1)
e3 = Entry(root, textvariable=var2)
e4 = Entry(root, textvariable=var3)

e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
e3.grid(row=2, column=1)
e4.grid(row=3, column=1)

b = Button(root, text="Here could be your ad", bg='blue')
b.grid(row=4, column=1)




source to share

1 answer

You can not. Labels do not support transparency.

The best solution is probably to use a canvas for the background and use text objects instead of labels, since text objects only draw the text, not the background.



All Articles