2017-12-03 3 views
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" 

答えて

0

あなたはDragBehaviorでon_touch_up()メソッドをオーバーライドしているので、あなたは

super(DraggableImage,self).on_touch_up(touch) 

への呼び出しを追加する必要があります。

+0

'on_touch_up()'メソッドには戻り値があるので、DragBehavior.on_touch_up()からの戻り値を処理する必要があります。 –

関連する問題