I'm exporting a png with transparent background: This is how it looks when it's exported: and this is how it is displayed in Tkinter:
我的代码是:
import tkinter as tk
import tkinter.ttk as ttk
from PIL import Image, ImageTk
import customtkinter
root = tk.Tk()
root.geometry("800x480")
root.resizable(False, False)
background_black = ImageTk.PhotoImage(file="background_black.png")
turn_on = ImageTk.PhotoImage(file="turn_on.png")
tk.Label(root, image=background_black).pack()
button = tk.Button(root, image=turn_on, borderwidth=0, highlightthickness=0, relief=tk.FLAT)
button.place(relx=0.5, rely=0.5, anchor=tk.CENTER)
root.mainloop()
原本应该是透明的区域却变成了白色,我该如何解决这个问题? 我提供了前2张图片,以防我在出口时做错了什么,而不是在我的代码中.