我是 Kivy 的新手,我正在尝试更好地处理事件以及框架的一些基础知识.
I'm new to Kivy, and I'm trying to get a better handle on Events, as well as a few basics of the framework.
为此,谁能提供在 Kivy 中实现的简单时钟的代码,它显示当前时间并每秒更新一次?
For that purpose, can anyone provide the code for a simple clock implemented in Kivy, which shows the current time, and updates every second?
这是一个非常简单的时钟:
Here's an extremely simple clock:
from kivy.app import App
from kivy.uix.label import Label
from kivy.clock import Clock
import time
class IncrediblyCrudeClock(Label):
def update(self, *args):
self.text = time.asctime()
class TimeApp(App):
def build(self):
crudeclock = IncrediblyCrudeClock()
Clock.schedule_interval(crudeclock.update, 1)
return crudeclock
if __name__ == "__main__":
TimeApp().run()
这篇关于用kivy制作时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!