I have tryed in many ways but i dont find solution for the problem i want to put the text background transparent
#Text where the background is black
Download=Label(root,text="00",font="calibri 40 bold",bg="#000000",fg="white")
Download.place(x=320,y=261,anchor="center")
i want to turn black background to transparent background
i want to turn black text background to transparent background
CodePudding user response:
tkinter Label
does not support transparent. But you can use Canvas
as the background and its drawing function .create_text(...)
to draw some text on it with transparency.
Below is a simple example:
import tkinter as tk
root = tk.Tk()
canvas = tk.Canvas(root, width=400, height=300, highlightthickness=0)
canvas.pack()
# background image
img = tk.PhotoImage(file="images/background.png")
canvas.create_image(400, 300, image=img)
# draw text
canvas.create_text(320, 261, text="00", font="calibri 40 bold", fill="white")
root.mainloop()
And the result: