Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FIX: Small change to addess a valueError in PyDMSlider when they are being dragged #1147

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

YektaY
Copy link
Collaborator

@YektaY YektaY commented Dec 20, 2024

Currently a value error can be thrown when dragging the handle of a slider that has floating point values. This fix rounds and casts to int the value change while dragging the handle of the PyDMSlider

@YektaY YektaY marked this pull request as ready for review December 20, 2024 19:46
@@ -78,9 +78,9 @@ def mouseMoveEvent(self, event):
delta = event.pos() - self.dragStartPos

if self.orientation() == Qt.Horizontal:
delta_value = (delta.x() / self.getSliderLength()) * (self.maximum() - self.minimum())
delta_value = int(round((delta.x() / self.getSliderLength()) * (self.maximum() - self.minimum())))
Copy link
Collaborator

@nstelter-slac nstelter-slac Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need both round and then int cast?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like not, I thought round would return a float if given a float, but it looks like without a ndigits passed it returns an int. I will remove the int casting

@jbellister-slac jbellister-slac merged commit 26c7a4d into slaclab:master Jan 14, 2025
19 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants