Kivy でテンキーを作成し、テンキーに入力された値を読み取り、関数を のようなものにアタッチできるようにしたいと考えていますon_submit
。
私のクラスは次のようになります
class NumPad(Widget):
field = ObjectProperty()
def validate(self):
# RULL CUSTOM CALLBACK HERE
私のKivyファイルは次のようになります
<NumPad>:
field: field
BoxLayout:
orientation: 'vertical'
Label:
name: 'field'
GridLayout:
cols: 3
Button: # REPEAT 9 TIMES
text: '1'
on_press: root.field.text += '1'
Button:
text: 'del'
on_press: root.field.text = ''
Button:
text: '0'
on_press: root.field.text += '0'
Button:
text: 'enter'
on_press: root.enter()
そして、このように定義することは可能ですか?
<Root>:
BoxLayout:
NumPad:
on_enter: # DEFINE CODE TO BE CALLED!
では、ウィジェットのインスタンスごとに定義されたコードを実行するのでしょうか? ありがとう!