Skip to content

Instantly share code, notes, and snippets.

@me2beats
Created October 12, 2019 03:54
Show Gist options
  • Save me2beats/bba6c5251d357707e8c34d9f59fdab6c to your computer and use it in GitHub Desktop.
Save me2beats/bba6c5251d357707e8c34d9f59fdab6c to your computer and use it in GitHub Desktop.
Draggable (borderless)
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.label import Label
from kivy.core.window import Window
#Window.size = (500, 300)
Window.borderless = True
KV = """
MyLabel
text: '123456'
"""
class MyLabel(Label):
def on_touch_down(self, touch):
self.mouse_pos = Window.mouse_pos
self.w_left= Window.left
self.w_top= Window.top
self.new_left = Window.left
self.new_top = -Window.top
self.last_x = self.mouse_pos[0]
self.last_y = self.mouse_pos[1]
super().on_touch_down(touch)
def on_touch_move(self, touch):
self.new_left += Window.mouse_pos[0]-self.last_x
self.new_top += Window.mouse_pos[1]-self.last_y
Window.left = self.new_left
Window.top = -self.new_top
super().on_touch_move(touch)
class MyApp(App):
def build(self):
self.root = Builder.load_string(KV)
MyApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment