Можно ли получить автоматический c результат расчета в кивах? Я думаю, что у меня есть 3 поля TextInput и когда по крайней мере 2 из них будут заполнены 3, я получу результат.
Я думаю о чем-то вроде этого:
--------------
| 2 | --> TextInput 1
--------------
|result = 5 | --> TextInput 2
-------------
| 3 | ---> TextInput 3
--------------
Or
--------------
| result = 5 | --> TextInput 1
--------------
| 2 | --> TextInput 2
-------------
| 3 | ---> TextInput 3
--------------
Результат должен появляются автоматически после ввода не менее 2 цифр.
My my.py:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
class HomeScreen(Screen):
pass
class CalculatorHome(Screen):
pass
GUI = Builder.load_file("kv/my.kv")
class MainApp(App):
def build(self):
return GUI
def change_screen(self, screen_name, direction):
# Get the screen manager from the kv file
screen_manager = self.root.ids['screen_manager']
screen_manager.current = screen_name
screen_manager.transition.direction = direction
def clear_text(self, *args):
for ar in args:
ar.text = ''
MainApp().run()
Calculate.kv с TextIput
<CalculatorHome>:
FloatLayout:
GridLayout:
rows:3
pos_hint: {"top": .8, "left": 1 }
size_hint: 1, .4
TextInput:
id: number1
multiline: False
TextInput:
id: number2
multiline: False
TextInput:
id: number3
multiline: False
GridLayout:
rows:1
pos_hint: {"top": .3, "left": 1 }
size_hint: 1, .1
Button:
text: "CLEAR"
on_press: app.clear_text(number1, number2, number3 )