Binding in canvas instruction breaking?

24 views
Skip to first unread message

Gary Johnson

unread,
Aug 27, 2015, 10:57:22 AM8/27/15
to Kivy users support
Hi, 

I've got a widget with a color fill which is bound to an RGB property that changes when a slider is moved. My issue is that after moving the slider around a lot, at some point the binding breaks and the color fill stops updating. The rest of the app continues to function fine and there is no output (including with the --debug flag). This sometimes happens almost immediately, and sometimes takes a while of moving the slider around, but I can make it happen every time. 

I'm not sure how to debug the binding further so posting it here.

Here's the color fill:

<LightControlScreen>:
    canvas.before:
        Color:
            rgb: self.lamp_state.rgb
        Rectangle:
            pos: self.pos
            size: self.size

Here's the self.lamp_state property being bound to:

class LightControlScreen(Screen):

    lamp_state = ObjectProperty(defaultvalue=LampState(), rebind=True, baseclass=LampState)

Here's the LampState rgb property being bound to, which is a ReferenceListProperty made of red, green, blue:

class LampState(EventDispatcher):

    red = BoundedNumericProperty(1.0, min=0.0, max=1.0)
    green = BoundedNumericProperty(1.0, min=0.0, max=1.0)
    blue = BoundedNumericProperty(1.0, min=0.0, max=1.0)
    rgb = ReferenceListProperty(red, green, blue)

    brightness = BoundedNumericProperty(1.0, min=0.0, max=1.0)

When the slider changes, an entirely new LampState instance is created and the property is overwritten:

        new_lamp_state = LampState(red=r,green=g,blue=b,brightness=self.brightness)
        self.lamp_state = new_lamp_state

I verified after the binding breaks that self.lamp_state and self.lamp_state.rgb represent the new values -- the properties are getting set but the canvas just stops updating. 
I did try manually calling self.canvas.ask_update() after the property set, which did not help.

The slider, by the way, is min: 0.0, max: 1.0, step: 0.01. So it doesn't change value as often as it would without step specified but still I'm guessing how fast rgb is updated could have something to do with the problem.

If anyone has any ideas of how to fix or debug it would be much appreciated. I was hoping for some way to observe and debug bindings at runtime but I'm not sure how to get there.

Gary Johnson

unread,
Aug 27, 2015, 11:06:13 AM8/27/15
to Kivy users support
Also, I should mention that I'm using Kivy 1.9.0 installed from PyPi on a Raspberry Pi B 2 with the latest raspbian. Python is version 2.7.3 installed from apt.

Gary Johnson

unread,
Aug 28, 2015, 1:15:27 PM8/28/15
to Kivy users support
Further updates: I tried this on OS X and was not able to reproduce. I built Kivy out of origin/master on the Raspberry Pi and did not seem to make a difference. So maybe a platform-specific issue, or maybe tied to the CPU performance or something. Not sure.


On Thursday, August 27, 2015 at 10:57:22 AM UTC-4, Gary Johnson wrote:
Reply all
Reply to author
Forward
0 new messages