def _build_option_stack(self): ''' create editable options with visible current values, editation type is define by the option possible values :return: ''' # temporary prototype self.stack_layout_dict = {} self.options = {} # create stack with all editable sections self.stack_layout_dict = { section: QFormLayout() for section in self.sections } for section in self.sections: options = CONF.options(section=section) if 'enable' in options: options.remove('enable') self.options[section] = options for option in options: option_val = CONF.get(section, option) name_reference = section + '||' + option # boolean (true/False) setup if isinstance(option_val, bool): tmp_widget = QCheckBox('On/Off') tmp_widget.setObjectName(name_reference) if option_val: tmp_widget.setChecked(True) else: tmp_widget.setChecked(False) tmp_widget.stateChanged.connect(self._boolean_state) # one string or color setup if isinstance(option_val, str): # TODO take care of hexa strings withou alpha channel if (len(option_val) == 9) & (option_val.startswith('#')): tmp_widget = QHBoxLayout() tmp_val = PreferenceLineedit(option_val, name_reference, 9) tmp_col = ColorButton(hex2rgba(option_val)) tmp_col.setObjectName(name_reference) tmp_col.color_changed.connect(self._color_change) tmp_val.editingFinished.connect(self._color_change_hex) tmp_widget.addWidget(tmp_val) tmp_widget.addWidget(tmp_col) else: tmp_widget = PreferenceLineedit(option_val, name_reference, max_len=100) tmp_widget.editingFinished.connect(self._line_edit) # configuration of list (multiple selection) if (isinstance(option_val, tuple) | isinstance(option_val, list)): tmp_widget = QHBoxLayout() for i, val in enumerate(option_val): name_loc = name_reference + '||{}'.format(i) if isinstance(val, int): validator = QIntValidator() else: validator = None tmp_val = PreferenceLineedit(str(val), name_loc, validator=validator) tmp_val.editingFinished.connect(self._line_edit_multi) tmp_widget.addWidget(tmp_val) self.preferences_changed[section][option] = \ list(option_val) # configuration of single number if isinstance(option_val, int) & ~isinstance(option_val, bool): tmp_widget = PreferenceLineedit(str(option_val), name_reference, max_len=4, validator=QIntValidator()) tmp_widget.editingFinished.connect(self._line_edit) if option.split('/')[0] in self.sections: _, option = option.split('/') # Create nice option name first_letter = option[0] option = option.replace(first_letter, first_letter.upper(), 1) option = option.replace('_', ' ') self.stack_layout_dict[section].addRow(str(option), tmp_widget) # build whole stack for section in self.sections: tmp = QWidget() tmp.setLayout(self.stack_layout_dict[section]) self.options_editor.addWidget(tmp)