Clock Max Iterations

1,561 views
Skip to first unread message

Mohamed Selim

unread,
Jan 24, 2012, 5:09:26 AM1/24/12
to kivy-...@googlegroups.com
Hello Kivy Users,

I'm getting a critical info that says:
[CRITICAL] [Clock       ] Warning, too much iteration done before the next frame. Check your code, or increase the Clock.max_iteration attribute


In my code, I imported Clock, and in the build() method I added the line:

        Clock.max_iteration = 40


but that didn't affect the critical warning i'm getting

How can I increase the Clock.max_iteration attribute ??


--
Best Regards,
Mohamed Selim

Mathieu Virbel

unread,
Jan 24, 2012, 5:42:34 AM1/24/12
to kivy-...@googlegroups.com
Hi,

If you increase it, and you still get the issue, that doesn't mean it
not working, that's mean you've a recursive Clock iteration somewhere.

Example:

def do_something(...):
Clock.schedule_once(do_something, -1)

# start the event
Clock.schedule_once(do_something, -1)


=> -1 mean before the next frame. Mean if you still trying to schedule a
method between the next frame, it's infinite. And kivy broke the link.

In rare case, this can be triggered by layout (and it should be a bug).
If it's from us, give a code snippet to reproduce the issue :)

Thanks!

Mathieu

Yurij Mikhassiak

unread,
Jan 22, 2013, 3:40:23 AM1/22/13
to kivy-...@googlegroups.com
Hello. I am new member of kivy community. Thanks for your great work!
 I think I may found an isue.


If I put <Label> rule in kv string i get same iteration error with strange grafical results.
This code should reproduce the error:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from kivy.uix.gridlayout import GridLayout
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout

Builder.load_string('''


<CustomPopup>:
    size_hint: .5, .5
    auto_dismiss: False
    title: 'Hello world'
    Button:
        text: 'Click me to dismiss'
        on_press: app.dismiss()

<Label>
    font_size: '24pt'
    text_size: self.width, self.height
    valign: 'middle'
    halign: 'center'
    markup: True

<TextInput>
    font_size: '24pt'

<Button>
    font_size: '16pt'
    

<Demo>:
    cols: 1
    padding: 10
    spacing: 10
    BoxLayout:
        
        size_hint_y: 0.05
        
        
        Label:
              
            text:
                ('[b]Demo controller v.0.1[/b]')
            markup: True
            font_size: '24pt'
           
      
    BoxLayout: 
        size_hint_y: 0.2 
        padding: 1 
        
        Label:
            
            text: 
                ('Some text')
            markup: True
            font_size: '24pt' 
        
        TextInput: 
        
            
            
        Button:
            text: 'Fire'
            on_press: root.show_popup()
           
        Label:
        

''')

class Demo(GridLayout):
    def show_popup(self):
        p = CustomPopup()
        p.open()
    
    
class CustomPopup(Popup):
    pass

class ControllerXYZApp(App):
    def build(self):
        return Demo()
    
    
   

if __name__ == '__main__':
    ControllerXYZApp().run()


If I remove: 
<Label>
    font_size: '24pt'
    text_size: self.width, self.height
    valign: 'middle'
    halign: 'center'
    markup: True

it will work as it should. 
Is it a bug? Can we fix it?



Also I've found undocumented isue that "\n" in kv files and kv string (Builder.load_string) behave in different ways. To reprosuce you can try to "load_string" from textalign.kv It will produce an error.



Regards, Yurij

Вівторок, 24 січня 2012 р. 12:42:34 UTC+2 користувач Mathieu Virbel написав:

Akshay Arora

unread,
Jan 22, 2013, 7:42:53 AM1/22/13
to kivy-...@googlegroups.com
You are overriding the default Label appearance. Forcing such usage for everything can break some internal Widgets that Kivy uses.

 In this case you are changing the default size of the font, forcing markup usage for every label and then setting text_size to the size of the label. This is the part that causes infinite loop I believe as The label for Title in popup needs it's height to be set to None.

     Label:
         text: root.title
         size_hint_y: None
         height: self.texture_size[1] + 16
         text_size: self.width - 16, None



Please DON'T over ride the default rules unless you absolutely know what you are doing.

You should instead create your own class

    MLabel(Label):
        pass

Then use this class MLabel in your kv set custom rules for it:

<MLabel>:
    ...

<CustomPopup>:
    ...
    MLabel:
    ...


Regards

Yurij Mikhassiak

unread,
Jan 22, 2013, 4:29:06 PM1/22/13
to kivy-...@googlegroups.com
Thank you so much!!!!

Вівторок, 22 січня 2013 р. 14:42:53 UTC+2 користувач qua-non написав:
Reply all
Reply to author
Forward
0 new messages