3

I have been struggling recently creating a filled Circle in Kivy that stays a circle when the window is re-sized to a different width or height. I looked at the question here:

Centering an object in Kivy

But when I implement my Circle like so:

<BigCircle>
    width: min(self.size)
    height: min(self.size)
    pos_hint: {'center_x': .5, 'center_y': .5}
    canvas:
        Color:
            rgb: 1, 1, 0
        Ellipse:
            size: self.size
            pos: self.pos

<MainScreen>:
    FloatLayout
        size: root.size
        canvas:
            Color:
                rgb: 1, 1, 1
            Rectangle:
                size: self.size

        BigCircle:
            id: big_cir

class MainScreen(Screen):
    pass
class MyApp(App):
    def build(self):
        sm = ScreenManager(transition=NoTransition())
        sm.add_widget(MainScreen(name="Main"))
        return sm

I get the error:

[Critical][Clock ]Warning, too much iteration done before the next frame. Check your code, or increase the Clock.max_iteration attribute

I am doing nothing with the Clock, but I am using a ScreenManager. Currently, MainScreen is the only screen. If I change the height/width to not include the min() then it works, but that is necessary to keep the Circle circular. Otherwise it becomes elongated when re-sized and looks bad.

Community
  • 1
  • 1
pech0rin
  • 4,588
  • 3
  • 18
  • 22

1 Answers1

3

The problem is you have an infinite loop due to BigCircle width and height being adjusted based on its size (width, height). Try changing your BigCircle to:

<BigCircle>
    canvas:
        Color:
            rgb: 1, 1, 0
        Ellipse:
            size: min(self.size), min(self.size)
            pos: root.center_x - min(self.size)/2, root.center_y - min(self.size)/2
user
  • 5,370
  • 8
  • 47
  • 75
brousch
  • 1,064
  • 5
  • 10
  • Thanks for the help. I guess I'm still slightly confused since I thought inside the canvas `self.size` referenced the width/height array of the widget. – pech0rin Apr 25 '14 at 20:25