Warning, too much iteration done before the next frame. Check your code, or increase the Clock.max_iteration attribute
пишу простой калькулятор с библиотекой KivyMD, но при запуске выдает куча ошибок, хотелось бы понять как решить проблему, и сильно ли она влияет на конечную сборку в exe файл? Пробовал Clock.max_iteration но не помогало. С kivy пока мало знаком.
from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window
from kivy.clock import Clock
from kivy.core.window import WindowBase
Window.size = (710, 500)
Window.resizable = (False, False)
class ContainerBX(BoxLayout):
Stopdot = False
all_simbols = []
int_simbols = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ]
plus_AndOther = ["+", "-", "*"]
plus_AndOtherStop = False
def add_numbers(self, numbers, x=1):
self.all_simbols.append(numbers)
if ( (self.plus_AndOtherStop != True) or (self.all_simbols[-1] not in self.plus_AndOther) ):
self.plus_AndOtherStop = False
if ( (self.all_simbols[-1] != ".") or (self.Stopdot == False) ):
if (((len(self.display.text)) < 20 and self.display.text != "Error")):
self.display.text += str(numbers)
print(self.all_simbols)
else:
self.display.text = "Error"
if self.all_simbols[-1] not in self.int_simbols:
if (self.all_simbols[-1] == "."):
self.Stopdot = True
else:
self.Stopdot = False
if self.all_simbols[-1] not in self.int_simbols:
if (self.all_simbols[-1] in self.plus_AndOther):
self.plus_AndOtherStop = True
else:
self.plus_AndOtherStop = False
print(self.all_simbols)
def main_operation(self, calculation, x):
try:
self.display.text = str(round((eval(calculation)), 2))
except Exception:
if (x == 1):
self.display.text = " "
else:
self.display.text = "Error"
class CalculatorApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "DeepPurple"
self.theme_cls.primary_hue = "400"
self.theme_cls.theme_style = "Dark"
return ContainerBX()
if __name__ == "__main__":
CalculatorApp().run()
Код .kv
<ContainerBX>:
id: calculator
display: entry
orientation: 'vertical'
NavigationLayout:
ScreenManager:
id: screen_manager
Screen:
name: "calculator_1"
FloatLayout
MDLabel:
theme_text_color: "Secondary"
multiline: False
id: entry
text:
pos_hint: {"x":0.1,"y":0.5,"top":1,"bottom":1,"left":0.5,"right":0.95}
font_size: 60
size_hint: 1, .60
text_size: (350, 180)
halign: "right"
GridLayout:
padding: 25,25,25,25
spacing:4
cols: 4
size_hint: 1, .6
MDRaisedButton:
text:"7"
size_hint: 1,1
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"8"
id: button_8
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"9"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"*"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"4"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"5"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"6"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"-"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"1"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"2"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"3"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"+"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"C"
on_release:
calculator.main_operation(self.text, x = 1)
calculator.add_numbers(" ",x = 0)
MDRaisedButton:
size_hint: 1,1
text:"0"
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"."
on_release:
calculator.add_numbers(self.text, x = 0)
MDRaisedButton:
size_hint: 1,1
text:"="
on_release:
calculator.main_operation(entry.text, x = 0)
Screen:
name: "calculator_2"
FloatLayout
MDLabel:
theme_text_color: "Secondary"
text: "Hi"
MDNavigationDrawer:
FloatLayout:
MDRaisedButton:
pos_hint: {"x":1,"y":1,"top":.95,"bottom":1,"left":.9,"right":.9}
size_hint: .80,.08
font_size: 30
text:"1"
on_release:
screen_manager.current = "calculator_1"
MDRaisedButton:
pos_hint: {"x":.1,"y":.1,"top":.82,"bottom":.1,"left":.3,"right":.9}
size_hint: .80,.08
font_size: 30
text:"2"
on_release:
screen_manager.current = "calculator_2"
