Assign group name to kivy graphic instruction
<p>This seems like it should be really simple, yet I have failed to find a way to do it.</p>

<p>In order to iterate over the instructions on my canvas, I am supposed to use <code>canvas.get_group()</code> method. In order to do that, I first need to assign a group name to whichever instructions I intend to iterate over. How does one do that?</p>

<p>Use <code>InstructionGroup()</code>. This is an example from kivy documentations:</p>

<pre><code>blue = InstructionGroup()
blue.add(Color(0, 0, 1, 0.2))
blue.add(Rectangle(pos=self.pos, size=(100, 100)))

green = InstructionGroup()
green.add(Color(0, 1, 0, 0.4))
green.add(Rectangle(pos=(100, 100), size=(100, 100)))

# Here, self should be a Widget or subclass
[self.canvas.add(group) for group in [blue, green]]
</code></pre>

python kivy kivy-language