tkinter中小部件的透明度问题
我设计了一个具有图像作为其背景的表单,然后使用画布,然后想在画布上放上其他具有透明背景的小部件。为此,我使用了root.wm_attributes(' - 透明冠军','#2A1863')
,然后是具有该颜色作为背景颜色的窗口透明背景,但我期望,我看不到,我看不到,帆布背景图像,相反,我看到了我的LCD屏幕上的内容。 我修改了我的代码,以使用Canvas.Create_Text(text =“ Welcome!”)
显示我想在画布上放置标签的内容。问题不仅限于标签小部件。 下面是由我的代码产生的图像:
I designed a form having an image as its background using a Canvas, then I want to put other widgets with transparent background over the Canvas. To do that I used root.wm_attributes('-transparentcolor', '#2a1863')
and then the widgets having that colour as background color assune a transparent background but I do not see, as I would expect, the canvas background image, instead I see what is on my LCD screen.
I modified my code to display a text on the canvas using canvas.create_text(text="Welcome!")
just to show what I want to have putting a Label over the Canvas. The problem is not limited only to Label widget.
Below there is the image as produced by my code:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

使用pywinstyles软件包
pip install pywinstyles
确保标签的bg颜色设置为“#2A1863'
Use the pywinstyles package
pip install pywinstyles
Make sure that the bg color of label is set to '#2a1863'