Kivy,在我按下按钮后 1 秒让事情发生

Kivy, make sometihing happen 1 sec after i press a button

我已经尝试了很多小时,阅读 wiki 并以不同的方式进行试验,但我无法做到,有人可以明确地向我解释(向我展示)如何做到这一点而不仅仅是将我链接到维基。下面你会发现我的代码被复制了,你在按钮下面看到了 on_release:,它的 ID 是“设置”,我希望它实际上不是在发布时发生,而是在我按下按钮后 1 秒发生。

.py 文件:

import kivy
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.config import Config
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout

#title
#self.title('Past Paper Question Search ')
#background
Window.clearcolor = (0.145, 0.145, 0.149, 1)
#resizability
Config.set('graphics', 'resizable', True)
class FloatLayout(FloatLayout):
    def __init__(self, **kwargs):
        super(FloatLayout, self).__init__(**kwargs)


class GUIApp(App):
    def build(self):
        return FloatLayout()

if __name__ == "__main__":
    GUIApp().run()

.kv 文件:

<FloatLayout>:
    BoxLayout:
        id: searchBox
        orientation: 'horizontal'
        size_hint_x: 0.6
        size_hint_y: 0.07
        pos_hint: {"x":0.2, "y":0.7}
        TextInput:
            background_color: 0.275, 0.275, 0.275, 1
            multiline: False
            font_size: self.height/1.6
            foreground_color: [1, 1, 1, 1]
            hint_text: "Search"
            hint_text_color: [1, 1, 1, 0.3]
            cursor_color: [1, 1, 1, 1]
            padding: [(self.height)/2-(self.line_height/2.0), (self.height)/2-(self.line_height/2.0), 6, 0]
        Button:
            size_hint_y: 1
            width: self.height
            size_hint_x: None
            border: 0, 0, 0, 0
            background_normal: "resources/Search.png"
            background_down: "resources/Search_pressed.png"  
    Button:
        id: settings
        size_hint_y: 0.095
        width: self.height
        size_hint_x: None
        border: 0, 0, 0, 0
        background_normal: "resources/empty.png"
        background_down: "resources/empty.png"
        pos_hint: {"x":0.92, "y":0.9}
        on_press: gif.anim_delay = 0.10
        on_press: gif._coreimage.anim_reset(True)
        on_release: settings.pos_hint= {"x":0.2, "y":2}
        on_release: close.pos_hint= {"x":0.92, "y":0.9}
        on_release: searchBox.pos_hint= {"x":0.2, "y":2.7}
        Image:
            id: gif
            source: 'resources/settings_gif.gif'
            center: self.parent.center
            size: self.parent.size
            anim_delay: -1
            anim_loop: 1
            allow_stretch: True
    
    
    Button:
        id: close
        size_hint_y: 0.095
        width: self.height
        size_hint_x: None
        border: 0, 0, 0, 0
        background_normal: "resources/X.png"
        background_down: "resources/X.png"
        on_press: searchBox.pos_hint= {"x":0.2, "y":0.7}
        on_press: settings.pos_hint= {"x":0.92, "y":0.9}
        on_press: close.pos_hint= {"x":0.92, "y":2.9}
        pos_hint: {"x":0.92, "y":2.9}
            

提前致谢

这是一个小例子。阅读时钟:https://kivy.org/doc/master/api-kivy.clock.html?highlight=clock#module-kivy.clock

from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock

kv = """
BoxLayout:
    orientation: 'vertical'
    Label:
        id: status
    Button:
        size_hint_y: None
        height: 48
        text: 'Press'
        on_release: app.schedule_action()
"""


class WaitOneSecondApp(App):
    def build(self):
        return Builder.load_string(kv)

    def schedule_action(self):
        self.root.ids.status.text = 'Waiting One Second...'
        Clock.schedule_once(self.wait_over, 1)

    def wait_over(self, dt):
        self.root.ids.status.text = 'The wait is over'


WaitOneSecondApp().run()