def set_cursor(self, cursor: constants.CursorShapeStr | QtGui.QCursor) -> None: if isinstance(cursor, QtGui.QCursor): curs = cursor else: if cursor not in constants.CURSOR_SHAPE: raise InvalidParamError(cursor, constants.CURSOR_SHAPE) curs = gui.Cursor(constants.CURSOR_SHAPE[cursor]) self.setCursor(curs)
def mousePressEvent(self, event): """ override to allow dragging the chart """ if event.button() == QtCore.Qt.RightButton: cursor = gui.Cursor(QtCore.Qt.SizeAllCursor) QtWidgets.QApplication.setOverrideCursor(cursor) self.last_mouse_pos = event.pos() event.accept() super().mousePressEvent(event)
def test_cursor(): cursor = gui.Cursor() cursor.set_shape("arrow") with pytest.raises(InvalidParamError): cursor.set_shape("test") assert cursor.get_shape() == "arrow" with open("data.pkl", "wb") as jar: pickle.dump(cursor, jar) with open("data.pkl", "rb") as jar: cursor = pickle.load(jar) bytes(cursor) cursor.get_position()
def get_cursor(self) -> gui.Cursor: return gui.Cursor(self.cursor())
def set_override_cursor(cls, cursor: constants.CursorShapeStr): crs = gui.Cursor(constants.CURSOR_SHAPE[cursor]) cls.setOverrideCursor(crs)
def test_cursor(): cursor = gui.Cursor() cursor.set_shape("arrow") with pytest.raises(ValueError): cursor.set_shape("test") assert cursor.get_shape() == "arrow"