Skip to content

Instantly share code, notes, and snippets.

@tshirtman
Created September 4, 2022 22:41
Show Gist options
  • Save tshirtman/5abf3f15d86498341d1cd1b65330d43d to your computer and use it in GitHub Desktop.
Save tshirtman/5abf3f15d86498341d1cd1b65330d43d to your computer and use it in GitHub Desktop.
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