CustomTkinter添加图片显示灰色方块而非正常图像的问题
问题:按钮旁添加图标显示灰色方块(CustomTkinter环境)
我尝试在应用的按钮旁添加小图标,但导入并放置图像后仅显示灰色方块。所用图像为非透明JPG格式,也尝试过PNG格式,期望支持透明PNG。窗口包含侧边栏和主屏幕两个框架,使用CustomTkinter库,图像与py文件同目录。
相关代码如下:
home_button = customtkinter.CTkButton(left_frame, text="Home", width=195, height=40, corner_radius=10, text_font=["", "16"], fg_color=["#ffffff", "#000000"], hover_color=["#f4f5fa", "#1d1e20"], command=home ) home_button.place(x=50, y=80) home_button.text_label.grid(sticky="w") home_ico = ImageTk.PhotoImage(Image.open("home_def.jpg")) home_label = Label(image=home_ico) home_label.place(x=20, y=80)
添加图像前后的GUI截图:

内容的提问来源于stack exchange,提问作者volcaniceruption09845
相关产品推荐
相关产品推荐

