Refine coordinate selector

This commit is contained in:
AuroraWright
2025-10-14 12:35:07 +02:00
parent c7b7992678
commit 7962275b73

View File

@@ -50,6 +50,9 @@ class ScreenSelector:
def on_release(event):
nonlocal start_x, start_y
if start_x is None or start_y is None:
return
end_x, end_y = event.x, event.y
x1 = min(start_x, end_x)
@@ -64,9 +67,18 @@ class ScreenSelector:
self.on_select(monitor, (x1, y1, x2 - x1, y2 - y1))
def reset_selection(event):
nonlocal start_x, start_y, rect
if rect:
canvas.delete(rect)
rect = None
start_x = None
start_y = None
canvas.bind('<ButtonPress-1>', on_click)
canvas.bind('<B1-Motion>', on_drag)
canvas.bind('<ButtonRelease-1>', on_release)
canvas.bind('<Leave>', reset_selection)
def _create_selection_window(self, img, geometry, scale_x=1, scale_y=1, monitor=None):
window = tk.Toplevel(self.root)