34 from python_qt_binding.QtWidgets
import \
35 QButtonGroup, QCheckBox, QGroupBox, QLabel, QVBoxLayout
40 Creates a button group of non-exclusive checkbox options. 42 Options must be a dict with following keys: 'enabled','title','description','tooltip' 45 def __init__(self, options, title='Checkboxes', selected_indexes=[], parent=None):
46 super(CheckBoxGroup, self).
__init__()
48 self.setLayout(QVBoxLayout())
50 self._button_group.setExclusive(
False)
55 for (button_id, option)
in enumerate(self.
_options):
57 checkbox = QCheckBox(option.get(
'title',
'option %d' % button_id))
58 checkbox.setEnabled(option.get(
'enabled',
True))
59 checkbox.setChecked(button_id
in selected_indexes)
60 checkbox.setToolTip(option.get(
'tooltip',
''))
62 self._button_group.addButton(checkbox, button_id)
63 parent.layout().addWidget(checkbox)
64 if 'description' in option:
65 parent.layout().addWidget(QLabel(option[
'description']))
68 """Return dictionary with selected_indexes (array) and selected_options (array) keys.""" 71 for button
in self._button_group.buttons():
72 if button.isChecked():
73 selected_indexes.append(self._button_group.id(button))
74 selected_options.append(self.
_options[self._button_group.id(button)])
75 return {
'selected_indexes': selected_indexes,
'selected_options': selected_options}
def __init__(self, options, title='Checkboxes', selected_indexes=[], parent=None)