click or drag and drop to move rectangle
#draw.py
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Rectangle
from kivy.graphics import Color
from kivy.graphics import Line
class Draw(Widget):
def __init__(self, **kwargs):
super(Draw, self).__init__()
with self.canvas:
Color(0, 1, 0, .5, mode='rgba')
Line(points=(20, 30, 400, 500, 60, 500))
Color(1, 0, 0, 0.5, mode='rgba')
self.rect = Rectangle(pos=(100, 100), size=(50, 100))
def on_touch_down(self, touch):
self.rect.pos = touch.pos
def on_touch_move(self, touch):
self.rect.pos = touch.pos
class DrawApp(App):
def build(self):
return Draw()
DrawApp().run()
reference:
No comments:
Post a Comment