예제 #1
0
 def __init__(self, container=None, box_data=None, init_state=None):
     QComboBox.__init__(self, parent=container)
     self.current = init_state
     for item in box_data:
         self.addItem('%s' % item)
     self.setCurrentIndex(self.current)
     self.currentIndexChanged[int].connect(self.index_changed)
예제 #2
0
 def __init__(self, parent, values, curvalue, add_other=False):
     QComboBox.__init__(self, parent)
     self._values = sorted(values, key=str)
     self._textvals = list(map(str, self._values))
     self._add_other = add_other
     if add_other:
         self._values.append(Ellipsis)
         self._textvals.append('<other value>')
     self.addItems(self._textvals)
     if curvalue in self._values:
         self.setCurrentIndex(self._values.index(curvalue))
     elif add_other:
         self.setCurrentIndex(len(self._values) - 1)
     self.currentIndexChanged['int'].connect(
         lambda idx: self.valueModified.emit())
예제 #3
0
 def __init__(self,
              parent,
              curvalue,
              client,
              needs_class='nicos.core.device.Device',
              allow_enter=False):
     QComboBox.__init__(self, parent, editable=True)
     self.setSizePolicy(
         QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
     if client:
         devs = client.getDeviceList(needs_class)
         self.addItems(devs)
         try:
             index = devs.index(curvalue)
             self.setCurrentIndex(index)
         except ValueError:
             self.setEditText(curvalue)
     else:
         self.setEditText(curvalue)
     self.editTextChanged.connect(lambda _: self.valueModified.emit())
     if allow_enter:
         self.lineEdit().returnPressed.connect(
             lambda: self.valueChosen.emit(self.currentText()))