我是Python的新手.我想创建一个以图像为背景的应用程序.但是当我在图像上添加"标签"时,我可以看到标签的白色背景.我们是否有解决方案使"标签"小部件颜色设置为"透明"?
我有一个带有标签的窗口作为我的框架.我这样做是因为我想在后台拍摄一张照片.但是现在我遇到了我用过的其他标签的问题.我用来实际标记的其他标签没有透明的背景.有没有办法让这些标签的背景透明?
import Tkinter as tk
root = tk.Tk()
root.title('background image')
image1 = Tk.PhotoImage(file='image_name.gif')
# get the image size
w = image1.width()
h = image1.height()
# make the root window the size of the image
root.geometry("%dx%d" % (w, h))
# root has no image argument, so use a label as a panel
panel1 = tk.Label(root, image=image1)
panel1.pack(side='top', fill='both', expand='yes')
# put a button/label on the image panel to test it
label1 = tk.Label(panel1, text='here i am')
label1.pack(side=Top)
button2 = tk.Button(panel1, text='button2') …Run Code Online (Sandbox Code Playgroud)