用奇异果制造一个时钟 [英] Making a clock in kivy

查看:116
本文介绍了用奇异果制造一个时钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Kivy的新手,我试图更好地处理Events以及框架的一些基础知识.

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()

这篇关于用奇异果制造一个时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆