Created
January 24, 2020 22:25
-
-
Save tshirtman/654bfd8859214878914839af50013875 to your computer and use it in GitHub Desktop.
drag behavior with initial position in float layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.lang import Builder | |
from kivy.factory import Factory | |
KV = ''' | |
<Floaty@DragBehavior+Image>: | |
size_hint: None, None | |
size: self.texture_size | |
drag_rectangle: self.pos + self.size | |
canvas: | |
Line: | |
rectangle: self.pos + self.size | |
on_touch_move: | |
touch = args[1] | |
uid = self._get_uid() | |
print(self._drag_touch is touch and touch.ud.get(uid)['mode']) | |
if self._drag_touch is touch and touch.ud.get(uid)['mode'] == 'drag': self.pos_hint = {} | |
FloatLayout: | |
Floaty: | |
source: 'data/logo/kivy-icon-128.png' | |
pos_hint: {'center': (.5, .5)} | |
''' | |
class Application(App): | |
def build(self): | |
return Builder.load_string(KV) | |
if __name__ == "__main__": | |
Application().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment