私はアンドロイドロックのようなものを作りたいので、ボタンの2つの画像があります(ボタンは通常、ボタンは押されています)。
すべての画像に関数 on_touch_down を定義したので、それを押すと、ソースが押されたボタンに変更され、on_touch_up で通常の状態に戻ります。しかし、画面のどこかを押すたびに、すべてのボタンが一度に変わります。
押したときに各ボタンだけを変更し、どこかを押したときにすべてを変更しないようにするにはどうすればよいですか?
ここに私のkvファイルがあります:
Manager:
Principal:
<Principal>:
GridLayout:
cols: 3
Image:
id: '1'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True
Image:
id: '2'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True
Image:
id: '3'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True
Image:
id: '4'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True
Image:
id: '5'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True
Image:
id: '6'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True
Image:
id: '7'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True
Image:
id: '8'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True
Image:
id: '9'
size: 30,30
source: 'button.png'
on_touch_down: self.source = 'button_press.png'
on_touch_up: self.source = 'button.png'
allow_strech: True