0

In the following code the ellipse gets displayed with no transparency (alpha=1). Probably when self.color changes, the alpha is set to 1 (interestingly this doesn't happen if the color is set to (1,1,1) in the setup method).

Is there a way to change the color without changing the alpha?

I would like to set the alpha in the kv file and change the color from python.

Thanks

alpha.kv:

#:kivy 1.9.1

<MyWidget>:
    color: 1,1,1
    canvas:
        Color:
            hsv: self.color
            a: 0.3
        Ellipse:
            pos: (200, 200)
            size: (30, 30)

main.py:

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ReferenceListProperty

class MyWidget(Widget):
    colorH = NumericProperty(1)
    colorS = NumericProperty(1)
    colorV = NumericProperty(1)
    color = ReferenceListProperty(colorH,colorS,colorV)

    def setup(self):
        self.color = (0.5,1,1)
#        self.color = (1,1,1) # here the alpha doesn't change

class AlphaApp(App):
    def build(self):
        w = MyWidget()
        w.setup()
        return w

if __name__ == '__main__':
    AlphaApp().run()
davide
  • 11
  • 3
  • I think this is a bug. You can possibly work around it with something silly like `a: 0.3 or self.color`. – inclement Sep 26 '16 at 10:32
  • Replace `a: 0.3` with `a: 0.3 or self.color` in the kv file? This didn't solve the problem unfortunately. Where would be a good place to ask if this is a bug? On the kivy forum? – davide Sep 26 '16 at 20:01

0 Answers0