我正在用kivy编写一个Android游戏应用,并且想让绘制的线条在绘制后的x秒后消失。
我已经尝试过,请阅读kivy.doc或google,但找不到它或idk只是愚蠢。
py.
class Drawing(Widget):
def on_touch_down(self, touch):
with self.canvas:
touch.ud["line"] = Line(points=(touch.x, touch.y))
def on_touch_move(self, touch):
touch.ud["line"].points += [touch.x, touch.y]
#They are what I've found and tried...
def i_remove_widget(self):
self.remove_widget(self.Drawing)
Clock.schedule_once(self.i_remove_widget(), 1.5)
def on_touch_up(self, touch):
touch.ud["line"].self.remove = Clock.schedule_once(self, 1.5)
kv.
Screen:
Drawing
我希望我的画线在1.5秒内消失,但是什么也没发生
答案 0 :(得分:0)
类似这样的东西:
def on_touch_up(self, touch):
line = touch.ud['line']
def remove_line(*args):
self.canvas.remove(line)
Clock.schedule_once(remove_line, 1.5)