Reputation: 4178
Here is a method that is supposed to draw the canvas of a label:
def update_canvas(self):
c = self.canvas.after
c.clear()
with c:
Color([1, 1, 1, 1])
Line(points=[self.point_from, self.point_to])
if self.texture:
Color([1, 0, 0, 1]) # RED RECTANGLE!
Rectangle(pos=self.pos, size=self.size)
Color([1, 1, 1, 1])
Rectangle(pos=self.pos, texture=self.texture, size=self.texture.size)
The label used as a tooltip which also has a line pointing to the tooltipped item. The above version produces this output:
If I comment out the Rectangle instruction after the RED COLOR line, this is displayed:
Please note that the text's label is rendered twice, because I have also added a Rectangle(texture=self.texture) instruction, but that is for testing only.
The Label itself is added to the window with this simple call:
Windows.add_widget(label)
The question is this: why is my rectangle not red? (Actually I want it to be half transparent.)
Upvotes: 5
Views: 4609
Reputation: 2645
You are passing a list []
to Color()
, while Color
expects at least 3 parameters rgb, rgba, rgb + mode or rgba + mode
try this:
def update_canvas(self):
c = self.canvas.after
c.clear()
with c:
Color(1, 1, 1, 1)
Line(points=[self.point_from, self.point_to])
if self.texture:
Color(1, 0, 0, 1) # RED RECTANGLE!
Rectangle(pos=self.pos, size=self.size)
Color(1, 1, 1, 1)
Rectangle(pos=self.pos, texture=self.texture, size=self.texture.size)
If you want a half transparent rectangle change the rgba to 1,0,0,.5
Upvotes: 4