我有一个问题,当我在dt
函数中删除count_down
参数时,我的应用程序已被中断。我想知道什么是dt
?
我在kivy文档中查了一下,并在另一个例子中看到了dt
arg,但我无法理解!也许持续时间?它是如何工作的?
这是我的__main__.py
源代码:
from kivy.app import App
from kivy.config import Config
from kivy.uix.gridlayout import GridLayout
from kivy.properties import NumericProperty
from kivy.clock import Clock
Config.set('graphics', 'width', '400')
Config.set('graphics', 'height', '280')
class RootWidget(GridLayout):
counter = NumericProperty(25)
condition = False
def start(self):
if not self.condition:
Clock.schedule_interval(self.count_down, 1)
self.condition = True
return 'Start'
else:
return 'Already started'
def pause(self):
Clock.unschedule(self.count_down, 1)
self.condition = False
return 'Pause'
def stop(self):
self.counter = 0
return 'Stop'
def count_down(self, dt):
if self.counter > 0:
self.counter -= 1
else:
self.stop()
class ClockApp(App):
def build(self):
return RootWidget()
if __name__=="__main__":
ClockApp().run()
来自documentation:# dt means delta-time
。