微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

是什么导致错误:Kivy 中的“警告,在下一帧之前完成了太多迭代”?

如何解决是什么导致错误:Kivy 中的“警告,在下一帧之前完成了太多迭代”?

我试图设置由嵌套 BoxLayouts 组成的屏幕布局。不幸的是,当我尝试设置两个底部按钮的大小(使用 size_hint: 0.5,0.5)时,我收到此错误

[CRITICAL] [Clock] 警告,在下一帧之前完成的迭代过多。检查您的代码,或增加 Clock.max_iteration 属性

但是,我得到了预期的结果:Two bottom buttons are in expected place,但一段时间后应用程序崩溃了。

.kv 文件

<Window2>:
    name: 'Window2'
    
    MDBoxLayout:
        orientation: 'vertical'
        size: root.width,root.height

        MDBoxLayout:
            orientation: 'vertical'
            size_hint: 1,0.5
            
            MDLabel:
                id: label_id
                text: 'Text'
                
            MDDropDownItem:
                id: drop_item
                text: 'Condition'
                pos_hint: {'center_x': 0.5}
                font_size: 32
                on_release: 
                    root.menu.open()

        MDBoxLayout:
            orientation: 'horizontal'
            size_hint: 1,0.5
        
            MDRaisedButton:
                text: 'Back'
                size_hint: 0.5,0.5 # this line is causing the problem
                on_release: 
                    app.root.current = 'Window1'
                    root.manager.transition.direction = 'left'
            
            MDRaisedButton:
                text: 'Continue'
                size_hint: 0.5,0.5 # this line is causing the problem
                on_release: 
                    app.root.current = 'Window3'
                    root.manager.transition.direction = 'left'

解决方法

好的,所以我通过将按钮从 KivyMD RaisedButtons 更改为标准 Kivy Buttons 解决了我的问题。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。