0
私はアンドロイドロックのようなものを作りたいので、ボタンの2つの画像を持っています。Python-Kivy:特定の子供に定義されているon_touch_down()はすべての子供に影響を与えます
すべての画像で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
それは私の問題を解決しました!ありがとう – gramsch