I want my widgets inside the tkinter application to have a **transparent ****background **to always see the background image i put on root, and I looked all over internet for a solution but nothing seems to work. My code is below and feel free to ask if you have some problems understanding
root = tk.Tk()
root.title("Monster Classifier")
# Set fixed window size and disable resizing
root.geometry("900x900")
root.resizable(False, False)
# Load background image
background_image = Image.open("../images/app background.png")
background_image = background_image.resize((900, 900)) # Match window size
background_photo = ImageTk.PhotoImage(background_image)
# Create a label for the background
background_label = tk.Label(root, image=background_photo)
background_label.place(relwidth=1, relheight=1)
# Main layout frame
main_frame = tk.Frame(root)
main_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
# Image display frames with border
image_frame = tk.Frame(main_frame)
image_frame.grid(row=0, column=0, rowspan=2, padx=10, pady=10)
# Original Image
original_image_frame = tk.Frame(image_frame, bd=5, width=250, height=250)
original_image_frame.pack(padx=50, pady=50)
original_img_label = tk.Label(original_image_frame)
original_img_label.pack()
original_img_display = tk.Label(original_image_frame)
original_img_display.pack()
# Preprocessed Image
preprocessed_image_frame = tk.Frame(image_frame, bd=5, width=250, height=250)
preprocessed_image_frame.pack(padx=50, pady=50)
preprocessed_img_label = tk.Label(preprocessed_image_frame)
preprocessed_img_label.pack(side=tk.TOP)
preprocessed_img_display = tk.Label(preprocessed_image_frame)
preprocessed_img_display.pack()
I tried asking gpt etc and they all said to put bg=”transparent” on the framse but i kept getting an error saying “Transparent” isn’t a valid color. I also tried applying a transparent image as a background but it didn’t work either, so I’m asking you if someone managed to do something similar
1