Python 显示生产线是否为kivy

Python 显示生产线是否为kivy,python,kivy,line,draw,Python,Kivy,Line,Draw,是否可以显示正在绘制的线,而不是立即显示的线。我试图制作多个加载条并旋转,但我认为制作线条会更简单一些。 我有我想要遵循的大纲,每个直角都是自己画的线。On_pre_enter我的输出线已经给出,On_enter红色线已经绘制,但我希望在给定时间内输入时绘制红色线。我用self.canvas.before在后面添加了amin行:但是屏幕是动画的,而不是行 mazeupdate.py from kivy.app import App from kivy.uix.screenmanager impo

是否可以显示正在绘制的线,而不是立即显示的线。我试图制作多个加载条并旋转,但我认为制作线条会更简单一些。 我有我想要遵循的大纲,每个直角都是自己画的线。On_pre_enter我的输出线已经给出,On_enter红色线已经绘制,但我希望在给定时间内输入时绘制红色线。我用self.canvas.before在后面添加了amin行:但是屏幕是动画的,而不是行

mazeupdate.py

from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.clock import Clock
from kivy.properties import NumericProperty
from kivy.uix.progressbar import ProgressBar
from kivy.config import Config
from kivy.graphics import Line, Color, Rectangle
from kivy.animation import Animation

class results(Screen):
    def on_pre_enter(self):
        with self.canvas.before:
            Color(1,1,1)
            Line(points=[100, 100, 100, 200, 200, 200, 200, 100, 300, 100, 300, 200], width=3)

    def on_enter(self):

        with self.canvas.before:
            Color(1,0,0)
            Line(points=[100, 100, 100, 200], width=5)
            anim = Animation(pos=(80, 10))
            anim &= Animation(size=(800, 800), duration=5)
            anim.start(self)

class mazeupdateApp(App):
    Config.set('graphics', 'width', '800')
    Config.set('graphics', 'height', '600')
    def build(self):
        FadeTransition.clearcolor = (1,1,1,1)
        sm = ScreenManager(transition=FadeTransition())
        sm.add_widget(results(name='one'))
        return sm
if __name__ == '__main__':
    mazeupdateApp().run()

可以设置直线端点的动画,然后使用对端点的每次更改重新绘制直线:

from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.properties import ListProperty
from kivy.config import Config
from kivy.graphics import Line, Color
from kivy.animation import Animation

class results(Screen):
    anim_pt = ListProperty([])    # this is the line endpoint

    def on_pre_enter(self):
        with self.canvas.before:
            Color(1,1,1)
            Line(points=[100, 100, 100, 200, 200, 200, 200, 100, 300, 100, 300, 200], width=3)

    def on_enter(self):
        # start the red line with no points
        with self.canvas.before:
            Color(1,0,0)
            self.line = Line(width=5)    # saves a reference to the line

        # animate the end point (self.anim_pt)
        self.anim_pt = [100, 100]
        anim = Animation(anim_pt=[100, 200], d=3)
        anim.start(self)

    def on_anim_pt(self, widget, progress):
        # called when anim_pt changes

        # set up the line points
        points = [100, 100]
        points.extend(self.anim_pt)

        # remove the old line
        self.canvas.before.remove(self.line)

        # draw the updated line
        with self.canvas.before:
            self.line = Line(points=points, width=5)

class mazeupdateApp(App):
    Config.set('graphics', 'width', '800')
    Config.set('graphics', 'height', '600')
    def build(self):
        FadeTransition.clearcolor = (1,1,1,1)
        sm = ScreenManager(transition=FadeTransition())
        sm.add_widget(results(name='one'))
        return sm
if __name__ == '__main__':
    mazeupdateApp().run()

我一直在研究这一点,但当我添加动画线条并使用anim.startself时,它只是为屏幕移动设置动画。我更改了anim.startine,得到了错误属性error:type对象“kivy.graphics.vertex\u instructions.Line”没有属性“pos”