从kivy中的canvas.get_group()调用返回 [英] Return from canvas.get_group() call in kivy

查看:84
本文介绍了从kivy中的canvas.get_group()调用返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从指令组中调用get_group()会得到比我想要的更多的东西.

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

我有以下代码:

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>

什么是BindTextures,为什么它们通过get_group()返回?我只希望矩形. 如果我打算操纵矩形,是否需要对BindTextures做同样的事情?

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?

推荐答案

也许您已经注意到,使用Rectangle可以设置Widget的背景图像.这就是 BindTexture 的用途,因为它提供了source参数,用于指向可用作背景的图像的路径.

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.

如果您不打算将这些矩形用作背景图像(来自文件,而不是使用Color + Rectangle进行绘制),我认为忽略纹理是安全的.

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.

这篇关于从kivy中的canvas.get_group()调用返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆