def test_TaurusValueCombobox(qtbot, model, names, value, expected): """Check that the TaurusValueComboBox is started with the right display See https://github.com/taurus-org/taurus/pull/1032 """ a = taurus.Attribute(model) a.write(value) w = TaurusValueComboBox() qtbot.addWidget(w) # ---------------------------------- # workaround: avoid PySide2 segfaults when adding quantity to combobox # https://bugreports.qt.io/browse/PYSIDE-683 if isinstance(value, UR.Quantity) and PYSIDE2: pytest.skip("avoid segfault due to PYSIDE-683 bug") # ---------------------------------- w.addValueNames(names) qtbot.wait_until(lambda: w.count() == len(names), timeout=3200) try: with qtbot.waitSignal(w.valueChangedSignal, timeout=3200): w.setModel(model) assert w.currentText() == expected finally: del a # set model to None as an attempt to avoid problems in atexit() with qtbot.waitSignal(w.valueChangedSignal, timeout=3200): w.setModel(None)
class Ui_CameraSettingsDialog(object): def setupUi(self, CameraSettingsDialog): CameraSettingsDialog.setObjectName(_fromUtf8("CameraSettingsDialog")) CameraSettingsDialog.resize(271, 162) self.verticalLayout = QtGui.QVBoxLayout(CameraSettingsDialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.taurusWidget = TaurusWidget(CameraSettingsDialog) self.taurusWidget.setObjectName(_fromUtf8("taurusWidget")) self.gridLayout = QtGui.QGridLayout(self.taurusWidget) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.label_3 = QtGui.QLabel(self.taurusWidget) self.label_3.setObjectName(_fromUtf8("label_3")) self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1) self.imageTypeComboBox = TaurusValueComboBox(self.taurusWidget) self.imageTypeComboBox.setObjectName(_fromUtf8("imageTypeComboBox")) self.gridLayout.addWidget(self.imageTypeComboBox, 0, 1, 1, 1) self.label_4 = QtGui.QLabel(self.taurusWidget) self.label_4.setObjectName(_fromUtf8("label_4")) self.gridLayout.addWidget(self.label_4, 1, 0, 1, 1) self.triggerModeComboBox = TaurusValueComboBox(self.taurusWidget) self.triggerModeComboBox.setObjectName( _fromUtf8("triggerModeComboBox")) self.gridLayout.addWidget(self.triggerModeComboBox, 1, 1, 1, 1) self.label_5 = QtGui.QLabel(self.taurusWidget) self.label_5.setObjectName(_fromUtf8("label_5")) self.gridLayout.addWidget(self.label_5, 2, 0, 1, 1) self.expTimeLineEdit = MAXLineEdit(self.taurusWidget) self.expTimeLineEdit.setModel(_fromUtf8("")) self.expTimeLineEdit.setUseParentModel(False) self.expTimeLineEdit.setObjectName(_fromUtf8("expTimeLineEdit")) self.gridLayout.addWidget(self.expTimeLineEdit, 2, 1, 1, 1) self.label_6 = QtGui.QLabel(self.taurusWidget) self.label_6.setObjectName(_fromUtf8("label_6")) self.gridLayout.addWidget(self.label_6, 3, 0, 1, 1) self.gainLineEdit = MAXLineEdit(self.taurusWidget) self.gainLineEdit.setObjectName(_fromUtf8("gainLineEdit")) self.gridLayout.addWidget(self.gainLineEdit, 3, 1, 1, 1) self.verticalLayout.addWidget(self.taurusWidget) self.retranslateUi(CameraSettingsDialog) QtCore.QMetaObject.connectSlotsByName(CameraSettingsDialog) def retranslateUi(self, CameraSettingsDialog): CameraSettingsDialog.setWindowTitle( _translate("CameraSettingsDialog", "Camera Settings", None)) self.label_3.setText( _translate("CameraSettingsDialog", "Image Type", None)) self.label_4.setText( _translate("CameraSettingsDialog", "Trigger Mode", None)) self.label_5.setText( _translate("CameraSettingsDialog", "Exposure (ms)", None)) self.label_6.setText( _translate("CameraSettingsDialog", "Gain (dB)", None))
def setModel(self, model): TaurusValueComboBox.setModel(self, '%s/value' % model) #@todo: change this (it assumes tango naming!) try: ior_dev = taurus.Device(model) except: return labels = ior_dev.getAttribute('Labels').read().value labels_list = labels.split(' ') # Update the mapping self.writeValueNames = [] for label_and_value in labels_list: label, value = label_and_value.split(':') self.writeValueNames.append((label, value)) self.setValueNames(self.writeValueNames)
def setModel(self, model): # @todo: change this (it assumes tango naming!) TaurusValueComboBox.setModel(self, '%s/value' % model) try: ior_dev = taurus.Device(model) except: return labels = ior_dev.getAttribute('Labels').read().value labels_list = labels.split(' ') # Update the mapping self.writeValueNames = [] for label_and_value in labels_list: label, value = label_and_value.split(':') self.writeValueNames.append((label, value)) self.setValueNames(self.writeValueNames)
def __init__(self, parent=None, designMode=False): TaurusValueComboBox.__init__(self, parent, designMode) TaurusValueComboBox.setForcedApply(self, True)