Hello!
Il I change the position of a a widget from python, the DragBehavior isn't working anymore.
How can I recover the dragbehavior after changing position?
Here's an exemple showing the non-draggable widget. Without the on_start function, it's draggable
from kivy.uix.label import Label
from kivy.app import App
from kivy.uix.behaviors import DragBehavior
from kivy.lang import Builder
kv = '''
<DragLabel>:
# Define the properties for the DragLabel
drag_rectangle: self.x, self.y, self.width, self.height
drag_timeout: 10000000
drag_distance: 0
FloatLayout:
DragLabel:
id:drag
size_hint: 0.25, 0.2
text: 'Drag me'
'''
class DragLabel(DragBehavior, Label):
pass
class TestApp(App):
def on_start(self, **kwargs):
self.root.ids.drag.pos_hint = {"x":0.5, "y":0.5}
def build(self):
return Builder.load_string(kv)
TestApp().run()