Is there any way to place transparent images on a frame? #329
-
From my understanding, this can only be done in Tkinter with a canvas widget... Seems kind of odd. Does anyone know of a better way of placing transparent images (.PNG) on the UI? |
Beta Was this translation helpful? Give feedback.
Answered by
abhaymakes
Jul 30, 2022
Replies: 1 comment 2 replies
-
Yes, you can do this with the Import tkinter as tk
import customtkinter as ctk
from PIL import ImageTk, Image
root = ctk.CTk()
transparent_image = ImageTk.PhotoImage(Image.open("image-url/path"))
image_label = ctk.CTkLabel(root, image=transparent_image)
image_label.pack()
#Note : I'm not sure if CTkLabel has an image argument(CTkButton has one)
#if not : Then use this instead of CTkLabel
label = tk.Label(root, image = img)
label.pack()
root.mainloop() |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
kelltom
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, you can do this with the
PIL
module. Below is the implementation: