向自定义tkinter 图像添加按钮时出现问题

问题描述 投票:0回答:1

我想使用customtkinter制作一个简单的dhikrmatik(当按下按钮时,数字会增加并写在屏幕上)应用程序。我添加了背景图片,并想在图片上添加按钮,但结果如图所示。您的文字解决方案是什么?本文是用谷歌翻译写的,如有错误,敬请谅解。谢谢

在此输入图片描述

from PIL import Image import customtkinter customtkinter.set_appearance_mode("systemTransparent") root= customtkinter.CTk() root.geometry("400x550") my_image= customtkinter.CTkImage( dark_image=Image.open("zikirmat\image2.png"), light_image=Image.open("zikirmat\image.png"), size=(300,300)) my_label =customtkinter.CTkLabel(root, width=30, height=35, image=my_image, text="") my_label.place(x=50,y=5) button =customtkinter.CTkButton(root, text="", width=110, height=110, corner_radius=100, ) #button.configure(bg="white", alpha=0.5) button.place(y=180,x=100) root.mainloop()
    
python
1个回答
0
投票
使用框架来包围图像(背景图像和标签,该标签将保存每次按下按钮时要递增的值,然后具有一个功能来配置每次按下按钮时的标签(递增它)

© www.soinside.com 2019 - 2024. All rights reserved.