press_button.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:kivy_soil 作者: Bakterija 项目源码 文件源码
def by_text(self, text):
        root = App.get_running_app().root
        found = False

        for widget in root.walk():
            if hasattr(widget, 'text') and text in widget.text:
                if hasattr(widget, 'on_press'):
                    found = True
                    widget.on_press()
                    Clock.schedule_once(widget.on_release, 0.2)
                    ret = '# Pressed button %s' % (widget)
                    break
                elif hasattr(widget, 'on_left_click'):
                    found = True
                    widget.on_left_click()
                    ret = '# Pressed button %s' % (widget)
                    break
        if not found:
            ret = '# Did not find button'

        return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号