1
2
3
4 """ pyforms.gui.Controls.ControlCombo """
5
6 import pyforms.Utils.tools as tools
7 from PyQt4 import uic
8 from pyforms.gui.Controls.ControlBase import ControlBase
9
10 __author__ = "Ricardo Ribeiro"
11 __copyright__ = ""
12 __credits__ = "Ricardo Ribeiro"
13 __license__ = "MIT"
14 __version__ = "0.0"
15 __maintainer__ = ["Ricardo Ribeiro", "Carlos Mão de Ferro"]
16 __email__ = ["ricardojvr at gmail.com", "cajomferro at gmail.com"]
17 __status__ = "Development"
21 """This class represents a wrapper to the combo box"""
22
23 _items = None
24
39
41 """Called when the user chooses an item in the combobox and
42 the selected choice is different from the last one selected.
43 @index: item's index
44 """
45 if not self._addingItem:
46 item = self._form.comboBox.currentText()
47 if len(item) >= 1:
48 ControlBase.value.fset(self, self._items[str(item)])
49
52
54 """Called when the user chooses an item in the combobox.
55 Note that this signal happens even when the choice is not changed
56 @index: item's index
57 """
58 pass
59
61 """Called when an item in the combobox popup
62 list is highlighted by the user.
63 @index: item's index
64 """
65 self.highlighted(index)
66
69
70 - def addItem(self, label, value=None):
87
92
93 @property
95
96 @property
98
99 @value.setter
101 for key, val in self.items:
102 if value == val:
103 index = self._form.comboBox.findText(key)
104 self._form.comboBox.setCurrentIndex(index)
105 if self._value != value:
106 self.changed()
107 self._value = val
108
109 @property
110 - def text(self): return str(self._form.comboBox.currentText())
111
112 @text.setter
113 - def text(self, value):
114 for key, val in self.items:
115 if value == key:
116 self.value = val
117 break
118