20c20 < from qtvcp.core import Action, Status --- > from qtvcp.core import Action, Status, Info 25a26 > INFO = Info() 211c212,213 < if count == self.maximum(): count = 0 --- > # wrapping dials -> 0 and maximum is the same position > if count == self.maximum() and self.wrapping(): count = 0 373a376,386 > self._isAllHomed = False > self._isHomed = False > > # button enabled states > self._is_all_homed_sensitive = False > self._is_on_sensitive = False > self._is_idle_sensitive = False > self._is_run_sensitive = False > self._is_manual_sensitive = False > self._is_mdi_sensitive = False > self._is_auto_sensitive = False 403a417,464 > if self._is_on_sensitive: > STATUS.connect('state-off', lambda w: self.setEnabled(False)) > STATUS.connect('state-on', lambda w: enable_logic_check(True)) > if self._is_all_homed_sensitive: > STATUS.connect('all-homed', lambda w: enable_logic_check(True)) > STATUS.connect('not-all-homed', lambda w, axis: self.setEnabled(False)) > if self._is_idle_sensitive: > STATUS.connect('interp-run', lambda w: self.setEnabled(False)) > STATUS.connect('interp-paused', lambda w: self.setEnabled(False)) > STATUS.connect('interp-idle', lambda w: enable_logic_check(True)) > elif self._is_run_sensitive: > STATUS.connect('interp-run', lambda w: enable_logic_check(True)) > STATUS.connect('interp-paused', lambda w: self.setEnabled(False)) > STATUS.connect('interp-idle', lambda w: self.setEnabled(False)) > if self._is_manual_sensitive or self._is_mdi_sensitive or self._is_auto_sensitive: > STATUS.connect('mode-manual', lambda w: enable_logic_check(self._is_manual_sensitive)) > STATUS.connect('mode-mdi', lambda w: enable_logic_check(self._is_mdi_sensitive)) > STATUS.connect('mode-auto', lambda w: enable_logic_check(self._is_auto_sensitive)) > > # if nothing selected make estop reset sensitive > if not (self._is_idle_sensitive or self._is_run_sensitive or \ > self._is_on_sensitive or self._is_all_homed_sensitive or \ > self._is_manual_sensitive or self._is_mdi_sensitive or \ > self._is_auto_sensitive): > STATUS.connect('state-estop-reset', lambda w: self.setEnabled(True)) > > # check for multiple selected enabled requests > def enable_logic_check(state): > if state: > temp = True > if self._is_run_sensitive: > temp = temp and STATUS.is_interp_running() > if self._is_on_sensitive: > temp = temp and STATUS.machine_is_on() > if self._is_all_homed_sensitive: > temp = temp and (STATUS.is_all_homed() or INFO.NO_HOME_REQUIRED) > if self._is_manual_sensitive: > temp = temp and STATUS.is_man_mode() > if self._is_mdi_sensitive: > temp = temp and STATUS.is_mdi_mode() > if self._is_auto_sensitive: > temp = temp and STATUS.is_auto_mode() > if self._is_idle_sensitive: > temp = temp and STATUS.is_interp_idle() > self.setEnabled(temp) > else: > self.setEnabled(False) > 437,438c498,499 < STATUS.connect('all-homed', lambda w: self._flip_state(True)) < STATUS.connect('not-all-homed', lambda w, axis: self._flip_state(False)) --- > STATUS.connect('all-homed', lambda w: self._flip_state(True, prop = 'isAllHomed')) > STATUS.connect('not-all-homed', lambda w, axis: self._flip_state(False, prop = 'isAllHomed')) 474c535 < self._flip_state(True) --- > self._flip_state(True, prop = 'isHomed') 478c539 < self._flip_state(False) --- > self._flip_state(False, prop = 'isHomed') 532a594,598 > except AttributeError as e: > LOG.error('({} called exec in error:{}'.format(self.objectName(),e)) > LOG.warning(' Command was {}'.format(self.true_python_command)) > LOG.warning(' List of objects:') > print(dir(self.QTVCP_INSTANCE_)) 538a605,609 > except AttributeError as e: > LOG.error('({} called exec in error:{}'.format(self.objectName(),e)) > LOG.warning(' Command was {}'.format(self.false_python_command)) > LOG.warning(' List of objects:') > print(dir(self.QTVCP_INSTANCE_)) 590,592c661 < y = int(0 + self._top_edge_offset) < # x = self.width() - self._diameter - self._right_edge_offset < # y = 0 + self._top_edge_offset --- > y = int(0 + self._top_edge_offset) 616,632c685,689 < < ar1=int( topLeft.x() + (self.width() ) ) < ar2=int( ( (1-self._w_fraction) /2) ) < ar3=int( self._top_edge_offset ) < p.drawRoundedRect(ar1*ar2 + ar3, < int(topLeft.y()+self._right_edge_offset), < int(self.width()*self._w_fraction+2), < int(self.height()*self._h_fraction), < int(self._corner_radius), int(self._corner_radius) ) < < # p.drawRoundedRect( topLeft.x()+(self.width()*((1-self._w_fraction)/2)) + self._top_edge_offset , < # topLeft.y()+self._right_edge_offset, < # int(self.width()*self._w_fraction+2), < # int(self.height()*self._h_fraction), < # self.width()*self._w_fraction+2, < # self.height()*self._h_fraction, < # self._corner_radius, self._corner_radius) --- > p.drawRoundedRect(topLeft.x()+(self.width()*((1-self._w_fraction)/2)) + self._top_edge_offset, > topLeft.y()+self._right_edge_offset, > self.width()*self._w_fraction+2, > self.height()*self._h_fraction, > self._corner_radius, self._corner_radius) 830d886 < # circle_diameter = QtCore.pyqtProperty(float, get_circle_diameter, set_circle_diameter, reset_circle_diameter) 832,833c888,889 < right_edge_offset = QtCore.pyqtProperty(float, get_right_edge_offset, set_right_edge_offset, reset_right_edge_offset) < top_edge_offset = QtCore.pyqtProperty(float, get_top_edge_offset, set_top_edge_offset, reset_top_edge_offset) --- > right_edge_offset = QtCore.pyqtProperty(int, get_right_edge_offset, set_right_edge_offset, reset_right_edge_offset) > top_edge_offset = QtCore.pyqtProperty(int, get_top_edge_offset, set_top_edge_offset, reset_top_edge_offset) 1106a1163,1217 > def setisHomed(self, data): > self._isHomed = data > def getisHomed(self): > return self._isHomed > isHomed = QtCore.pyqtProperty(bool, getisHomed, setisHomed) > > def setisAllHomed(self, data): > self._isAllHomed = data > def getisAllHomed(self): > return self._isAllHomed > isAllHomed = QtCore.pyqtProperty(bool, getisAllHomed, setisAllHomed) > > # properties for enable/disable button on status state > def setisAllHomedSensitive(self, data): > self._is_all_homed_sensitive = data > def getisAllHomedSensitive(self): > return self._is_all_homed_sensitive > isAllHomedSensitive = QtCore.pyqtProperty(bool, getisAllHomedSensitive, setisAllHomedSensitive) > > def setisOnSensitive(self, data): > self._is_on_sensitive = data > def getisOnSensitive(self): > return self._is_on_sensitive > isOnSensitive = QtCore.pyqtProperty(bool, getisOnSensitive, setisOnSensitive) > > def setisIdleSensitive(self, data): > self._is_idle_sensitive = data > def getisIdleSensitive(self): > return self._is_idle_sensitive > isIdleSensitive = QtCore.pyqtProperty(bool, getisIdleSensitive, setisIdleSensitive) > > def setisRunSensitive(self, data): > self._is_run_sensitive = data > def getisRunSensitive(self): > return self._is_run_sensitive > isRunSensitive = QtCore.pyqtProperty(bool, getisRunSensitive, setisRunSensitive) > > def setisManSensitive(self, data): > self._is_manual_sensitive = data > def getisManSensitive(self): > return self._is_manual_sensitive > isManSensitive = QtCore.pyqtProperty(bool, getisManSensitive, setisManSensitive) > > def setisMDISensitive(self, data): > self._is_mdi_sensitive = data > def getisMDISensitive(self): > return self._is_mdi_sensitive > isMDISensitive = QtCore.pyqtProperty(bool, getisMDISensitive, setisMDISensitive) > > def setisAutoSensitive(self, data): > self._is_auto_sensitive = data > def getisAutoSensitive(self): > return self._is_auto_sensitive > isAutoSensitive = QtCore.pyqtProperty(bool, getisAutoSensitive, setisAutoSensitive) > 1138a1250,1253 > ''' > Label that scales the text based on available size. > Base widget for DRO display. > ''' 1140a1256,1257 > self._text = '' > self._scaled = True 1143c1260 < if self.textFormat() == 0: --- > if self.textFormat() in( 0,1) and self._scaled: 1146c1263,1271 < self.setMinSize(14) --- > self.setMinSize(15) > > def textSample(self): > ''' > Holds a sample of text to reserve space for the longest text. > ''' > if self._text =='': > return self.text() > return self._text 1148c1273 < def setMinSize(self, minfs): --- > def setMinSize(self, minfs): 1150,1151c1275,1276 < f.setPixelSize(minfs) < br = QtGui.QFontMetrics(f).boundingRect(self.text()) --- > f.setPointSizeF(minfs) > br = QtGui.QFontMetrics(f).boundingRect(self.textSample()) 1154,1155c1279,1283 < def resizeEvent(self, event): < super(ScaledLabel, self).resizeEvent(event) --- > def setMaxSize(self, maxfs): > f = self.font() > f.setPointSizeF(maxfs) > br = QtGui.QFontMetrics(f).boundingRect(self.textSample()) > self.setMaximumSize(br.width(), br.height()) 1157c1285,1292 < if not self.text() or self.textFormat() in(1, 2): --- > def resizeEvent(self, event): > super(ScaledLabel, self).resizeEvent(event) > if not self._scaled: > return > #if self.textFormat() == QtCore.Qt.RichText: > #print(self.text()) > #print(self.styleSheet(),self.text(),self.font().pointSizeF()) > if not self.text() or self.textFormat() == QtCore.Qt.AutoText: 1167c1302 < fs = max(f.pixelSize(), 1) --- > fs = max(f.pointSizeF(), .5) 1169c1304 < f.setPixelSize(fs) --- > f.setPointSize(fs) 1171c1306 < br = QtGui.QFontMetrics(f).tightBoundingRect(self.text()) --- > #br = QtGui.QFontMetrics(f).tightBoundingRect(self.textSample()) 1173c1308 < #br = QtGui.QFontMetrics(f).boundingRect(self.text()) --- > br = QtGui.QFontMetrics(f).boundingRect(self.textSample()) 1176c1311 < fs += 1 --- > fs += .5 1178c1313 < f.setPixelSize(max(fs - 1, 1)) # backtrack --- > f.setPointSizeF(max(fs - .5, .5)) # backtrack 1183c1318 < fs -= 1 --- > fs -= .5 1187,1188c1322,1324 < if fs < 1: break < #print br, cr --- > if fs < .5: break > > #print (br, cr) 1190c1326,1350 < self.setFont(f) --- > if self.textFormat() == QtCore.Qt.RichText: > self.setStyleFontSize(f.pointSizeF()) > else: > self.setFont(f) > > def setStyleFontSize(self, fs): > self.setStyleSheet(' font: {}pt ;'.format(fs)) > > def set_scaleText(self, data): > self._scaled = data > def get_scaleText(self): > return self._scaled > def reset_scaleText(self): > self._scaled = True > > def set_testSample(self, data): > self._text = data > def get_testSample(self): > return self._text > def reset_testSample(self): > self._text = '' > > scaleText = QtCore.pyqtProperty(bool, get_scaleText, set_scaleText, reset_scaleText) > textSpaceSample = QtCore.pyqtProperty(str, get_testSample, set_testSample, reset_testSample) >