Home | Trees | Indices | Help |
|
---|
|
1 from PyQt4 import QtGui, QtCore 2 3 from customeditor import AbstractCustomEditor 4 import sip 57629 QtGui.QComboBox.__init__(self, parent) 10 AbstractCustomEditor.__init__(self) 11 self.setEnabled(editable)1214 """ 15 :param choices: a list of (value,name) tuples. name will be displayed in the combobox, 16 while value will be used within get_value and set_value. This method changes the items 17 in the combo box while preserving the current value, even if this value is not in the 18 new list of choices. 19 """ 20 if not sip.isdeleted(self): 21 current_value = self.get_value() 22 for i in range(self.count(), 0, -1): 23 self.removeItem(i-1) 24 for i, (value, name) in enumerate(choices): 25 self.insertItem(i, unicode(name), QtCore.QVariant(value)) 26 self.set_value(current_value)27 3032 """ 33 :rtype: a list of (value,name) tuples 34 """ 35 from camelot.core.utils import variant_to_pyobject 36 return [(variant_to_pyobject(self.itemData(i)),unicode(self.itemText(i))) for i in range(self.count())]3739 if not sip.isdeleted(self): 40 from camelot.core.utils import variant_to_pyobject 41 value = AbstractCustomEditor.set_value(self, value) 42 if value not in (None, NotImplemented): 43 for i in range(self.count()): 44 if value == variant_to_pyobject(self.itemData(i)): 45 self.setCurrentIndex(i) 46 return 47 # it might happen, that when we set the editor data, the set_choices 48 # method has not happened yet, therefore, we temporary set ... in the 49 # text while setting the correct data to the editor 50 self.insertItem(self.count(), '...', QtCore.QVariant(value)) 51 self.setCurrentIndex(self.count()-1)5254 if not sip.isdeleted(self): 55 from camelot.core.utils import variant_to_pyobject 56 current_index = self.currentIndex() 57 if current_index>=0: 58 value = variant_to_pyobject(self.itemData(self.currentIndex())) 59 else: 60 value = None 61 return AbstractCustomEditor.get_value(self) or value
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 12 15:42:13 2010 | http://epydoc.sourceforge.net |