33 from python_qt_binding.QtWidgets
import \
34 QButtonGroup, QGroupBox, QLabel, QRadioButton, QVBoxLayout
39 Creates a button group of exclusive radio options.
41 Options must be a dict with following keys:
42 'enabled', 'selected', 'title', 'description', 'tooltip'
45 def __init__(self, options, title='Exclusive Options', selected_index=None, parent=None):
46 super(ExclusiveOptionGroup, self).
__init__()
48 self.setLayout(QVBoxLayout())
55 for (button_id, option)
in enumerate(self.
_options):
57 radio_button = QRadioButton(option.get(
'title',
'option %d' % button_id))
58 radio_button.setEnabled(option.get(
'enabled',
True))
59 radio_button.setChecked(option.get(
'selected',
False)
or button_id == selected_index)
60 radio_button.setToolTip(option.get(
'tooltip',
''))
63 parent.layout().addWidget(radio_button)
64 if 'description' in option:
65 parent.layout().addWidget(QLabel(option[
'description']))
68 """Return dictionary with selected_index (int) and selected_option (dict) keys."""
70 if selected_index >= 0:
72 'selected_index': selected_index,
73 'selected_option': self.
_options[selected_index]
75 return {
'selected_index':
None,
'selected_option':
None}