0
drag_table_upでDragGehaviorImageクラス(DragBehaviorとImageを継承するクラス)を使用すると、ドラッグしてイメージをドロップするとイメージをドラッグできなくなります。DragBehaviorはKivyのon_touch_upで初めてしか動作しません
なぜこれが起こり、修正するのか分かりません。あなたのon_touch_up()
方法で
from kivy.app import App
from kivy.uix.behaviors import DragBehavior
from kivy.uix.image import Image
class DraggableImage(DragBehavior, Image):
def on_touch_up(self, touch): # without this (e.g. "pass" here), image is always draggable.
print("This is test")
class TestApp(App):
def build(self):
pass
if __name__ == '__main__':
TestApp().run()
test.kv
BoxLayout:
DraggableImage:
source: "example.png"
'on_touch_up()'メソッドには戻り値があるので、DragBehavior.on_touch_up()からの戻り値を処理する必要があります。 –