本文介紹了用kivy制作時鐘的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我是 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模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!