Python Kivy:移动时生成/绘制身后轨迹的对象

Python Kivy:移动时生成/绘制身后轨迹的对象,python,python-2.7,kivy,Python,Python 2.7,Kivy,早上好/晚上好:-) 我在跟踪一段视频,试图在移动时从圆圈生成一条“轨迹”,轨迹是黄线。最好显示一幅图像,而不是长篇大论: -有人能帮我消除这个错误吗? -我真的不知道如何生成轨迹。。。 …也许是像绘画应用程序那样画点,但“触动”应该是像触动…也许 (我将在最后发布一段代码) 错误: /ex38.kv”,第24行: ... 22:位置:300,根。顶部-100 23:案文: >>24:(“[size=32][color=88FF22]”+ 25:root.ball.anim_选择+ 26

早上好/晚上好:-)

我在跟踪一段视频,试图在移动时从圆圈生成一条“轨迹”,轨迹是黄线。最好显示一幅图像,而不是长篇大论:


-有人能帮我消除这个错误吗? -我真的不知道如何生成轨迹。。。 …也许是像绘画应用程序那样画点,但“触动”应该是像触动…也许
(我将在最后发布一段代码)


错误:
/ex38.kv”,第24行:
...
22:位置:300,根。顶部-100
23:案文:
>>24:(“[size=32][color=88FF22]”+
25:root.ball.anim_选择+
26:“[/color][/size]”)
...
/ex38.kv”,第24行:
...
22:位置:300,根。顶部-100
23:案文:
>>24:(“[size=32][color=88FF22]”+
25:root.ball.anim_选择+
26:“[/color][/size]”)
...
AttributeError:“Label”对象没有属性“ball”

主要Python:
#ex38.py
从kivy.uix.widget导入widget
从kivy.app导入应用程序
从kivy.animation导入动画
从kivy.properties导入StringProperty
从kivy.lang导入生成器
Builder.load_文件('ex38.kv')
类球(小部件):
anim_choice=StringProperty('触按以设置球动画')
计数器=0
def on_触控向下(自身,触控):
动画。全部取消(自身)
动画选项=[“返回”、“反弹”、“循环中”,
“in_cubic”、“in_elastic”、“in_expo”,
“输入输出返回”、“输入输出反弹”、“输入输出循环”,
“out_sine”]
self.anim_choice=动画选择[self.counter]
动画=动画(中心x=touch.x,
中心y=touch.y,
t=自我动画(选择)
动画开始(自我)
self.counter=(self.counter+1)%len(动画选项)
类Ex38(小部件):
通过
Ex38App类(应用程序):
def生成(自):
返回Ex38()
如果“名称”=“\uuuuuuuu主要”:
Ex38App().run()
基维: 致以最诚挚的问候,希望您感兴趣

# ex38.kv

<Ball>:
    size: 65,60
    canvas:
        Color:
            rgb: 0.75,0,0
            Ellipse:
                pos: self.pos
                size: self.size

<Ex38>:
    ball: ball_id
    canvas:
        Color:
            rgb: 0,0,1
        Rectangle:
            size: root.width,root.height
            pos: 0,0

Label:
    pos: 300,root.top-100
    text:
        ( '[size=32][color=88FF22]' +
        root.ball.anim_choice +
        '[/color][/size]' )
    markup: True 
<Ball>:
    id: ball_id
def on_touch_move(self, touch): #That one shouldn't be for the mouse but related to our Ellipse
        global length,n_points,last_x,last_y
        if touch.button=='left':
            touch.ud['line'].points += [touch.x, touch.y]
            x = int(touch.x)
            y = int(touch.y)
            length += np.sqrt(max((x - last_x)**2 + (y - last_y)**2, 2))
            n_points += 1.
            density = n_points/(length)
            touch.ud['line'].width = int(20*density + 1)
            sand[int(touch.x) - 10 : int(touch.x) + 10, int(touch.y) - 10 : int(touch.y) + 10] = 1
            last_x = x
            last_y = y