tkinter中小部件的透明度问题

发布于 01-22 14:25 字数 441 浏览 2 评论 0原文

我设计了一个具有图像作为其背景的表单,然后使用画布,然后想在画布上放上其他具有透明背景的小部件。为此,我使用了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:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罗罗贝儿2025-01-29 14:25:44

使用pywinstyles软件包pip install pywinstyles

pywinstyles.set_opacity(widget, color='#2a1863')

确保标签的bg颜色设置为“#2A1863'

Use the pywinstyles package pip install pywinstyles

pywinstyles.set_opacity(widget, color='#2a1863')

Make sure that the bg color of label is set to '#2a1863'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文