Skip to content

Instantly share code, notes, and snippets.

@kived
Created September 16, 2014 22:31
Show Gist options
  • Save kived/25d5d0fcfa38239c5a2f to your computer and use it in GitHub Desktop.
Save kived/25d5d0fcfa38239c5a2f to your computer and use it in GitHub Desktop.
Kivy: mouse position
from kivy.app import App
from kivy.uix.label import Label
class TestApp(App):
def build(self):
from kivy.core.window import Window
self.label = Label()
Window.bind(mouse_pos=lambda w, p: setattr(self.label, 'text', str(p)))
return self.label
if __name__ == '__main__':
TestApp().run()
@robertmlinden
Copy link

This only works if your mouse is in the Window. How can it track your mouse over the entire screen, even if it isn't in the window.

This is a useful thing to know for "fast-scrolling" mouse events.

@Gobline225
Copy link

Gobline225 commented Apr 10, 2021

You have to use "pyautogui", if you want to get the current position of the mouse even out of the window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment