Решил написать калькулятор на фраемворке kivy но выдает ошибку. Сразу скажу в работе с этим фраемворком я новичок
Вот код:
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.config import Config
Config.set("graphics","resizable","0")
Config.set("graphics","width","300")
Config.set("graphics","height","300")
class CalculatorApp(App):
def update_label(self):
self.label.text = self.formula
def input_figures(self,instance):
if (self.formula == '0'):
self.formula = ''
self.formula += str(instance.text)
self.update_label()
def calculate(self,instance):
self.formula += str(instance.text)
self.update_label()
def build(self):
self.formula = '0'
layot = GridLayout(cols = 3) #Создаем gridlayout
superbox = BoxLayout(orientation = "vertical")
self.label= superbox.add_widget(Label(text = '0'))
self.b0 = layot.add_widget(Button(text = '0', on_press = self.input_figures))
self.b1 =layot.add_widget(Button(text = '1', on_press = self.input_figures))
self.b2 = layot.add_widget(Button(text = '2', on_press = self.input_figures))
self.b3 = layot.add_widget(Button(text = '3', on_press = self.input_figures))
self.b4 = layot.add_widget(Button(text = '4', on_press = self.input_figures))
self.b5 = layot.add_widget(Button(text = '5', on_press = self.input_figures))
self.b6 = layot.add_widget(Button(text = '6', on_press = self.input_figures))
self.b7 = layot.add_widget(Button(text = '7', on_press = self.input_figures))
self.b8 = layot.add_widget(Button(text = '8', on_press = self.input_figures))
self.b9 = layot.add_widget(Button(text = '9', on_press = self.input_figures))
equip = layot.add_widget(Button(text = '+',on_press = self.calculate))
minus = layot.add_widget(Button(text = '-',on_press = self.calculate))
multipls = layot.add_widget(Button(text = '*',on_press = self.calculate))
multimin = layot.add_widget(Button(text = '/',on_press = self.calculate))
plus = layot.add_widget(Button(text = '=',on_press = self.calculate))
superbox.add_widget(layot)
return superbox
if __name__ == '__main__':
CalculatorApp().run()