As you can see above, you can envelope the points by () or [], you can line the points one by one or line them all together if you wish (The examples show down below).
from kivy.app import App from kivy.uix.floatlayout import FloatLayout from kivy.lang import Builder
Builder.load_string(''' <LinePlayground>: # assign a list variate as point so it could be easliy handled in later point: [0,0, 200, 100] canvas: Color: rgba: .4, .4, 1, 1 Line: # recall the variate 'point' above points: self.point ''' )
If you are not satisfied with drawing a line and want to create an animation, than like do some thing cool.
updating…
from kivy.app import App from kivy.properties import ListProperty
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.widget import Widget from kivy.lang import Builder from kivy.clock import Clock from kivy.properties import ObjectProperty
## Remove unnecessary codes from this class classLinePlayground(FloatLayout): pass
classMain_app(Widget): # assign a numeric variate i = 0 # connect the class in kv file: line -> line_ground -> LinePlayground
line = ObjectProperty(None)
defupdate(self, dt): self.i +=1 # update the point self.line.point = [[0,0,], [self.i,self.i]] print(self.line.point) print(self.line) print("1")
classTestLineApp(App): defbuild(self): Main = Main_app() # update the result with 60 fps (1/60) Clock.schedule_interval(Main.update,1/60) return Main
if __name__ == '__main__': TestLineApp().run()
testline.kv file:
<LinePlayground>: # assign a list variate as point so it could be easliy handled in later point: [0,0, 200, 100] canvas: Color: rgba: .4, .4, 1, 1 Line: # recall the variate 'point' above points: self.point
<Main_app>: # assign the id which could be recall later line: line_ground