from kivy.app import App
from kivy.uix.button import Button
from kivy.config import Config
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.widget import Widget
Config.set('graphics', 'resizable', '0');
Config.set('graphics', 'width', '400');
Config.set('graphics', 'height', '600');
class CalculatorApp(App):
def build(self):
g1 = GridLayout(cols = 4,
padding = 10,
spacing = 2,
size_hint = (1, .75))
b1 = BoxLayout(orientation = 'vertical')
b1.add_widget(Label(text = b,
font_size = 40,
size_hint = (1, .25)))
a = 30
g1.add_widget(Button(text = '7',
font_size = a))
g1.add_widget(Button(text = '8',
font_size = a))
g1.add_widget(Button(text = '9',
font_size = a))
g1.add_widget(Button(text = '+',
font_size = a))
g1.add_widget(Button(text = '4',
font_size = a))
g1.add_widget(Button(text = '5',
font_size = a))
g1.add_widget(Button(text = '6',
font_size = a))
g1.add_widget(Button(text = '-',
font_size = a))
g1.add_widget(Button(text = '1',
font_size = a))
g1.add_widget(Button(text = '2',
font_size = a))
g1.add_widget(Button(text = '3',
font_size = a))
g1.add_widget(Button(text = 'x',
font_size = a))
g1.add_widget(Widget())
g1.add_widget(Button(text = '0',
font_size = a))
g1.add_widget(Button(text = ',',
font_size = a))
g1.add_widget(Button(text = '=',
font_size = a))
b1.add_widget(g1)
return b1
CalculatorApp().run()
Как сделать чтобы при нажатии на Button с любым текстом, она печатала в Label число которое соответствует атрибуту text данной Button?