Return from canvas.get_group() call in kivy

Deadly 提交于 2019-12-12 02:45:42

问题


Calling get_group() from an instruction group yields back more that what I wanted.

I have the following code:

for widget in self.selected:
    dx, dy = (
        widget.pos[0] - self.pos[0],
        widget.pos[1] - self.pos[1]
    )
    self.shadows.add(Rectangle(size=widget.size, pos=widget.pos, group='my_shadows'))

self.canvas.add(self.shadows)

print self.shadows.get_group('my_shadows')

which in turn produces the following result:

<kivy.graphics.context_instructions.BindTexture object at 0x7ff992377050>
<kivy.graphics.vertex_instructions.Rectangle object at 0x7ff99493e638>
<kivy.graphics.context_instructions.BindTexture object at 0x7ff9923770e8>
<kivy.graphics.vertex_instructions.Rectangle object at 0x7ff99493e6e0>

What are BindTextures and why are they returned through get_group()? I expected only Rectangles. If i intend to manipulate my Rectangles, do I need to do the same with my BindTextures?


回答1:


Maybe you've already noticed that with Rectangle you can set a background image of a Widget. That's what BindTexture is for as it provides source parameter for a path to an image that can be used as a background.

If you don't intend to use those Rectangles as background images (from file, not drawing with Color + Rectangle), I think it is safe to ignore the textures.



来源:https://stackoverflow.com/questions/39476837/return-from-canvas-get-group-call-in-kivy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!