From a75ee764638e2cadf61cb5902e3ad78a4824382b Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Wed, 16 Mar 2016 21:25:45 +0100 Subject: [PATCH] scanwidget: more adaptable sizing (8bc0c10) --- artiq/gui/scanwidget.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/artiq/gui/scanwidget.py b/artiq/gui/scanwidget.py index 67764b5fc..c2486ac33 100644 --- a/artiq/gui/scanwidget.py +++ b/artiq/gui/scanwidget.py @@ -32,6 +32,11 @@ class ScanWidget(QtWidgets.QSlider): self.setRange(0, 4095) + qfm = QtGui.QFontMetrics(self.font()) + self._labelSize = QtCore.QSize( + (self.ticker.precision + 5)*qfm.averageCharWidth(), + qfm.lineSpacing()) + self._start, self._stop, self._num = None, None, None self._axisView, self._sliderView = None, None self._offset, self._pressed, self._dragLeft = None, None, None @@ -43,9 +48,8 @@ class ScanWidget(QtWidgets.QSlider): return self.minimumSizeHint() def minimumSizeHint(self): - qfm = QtGui.QFontMetrics(self.font()) - return QtCore.QSize(5*10*qfm.averageCharWidth(), - 4*qfm.lineSpacing()) + return QtCore.QSize(2.5*3*self._labelSize.width(), + 4*self._labelSize.height()) def _axisToPixel(self, val): a, b = self._axisView @@ -212,7 +216,8 @@ class ScanWidget(QtWidgets.QSlider): if center: scale = min(scale, self.dynamicRange/abs(center)) left = a*scale/b - self.ticker.min_ticks = int(ev.size().width()/100) + self.ticker.min_ticks = int(ev.size().width() / + (2.5*self._labelSize.width())) self._setView(left, scale) def paintEvent(self, ev):