Хто підкаже що не так роблю
main.py
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.properties import ObjectProperty
from kivy.core.window import Window
Window.size = (480, 853)
from kivy.config import Config
Config.set('kivy', 'keyboard_mode', 'systemanddock')
def get_brutto(x):
r = str(round((y / x) * 100 - 100))
r1 = str(round((z / x) * 100 - 100))
return {'x': x, 'r': r, 'r1': r1}
class Container(GridLayout):
def calculate(self):
try:
x = int(self.text_input.x)
y = int(self.text_input.y)
z = int(self.text_input.z)
except:
x = 0
brutto = get_brutto(x)
self.x.text = brutto.get(x)
self.r.text = brutto.get(r)
self.r1.text = brutto.get(r1)
class MyApp(App):
def build(self):
return Container()
if __name__ == '__main__':
MyApp().run()
my.kv
<ItemLabel@Label>:
font_size: '25sp'
haline: 'left'
valign: 'middle'
text_size: self.size
<Container>:
rows: 6
text_input: x
text_input: y
text_input: z
AnchorLayout:
size_hint: 1, 1
rows:3
GridLayout:
rows: 3
FloatLayout:
TextInput:
id: x
font_size: '45sp'
#size_hint: 1, 0.4
#pos: 100, 100
pos_hint: {'top': 1}
multiline: False
font_size: 40
FloatLayout:
TextInput:
id: y
font_size: '45sp'
#size_hint: 1, 0.4
pos_hint: {'top': 1}
#pos: 100, 50
multiline: False
font_size: 40
FloatLayout:
TextInput:
id: z
font_size: '45sp'
#size_hint: 1, 0.4
pos_hint: {'top': 1}
#pos: 100, 10
multiline: False
font_size: 40
GridLayout:
cols: 2
BoxLayout:
orientation: 'vertical'
padding: [30, 0, 0, 0]
ItemLabel:
text: 'Номінальна вага'
ItemLabel:
text: 'Мінімальна вага'
ItemLabel:
text: 'Максимальна вага'
BoxLayout:
orientation: 'vertical'
padding: [30, 0, 0, 0]
size_hint: 1, 1
ItemLabel:
id: x
text: '0 '
ItemLabel:
id: r
text: '0%'
ItemLabel:
id: r1
text: '0%'
BoxLayout:
size_hint: 0.9, 0.5
padding: [30, 0, 30, 20]
Button:
#size_hint: 0.5, 0.4
pos_hint: {'center_x': 0.5, 'y': 0.1}
text: 'Розрахувати'
on_release:
root.calculate()
BoxLayout:
size_hint: 0.9, 0.5
padding: [30, 0, 30, 20]
Button:
#size_hint: 0.5, 0.4
pos_hint: {'center_x': 0.5, 'y': 0.1}
text: 'SinglePack'
BoxLayout:
size_hint: 0.9, 0.5
padding: [30, 0, 30, 20]
Button:
#size_hint: 0.5, 0.4
pos_hint: {'center_x': 0.5, 'y': 0.1}
text: 'MultiPack'