赞
踩
- from kivy.app import App
- from kivy.graphics import Line, Color
- from kivy.uix.widget import Widget
- from kivy.core.text import LabelBase
- from kivy.utils import get_color_from_hex
-
-
- get_color_from_hex("#19cadd")
- LabelBase.register("Roboto", "HelloKitty.TTF")
-
-
- class DrawCanvasWidget(Widget):
- def __init__(self,**kwargs):
- super(DrawCanvasWidget, self).__init__(**kwargs)
- # 设置默认值
- self.change_color(get_color_from_hex("#19caad"))
- self.canvas.add(Color(rgb=[0, 0, 0]))
- self.line_width = 2
-
- def on_touch_down(self, touch):
- """触摸显示轨迹"""
- if Widget.on_touch_down(self, touch):
- return
- with self.canvas:
- touch.ud["current_line"] = Line(points=(touch.x, touch.y), width=self.line_width)
-
- def on_touch_move(self, touch):
- """连线"""
- if "current_line" in touch.ud:

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。