Created
September 16, 2014 22:31
-
-
Save kived/25d5d0fcfa38239c5a2f to your computer and use it in GitHub Desktop.
Kivy: mouse position
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.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() |
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
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.