Search code examples
pythonpython-3.xkivykivy-languagekivymd

Divisoin by zero in KIvyMD


I have code:

<TheSettings>
    size_hint_y: None
    height: 40
    FloatLayout:
        MDLabel:
            text: 'Темная тема'
            pos_hint: {'center_x':.5,'center_y':.5}
        MDSwitch:
            id: dark_switch
            active: False
            on_active: app.dark()
            width: 30
            pos_hint: {'center_x':.94,'center_y':.5}

Why i receive this error?

ZeroDivisionError: float division by zero
 Exception ignored in: 'kivy.graphics.vertex_instructions.Line.prebuild_rounded_rectangle'
 Traceback (most recent call last):
   File "C:\Users\lolo\PycharmProjects\FindWord\venv\lib\site-packages\kivy\core\window\__init__.py", line 1395, in on_draw
     self.render_context.draw()
 ZeroDivisionError: float division by zero

If remove MDSwitch problem lost. Means, error in him. How this fix?


Solution

  • Try using width:'30px' instead of width:30 .