Created
September 4, 2022 22:41
-
-
Save tshirtman/5abf3f15d86498341d1cd1b65330d43d to your computer and use it in GitHub Desktop.
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.factory import Factory as F | |
from kivy.core.window import Window as W | |
class CrossHairCursorApp(App): | |
def build(self): | |
root = F.Widget() | |
with root.canvas.after: | |
self.v_line = F.Line(points=[]) | |
self.h_line = F.Line(points=[]) | |
W.bind(mouse_pos=self.update_cursor) | |
return root | |
def update_cursor(self, window, mouse_pos): | |
self.v_line.points = [mouse_pos[0], 0, mouse_pos[0], window.height] | |
self.h_line.points = [0, mouse_pos[1], window.width, mouse_pos[1]] | |
if __name__ == '__main__': | |
CrossHairCursorApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment