I want to simulate the user action and after looking in the doc, I saw the Clock.schedule_once(my_callback, 1)
.
.
Question: Is this the only way to do it ? I would have prefered something like my_button.press()
.
.
I want to press the button and then, it will call my_callback
, I don't want to directly call my_callback
.
(Because if I do this and my callback evolve, I lost the good reference)
PS: I saw that there was the possibility to use Clock.create_trigger(my_callback)
but it didn't seems to be the good solution here.
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.clock import Clock
KV_APP = '''
BoxLayout:
Button:
id: my_button
text: "Click on me"
'''
class TestApp(MDApp):
def build(self):
self.screen = Builder.load_string(KV_APP)
self.screen.ids["my_button"].bind(on_press=self.on_button_click)
event = Clock.schedule_once(self.on_button_click, 1)
return self.screen
def on_button_click(self, instance):
print("hello there !")
if __name__ == '__main__':
TestApp().run()