简体   繁体   English

WXPython中各个小部件的不透明度

[英]Opacity of individual widgets in WXPython

Is it possible to control the opacity of individual widgets in WXPython? 是否可以在WXPython中控制各个小部件的不透明度?

I know I can make the Frame transparent with self.SetTransparent(150) , is there a way to do this for individual widgets? 我知道我可以使用self.SetTransparent(150)使Frame透明,有没有办法为单个小部件执行此操作?

Since nearly everything visible inherits from wx.Window, you can use item.SetTransparent() on most widgets. 由于几乎所有可见的都继承自wx.Window,因此您可以在大多数小部件上使用item.SetTransparent()。

Not everything can go transparent though. 不是所有东西都可以透明。 To check: 去检查:

if button.CanSetTransparent():
    button.SetTransparent(100)

But as the wxPython documentation says: 但正如wxPython文档所说:

Returns True if the platform supports setting the transparency for this window. 如果平台支持设置此窗口的透明度,则返回True。 Note that this method will err on the side of caution, so it is possible that this will return False when it is in fact possible to set the transparency. 请注意,此方法在谨慎方面会出错,因此当实际可以设置透明度时,可能会返回False。

So this isn't very reliable. 所以这不是很可靠。 I would just go ahead and try to set the transparency. 我会继续尝试设置透明度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM