From 913927c147c1e4ff7e6d41da9d629262f64920d7 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Mon, 29 Apr 2024 22:38:12 +0900 Subject: [PATCH] Show xy coordinate in the status bar --- labelme/app.py | 3 +++ labelme/widgets/canvas.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/labelme/app.py b/labelme/app.py index 579b04521..9a46469aa 100644 --- a/labelme/app.py +++ b/labelme/app.py @@ -169,6 +169,9 @@ def __init__( crosshair=self._config["canvas"]["crosshair"], ) self.canvas.zoomRequest.connect(self.zoomRequest) + self.canvas.mouseMoved.connect( + lambda pos: self.status(f"Mouse is at: x={pos.x()}, y={pos.y()}") + ) scrollArea = QtWidgets.QScrollArea() scrollArea.setWidget(self.canvas) diff --git a/labelme/widgets/canvas.py b/labelme/widgets/canvas.py index 7817aec9a..b78a5fd2a 100644 --- a/labelme/widgets/canvas.py +++ b/labelme/widgets/canvas.py @@ -30,6 +30,7 @@ class Canvas(QtWidgets.QWidget): shapeMoved = QtCore.Signal() drawingPolygon = QtCore.Signal(bool) vertexSelected = QtCore.Signal(bool) + mouseMoved = QtCore.Signal(QtCore.QPointF) CREATE, EDIT = 0, 1 @@ -234,6 +235,8 @@ def mouseMoveEvent(self, ev): except AttributeError: return + self.mouseMoved.emit(pos) + self.prevMovePoint = pos self.restoreCursor()