我有一个Popup
,我想使其背景透明。我通过将app.root
渲染到Fbo
来获得模糊的图片,但是当我从app.root
恢复Fbo
小部件时,并不是每个帧都渲染该小部件,而是仅当运行任何窗口小部件上的Animation
或拖动窗口时。完整文件在这里:https://github.com/XtremeWare/XtremeUpdater/blob/master/src/main.py#L493
代码段:
def render_background(*args):
fbo = Fbo(size=app.root.size, with_stencilbuffer=True)
with fbo:
Scale(1, -1, 1)
Translate(-app.root.x, -app.root.y - app.root.height, 0)
fbo.add(app.root.canvas)
fbo.draw()
tex = fbo.texture
fbo.remove(app.root.canvas)
tex.flip_vertical()
img = Image.frombytes('RGBA', tex.size, tex.pixels)
img = img.filter(ImageFilter.GaussianBlur(50))
tex = Texture.create(size=img.size)
tex.blit_buffer(
pbuffer=img.tobytes(), size=img.size, colorfmt='rgba')
tex.flip_vertical()
self.canvas.before.get_group('blur')[0].texture = tex
Clock.schedule_once(render_background)
答案 0 :(得分:0)
我知道了。以下行必须位于结束。
Window.canvas.insert(0, app.root.canvas)