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

Posted

技术标签:

【中文标题】是啥导致了错误:Kivy 中的“警告,在下一帧之前完成了太多迭代”?【英文标题】:What is causing error: "Warning, too much iteration done before the next frame" in Kivy?是什么导致了错误:Kivy 中的“警告,在下一帧之前完成了太多迭代”? 【发布时间】:2021-09-21 23:16:52 【问题描述】:

我试图设置由嵌套 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'

【问题讨论】:

你能在它最终崩溃的时候发布回溯吗? 好的,我做了一些测试,我可以更彻底地描述警告消息的行为。当我启动我的应用程序(它是另一个屏幕)并每秒发送多次垃圾邮件警告消息“[CRITICAL] [Clock] 警告,在下一帧之前完成太多迭代”时出现警告消息,直到我到达布局的“Window2” -然后垃圾邮件停止。仅当我尝试通过 size_hint 属性在“Window2”上设置按钮时才会发生此行为。然而,应用程序并没有在此警告消息上崩溃(但垃圾邮件很多)。 所以看起来按钮被渲染后,一切正常。 【参考方案1】:

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

【讨论】:

以上是关于是啥导致了错误:Kivy 中的“警告,在下一帧之前完成了太多迭代”?的主要内容,如果未能解决你的问题,请参考以下文章

使用 cmd 安装 Kivy 会导致“错误:依赖关系......未解决”[关闭]

是啥导致 cellForRowAtIndexPath 中的 outOfBounds 错误?

是啥导致了 boost C++ asio 中的 asio.misc.3 错误

是啥导致 Dart 类 '_WebSocketImpl' 中的错误没有实例方法 'send'?

是啥导致我的 s-s-rS 图表中的范围参数错误?

是啥导致 weka 中的 csv 加载错误?