2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

gui: fix Python 3.10 PyQt float/int issues. Closes #1887

This commit is contained in:
Sebastien Bourdeauducq 2022-05-29 08:43:25 +08:00
parent 7cff63e539
commit 667f36a2e7
3 changed files with 12 additions and 12 deletions

View File

@ -71,7 +71,7 @@ class ZoomIconView(QtWidgets.QListView):
self._char_width = QtGui.QFontMetrics(self.font()).averageCharWidth()
self.setViewMode(self.IconMode)
w = self._char_width*self.default_size
self.setIconSize(QtCore.QSize(w, w*self.aspect))
self.setIconSize(QtCore.QSize(w, int(w*self.aspect)))
self.setFlow(self.LeftToRight)
self.setResizeMode(self.Adjust)
self.setWrapping(True)

View File

@ -49,7 +49,7 @@ class ScanWidget(QtWidgets.QWidget):
return self.minimumSizeHint()
def minimumSizeHint(self):
return QtCore.QSize(2.5*3*self._labelSize.width(),
return QtCore.QSize(int(2.5*3*self._labelSize.width()),
4*self._labelSize.height())
def _axisToPixel(self, val):
@ -214,7 +214,7 @@ class ScanWidget(QtWidgets.QWidget):
self._setView(left, scale)
def wheelEvent(self, ev):
y = ev.angleDelta().y()/120.
y = round(ev.angleDelta().y()/120.)
if not y:
return
if ev.modifiers() & QtCore.Qt.ShiftModifier:
@ -252,22 +252,22 @@ class ScanWidget(QtWidgets.QWidget):
for t, l in zip(ticks, labels):
t = self._axisToPixel(t)
painter.drawText(t - len(l)/2*avgCharWidth, 0, l)
painter.drawLine(t, descent, t, lineSpacing/2)
painter.translate(0, lineSpacing/2)
painter.drawText(int(t - len(l)/2*avgCharWidth), 0, l)
painter.drawLine(int(t), descent, int(t), int(lineSpacing/2))
painter.translate(0, int(lineSpacing/2))
painter.drawLine(0, 0, self.width(), 0)
for p in np.linspace(self._axisToPixel(self._start),
self._axisToPixel(self._stop),
self._num):
painter.drawLine(p, 0, p, lineSpacing/2)
painter.translate(0, lineSpacing/2)
painter.drawLine(int(p), 0, int(p), int(lineSpacing/2))
painter.translate(0, int(lineSpacing/2))
for x, c in (self._start, QtCore.Qt.blue), (self._stop, QtCore.Qt.red):
x = self._axisToPixel(x)
painter.setPen(c)
painter.setBrush(c)
painter.drawPolygon(*(QtCore.QPointF(*i) for i in [
(x, 0), (x - lineSpacing/2, lineSpacing),
(x + lineSpacing/2, lineSpacing)]))
(int(x), 0), (int(x - lineSpacing/2), lineSpacing),
(int(x + lineSpacing/2), lineSpacing)]))

View File

@ -75,7 +75,7 @@ class QtWaitingSpinner(QWidget):
color = self.currentLineColor(distance, self._numberOfLines, self._trailFadePercentage,
self._minimumTrailOpacity, self._color)
painter.setBrush(color)
painter.drawRoundedRect(QRect(0, -self._lineWidth / 2, self._lineLength, self._lineWidth), self._roundness,
painter.drawRoundedRect(QRect(0, int(-self._lineWidth / 2), self._lineLength, self._lineWidth), self._roundness,
self._roundness, Qt.RelativeSize)
painter.restore()
@ -160,7 +160,7 @@ class QtWaitingSpinner(QWidget):
self.setFixedSize(self.size, self.size)
def updateTimer(self):
self._timer.setInterval(1000 / (self._numberOfLines * self._revolutionsPerSecond))
self._timer.setInterval(int(1000 / (self._numberOfLines * self._revolutionsPerSecond)))
def lineCountDistanceFromPrimary(self, current, primary, totalNrOfLines):
distance = primary - current