So I am new to Kivy and Gui coding in general.... I am trying to have a moveable image, and here is the code I have so far tried:
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.image import Image
from kivy.uix.behaviors import DragBehavior
from kivy.uix.floatlayout import FloatLayout
class Box_layout(FloatLayout):
def __init__(self,**kwargs):
super(Box_layout, self).__init__(**kwargs)
self.size_hint = (.50,.50)
self.orientation = "vertical"
self.add_widget(MoveableImage())#drag_rectangle = [self.x, self.y, self.width, self.height],source="temp_plot.png"))
class MoveableImage(DragBehavior,Image):
def __init__(self, **kwargs):
super(MoveableImage, self).__init__(**kwargs)
self.drag_timeout = 10000000
self.drag_distance = 0
#self.drag = DragBehavior()
#self.drag.drag_rectangle = [self.x, self.y, self.width, self.height]
class gameApp(App):
def build(self):
wimg = MoveableImage(source="temp_plot.png")
m = Box_layout()
if __name__ == '__main__':
gameApp().run()
What happens is I currently have a blank 'image' that is draggable on the first click, but then reaches a timeout or something where it cannot be moved after it has been moved once..... I figured it was a timeout issue or something though self.drag_timeout = 10000000
did not fix the issue...what am I doing wrong here?
Further, when I am passing an actual source to MoveableImage, ie self.add_widget(MoveableImage(source='tmp.png'))
, the image never is moveable to begin with, which again is very confusing to me....if someone could help and explain what is going on and then explain why these behaviors are occurring, hat would be awesome!