Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEP: allow tuple/list coordinates for Line.points #3481

Closed
kived opened this issue Jul 2, 2015 · 5 comments
Closed

KEP: allow tuple/list coordinates for Line.points #3481

kived opened this issue Jul 2, 2015 · 5 comments
Labels
Component: graphics kivy/graphics easy Should be easy to fix KEP Proposals for Kivy

Comments

@kived
Copy link
Contributor

kived commented Jul 2, 2015

Could be handled at assignment time.

if points and isinstance(points[0], (list, tuple)):
    points = list(itertools.chain(*points))

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

@kived kived added Component: graphics kivy/graphics easy Should be easy to fix KEP Proposals for Kivy labels Jul 2, 2015
@spinningD20
Copy link

Thanks for suggesting this officially. I would think most use-cases in kivy for Line points would be tuples or something similar, like widget.pos, widget.center. Is there a use case where a list of x, y, x, y makes more sense?

@udiboy1209
Copy link
Contributor

I'd like to work on this issue! Could you tell me where to start ?

@tshirtman
Copy link
Member

@udiboy1209
Copy link
Contributor

I made the change suggested by @kived and tried testing it using the lines example: https://github.com/kivy/kivy/blob/master/examples/canvas/lines.py#L142

When I run the example as it is, it works. But when I change the points declaration to this

points = ListProperty([(500, 500), 300, 300, 500, 300, 500, 400, 600, 400])

it shows error:

Exception TypeError: 'a float is required' in 'kivy.graphics.vertex_instructions.SmoothLine.build_smooth' ignored

I dont know whats wrong and what float is required? Does it mean that the elements in the list (coordinate values) should be float, but it is getting a tuple? (which would mean the change isn't working). Please help!

udiboy1209 added a commit to udiboy1209/kivy that referenced this issue Dec 23, 2015
Fix for issue kivy#3481
Line.points can be defined as list of lists, tuples and
coordinates (float values)
setter method modified to check each element of the argument
list and append it to self._points accordingly
Line example file /examples/canvas/line.py updated with the new
possible way of defining points
@dessant
Copy link
Contributor

dessant commented Feb 1, 2016

Fixed in #3866.

@dessant dessant closed this as completed Feb 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: graphics kivy/graphics easy Should be easy to fix KEP Proposals for Kivy
Projects
None yet
Development

No branches or pull requests

5 participants