因此,如果我有一个包含多个子窗口小部件实例的布局,父窗体如何以及何时确保它们都被绘制到屏幕上?假设我们的孩子以一种简单的方式进行动画制作,因此他们不断需要更新。
如果我的ParentLayout类大致如此:
class ParentLayout(ScatterLayout):
def __init__(self):
#
with self.canvas.before:
#hook A
#switchout framebuffer here?
pass
with self.canvas:
#hook B
pass
with self.canvas.after:
#hook C
#recover framebuffer with just this Widget?
pass
Q1:儿童抽奖最终是否被parent.canvas
吸引?
A1:不,不是。帆布充满了指示;它不是缓冲区。
似乎孩子会在hook B
左右被吸引,但我无法确认或测试这一点。
我实际上是在尝试将某些小部件组的屏幕截图重新渲染到缓冲区之后。我想要检索一个表示 ParentLayout 画布的纹理及其子画面......不多也不少。
答案 0 :(得分:1)
Widget already has a method that does this, Widget.export_to_png
.
The canvas is ultimately an ordered list of instructions (mapping to opengl instructions). Drawing the screen involves running through this list, and is guaranteed to happen once per frame, so a simple solution in general is to Clock.schedule_once(your_function, 0) which should run the next frame after everything is rendered.