<legend id='EMVDK'><style id='EMVDK'><dir id='EMVDK'><q id='EMVDK'></q></dir></style></legend>

<i id='EMVDK'><tr id='EMVDK'><dt id='EMVDK'><q id='EMVDK'><span id='EMVDK'><b id='EMVDK'><form id='EMVDK'><ins id='EMVDK'></ins><ul id='EMVDK'></ul><sub id='EMVDK'></sub></form><legend id='EMVDK'></legend><bdo id='EMVDK'><pre id='EMVDK'><center id='EMVDK'></center></pre></bdo></b><th id='EMVDK'></th></span></q></dt></tr></i><div id='EMVDK'><tfoot id='EMVDK'></tfoot><dl id='EMVDK'><fieldset id='EMVDK'></fieldset></dl></div>

<small id='EMVDK'></small><noframes id='EMVDK'>

    • <bdo id='EMVDK'></bdo><ul id='EMVDK'></ul>
  1. <tfoot id='EMVDK'></tfoot>

      如何在 Kivy 中有更新时间

      时间:2023-10-10

      <legend id='WYLcn'><style id='WYLcn'><dir id='WYLcn'><q id='WYLcn'></q></dir></style></legend><tfoot id='WYLcn'></tfoot>
      • <bdo id='WYLcn'></bdo><ul id='WYLcn'></ul>

          <tbody id='WYLcn'></tbody>
        <i id='WYLcn'><tr id='WYLcn'><dt id='WYLcn'><q id='WYLcn'><span id='WYLcn'><b id='WYLcn'><form id='WYLcn'><ins id='WYLcn'></ins><ul id='WYLcn'></ul><sub id='WYLcn'></sub></form><legend id='WYLcn'></legend><bdo id='WYLcn'><pre id='WYLcn'><center id='WYLcn'></center></pre></bdo></b><th id='WYLcn'></th></span></q></dt></tr></i><div id='WYLcn'><tfoot id='WYLcn'></tfoot><dl id='WYLcn'><fieldset id='WYLcn'></fieldset></dl></div>

            <small id='WYLcn'></small><noframes id='WYLcn'>

              • 本文介绍了如何在 Kivy 中有更新时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在 kivy 中创建日历应用程序,我想知道如何添加更新时钟?我可以使用 datetime python 函数,但是当我在我的应用程序中加载它时,它会显示一个没有移动的冻结时间.有什么建议吗?

                I am creating a calendar app in kivy, and I was wondering how I would be able to add an updating clock? I can use the datetime python function, but when I load it in my app it shows a frozen time with no movement. Suggestions?

                from datetime import datetime, date, time, timedelta
                from kivy.app import App
                from kivy.clock import Clock
                

                (已解决)

                推荐答案

                这里有一个完整的例子来说明如何使用这个功能.您应该能够从中工作并将其应用于您自己的代码.如果您有任何具体问题,请在评论中告诉我,我很乐意回答:)

                Here's a complete example of how to get this feature working. You should be able to work from this and apply it to your own code. If you have any specific questions, let me know in a comment and I'll be happy to answer :)

                from kivy.app import App
                from datetime import datetime
                from datetime import timedelta
                from kivy.clock import Clock
                from kivy.uix.label import Label
                
                class MyApp(App):
                    def build(self):
                        self.now = datetime.now()
                
                        # Schedule the self.update_clock function to be called once a second
                        Clock.schedule_interval(self.update_clock, 1)
                        self.my_label = Label(text= self.now.strftime('%H:%M:%S'))
                        return self.my_label  # The label is the only widget in the interface
                
                    def update_clock(self, *args):
                        # Called once a second using the kivy.clock module
                        # Add one second to the current time and display it on the label
                        self.now = self.now + timedelta(seconds = 1)
                        self.my_label.text = self.now.strftime('%H:%M:%S')
                
                MyApp().run()
                

                这篇关于如何在 Kivy 中有更新时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Kivy 时钟和弹出窗口 下一篇:Kivy FileChooser 双击

                相关文章

                最新文章

                    <tfoot id='mkmiy'></tfoot>
                  1. <legend id='mkmiy'><style id='mkmiy'><dir id='mkmiy'><q id='mkmiy'></q></dir></style></legend>

                    <small id='mkmiy'></small><noframes id='mkmiy'>

                  2. <i id='mkmiy'><tr id='mkmiy'><dt id='mkmiy'><q id='mkmiy'><span id='mkmiy'><b id='mkmiy'><form id='mkmiy'><ins id='mkmiy'></ins><ul id='mkmiy'></ul><sub id='mkmiy'></sub></form><legend id='mkmiy'></legend><bdo id='mkmiy'><pre id='mkmiy'><center id='mkmiy'></center></pre></bdo></b><th id='mkmiy'></th></span></q></dt></tr></i><div id='mkmiy'><tfoot id='mkmiy'></tfoot><dl id='mkmiy'><fieldset id='mkmiy'></fieldset></dl></div>
                      <bdo id='mkmiy'></bdo><ul id='mkmiy'></ul>