tkinter python中的透明画布 [英] Transparent canvas in tkinter python

查看:68
本文介绍了tkinter python中的透明画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要让画布透明,并坐在按钮、标签等前面(使仅使用画布背景的想法不切实际).所以当用户画东西时,它会出现在所有的小部件上.

I need to have the canvas to be transparent and sit in front of buttons, labels ect (Making the idea of just using a canvas background impracticable). So when the user draws stuff, it will appear over all of the widgets.

在这一点上很明显这可能是不可能的.所以考虑到我遇到的问题,有人可以推荐一个图书馆,或者我错过了什么?

At this point it's being clear that this may be impossible. So given the problem I have can someone either suggest a library, or maybe I missed something?

干杯.

推荐答案

使 Canvas 透明是不可能的(正如已经说过的 此处) 但您可以尝试使用 wxPython.

Making the Canvas transparent is not possible (as already said here) but you can try with wxPython.

否则,我建议您创建两个画布:一个带有小部件,另一个带有伪造小部件的背景图像.然后你可以只显示你想要使用的框架并隐藏另一个(使用选项 state=HIDDEN).但这会使您在绘图时无法使用小部件.我想不出更好的解决方案.

Otherwise, I suggest that you create two canvases: one with the widgets and one with a background image that fakes the widgets. Then you could just show the frame that you want to use and hide the other (using the option state=HIDDEN). But that would make the widgets unusable while you are drawing. I can't come up with a better solution.

这篇关于tkinter python中的透明画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆