-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombo box.py
More file actions
17 lines (16 loc) · 734 Bytes
/
Copy pathcombo box.py
File metadata and controls
17 lines (16 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class ComboBoxWithMultiSelect:
def __init__(self, c_b, it):
self.combo_box = c_b
self.items = it
self.combo_box.addItems(self.items)
self.combo_box.currentTextChanged.connect(self.select)
def select(self):
if self.combo_box.currentText() not in {'select', ''}:
if ' (selected)' in self.combo_box.currentText():
self.items[self.combo_box.currentIndex()] = \
self.items[self.combo_box.currentIndex()].split(' (selected)')[0]
else:
self.items[self.combo_box.currentIndex()] += ' (selected)'
self.combo_box.clear()
self.combo_box.addItems(self.items)
self.combo_box.showPopup()