[英]Python tkinter label background image
我想在 label 上放置背景图像,但文本仍在显示。
img = tk.Photoimage(file = "image.png")
tk.Label(root, text = "test", image = img).pack()
但文字不显示。 我认为它被图像覆盖了。
您需要使用Label
的compound
选项来告诉如何将文本和图像放在一起:
tk.Label(root, text='test', image=img, compound='center')
将文本放在图像的中心。
其他选项:
'left', 'top', 'right', 'bottom': put the image at the specified side of text.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.