Consistency in properties/call parameters through kivy. #853

Open
tshirtman opened this Issue Dec 11, 2012 · 2 comments

4 participants

@tshirtman
Kivy member

what's good

Consistency matters, i think kivy is great because the properties system makes it easy to set attributes values by passing through kwargs, and that kv lang map theses concepts perfectly.

examples:

python:

w = Widget(size=(150, 100), size_hint=(None, None), pos=(200, 200))

kv:

Widget:
    size: 150, 150
    size_hint: None, None
    pos: 200, 200

and you can access w.size/pos/etc from python, that's great, the world is beautiful, birds singings in the heavens.

what's bad

Now, lets add some decoration, in kv you'd do:

kv:

Widget:
    canvas:
        Color:
            rgb: 1, 0, 1
        Rectangle:
            pos: 1, 1
            size: root.width - 2, root.height - 2

Nice heh?
the same can be achieved in python using:

python:

with w.canvas:
    Color(1, 0, 1, mode='rgb')
    Rectangle(pos=(1, 1), size=(w.width - 2, w.height - 2))

What's wrong there? well Rectangle follow the exact same convention seen before, that's great, but Color? not so much, that would be Color(rgb=(1, 0, 1)), but that doesn't work, and the kivy beautiful world falls apart, everything is a lie, and you feel the urge to check the syntax of everything in the doc again, because that assumption you had build up when "getting" kivy is not true anymore.

And it's not getting any better… Translate, Rotate, Scale are the same, and probably others.

what to do?

Now, of course it would be bad to break the old syntax, that would require rewrite of a lot of code, and there are people out there with kivy apps, so we need to keep it working, but i think it would be great to provide an alternate syntax, so the same way of thinking can be applied everywhere, that is, everything is a property, you can set it by passing as named parameter, the same as in kv, and get it from the thing under the same name.

I hope this is possible, and that it won't cost a lot of performances, @tito thinks it will cost some, but i think consistency is a feature, and that if the cost ain't too high, we should have it.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@CreamyCookie

Breaking backwards compatibility is needed for keeping the code clean. If you do not, the code will rot, slowly degrade and thus slow down developement.

Perhaps do it like Python. Make changes that break backward compatibility, but only in new major versions and list them in the change log so that everyone can see that certain things work differently now.

@tito
Kivy member

I agree, the graphics part/core part are different, because they were done prior to the widget. Properties give us consistency. We can try to at least get the graphics more consistent.

@dessant dessant modified the milestone: 2.0, 2.0.0 Jan 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment