问题
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