python label背景透明_Python Tkinter标签背景透明

I have a window with a label as my frame. I did this because i wanted an image in the background. But now im having trouble with the other labels i have used. The other labels i have used to actually labeled things dont have a transparent background. Is there a way to make the background of these labels transparent?

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')

button2.pack(side='top')

# start the event loop

root.mainloop()

解决方案

It is not supported with transparent backgrounds in Tk.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值