How can I draw lines between these points that attaches them also during dragg movement via widget properties?
os.environ['KIVY_GL_BACKEND'] = 'sdl2'
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.widget import Widget
from kivy.graphics import Rotate, Rectangle, Line, Ellipse, Color
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.core.window import Window
from random import randint
background_color: 0,0,0,1
text: 'Moderate curve or straight canals'
background_color: 128,0,0,1
on_press: root.manager.transition.direction = 'left'
on_press: root.manager.current = 'straight'
orientation: 'horizontal'
class MainScreen(Screen):
class LearnScreen(Screen):
# class StraightScreen(Screen):
class StraightScreen(Screen):
class CircleWidget1(Widget):
def __init__(self, **kwargs):
super(CircleWidget1, self).__init__(**kwargs)
self.circle = Ellipse(pos=self.pos, size=self.size)
circle2=self.add_widget(CircleWidget2(pos=(200,200), size=(2,2)))
circle3=self.add_widget(CircleWidget3(pos=(200,100), size=(2,2)))
self.bind(pos=self.redraw, size=self.redraw)
self.circle.size = self.size
self.circle.pos = self.pos
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
# if the touch collides with our widget, let's grab it
return super(CircleWidget1, self).on_touch_down(touch)
def on_touch_up(self, touch):
# check if it's a grabbed touch event
if touch.grab_current is self:
# don't forget to ungrab ourself, or you might have side effects
return super(CircleWidget1, self).on_touch_up(touch)
def on_touch_move(self, touch):
# check if it's a grabbed touch event
if touch.grab_current is self:
# and accept the last move
return super(CircleWidget1, self).on_touch_move(touch)
class CircleWidget2(Widget):
def __init__(self, **kwargs):
super(CircleWidget2, self).__init__(**kwargs)
self.circle = Ellipse(pos=self.pos, size=self.size)
self.bind(pos=self.redraw, size=self.redraw)
self.circle.size = self.size
self.circle.pos = self.pos
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
# if the touch collides with our widget, let's grab it
return super(CircleWidget2, self).on_touch_down(touch)
def on_touch_up(self, touch):
# check if it's a grabbed touch event
if touch.grab_current is self:
# don't forget to ungrab ourself, or you might have side effects
return super(CircleWidget2, self).on_touch_up(touch)
def on_touch_move(self, touch):
# check if it's a grabbed touch event
if touch.grab_current is self:
# and accept the last move
return super(CircleWidget2, self).on_touch_move(touch)
class CircleWidget3(Widget):
def __init__(self, **kwargs):
super(CircleWidget3, self).__init__(**kwargs)
self.circle = Ellipse(pos=self.pos, size=self.size)
self.bind(pos=self.redraw, size=self.redraw)
self.circle.size = self.size
self.circle.pos = self.pos
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
# if the touch collides with our widget, let's grab it
return super(CircleWidget3, self).on_touch_down(touch)
def on_touch_up(self, touch):
# check if it's a grabbed touch event
if touch.grab_current is self:
# don't forget to ungrab ourself, or you might have side effects
return super(CircleWidget3, self).on_touch_up(touch)
def on_touch_move(self, touch):
# check if it's a grabbed touch event
if touch.grab_current is self:
# and accept the last move
return super(CircleWidget3, self).on_touch_move(touch)
class RootWidget(Widget):
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
circle1=self.add_widget(CircleWidget1(pos=(200,300), size=(2,2)))
sm.add_widget(StraightScreen(name='straight'))
if __name__ == '__main__':