77 линия, AttributeError: 'CalApp' object has no attribute 'cleaner'
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.widget import Widget
class CalApp(App):
def update_label(self):
self.lbl.text = self.formula
def add_number(self, instance):
if (self.formula == "0"):
self.formula = ""
self.formula += str(instance.text)
self.update_label()
def add_operation(self, instance):
if( str(instance.text).lower() == "x"):
self.formula += "*"
else:
self.formula += str(instance.text)
self.update_label()
def calc_result(self, instance):
try:
self.lbl.text = str(eval(self.lbl.text))
self.formula = "0"
except ZeroDivisionError:
self.lbl.text="На 0 нельзя делить!"
self.formula = "0"
def cleaner(self, instance):
self.formula = "0"
self.update_label()
def build(self):
self.formula = "0"
bl=BoxLayout(orientation="vertical")
gl = GridLayout(cols=5, rows=5, padding=[0, 500, 0, 0], spacing=3)
self.lbl=(Label(text="0",
size_hint=(.10, .15),
font_size=(55),
halign="right",
valign="center",
text_size=(1300,1300)))
bl.add_widget(self.lbl)
gl.add_widget(Button(text="1", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="2", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="3", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text=".", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="4", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="5", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="6", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="/", font_size=50, on_press = self.add_operation))
gl.add_widget(Button(text="7", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="8", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="9", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="*", font_size=50, on_press = self.add_operation))
gl.add_widget(Button(text="=", font_size=50, on_press = self.calc_result))
gl.add_widget(Button(text="0", font_size=50, on_press = self.add_number))
gl.add_widget(Button(text="+", font_size=50, on_press=self.add_operation))
gl.add_widget(Button(text="-", font_size=50, on_press = self.add_operation))
gl.add_widget(Button(text="<="), on_press=self.cleaner)
bl.add_widget(gl)
return(bl)
if __name__ == "__main__":
CalApp().run()