def __init__(self, parent, **params): get_or_put(params, 'i18n_def', 'Separator') self.params = Params(**params) self.separatorsGroupBox = GroupBoxWidget(parent, i18n="separator.widget.group.title", i18n_def=nvl(self.params.i18n_def, "Separator"), layout=QVBoxLayout()) self.predefinedSeparatorsComposite = CompositeWidget( self.separatorsGroupBox, layout=QHBoxLayout()) self.predefinedSeparatorsButtonsGroup = ButtonGroupWidget( self.predefinedSeparatorsComposite) self.predefinedSeparatorsSpecs = Separator.getSeparatorsSpec( separator_label_handler) for separatorSpec in self.predefinedSeparatorsSpecs: label = separatorSpec.label if not label == Separator.CUSTOM.label: # @UndefinedVariable predefinedSeparatorCheckBox = CheckBoxWidget( self.predefinedSeparatorsComposite) #attach artificially a separatorSpec object used later in #def setSeparator(self, _separator) method predefinedSeparatorCheckBox.separator_spec = separatorSpec predefinedSeparatorCheckBox.setText(label) predefinedSeparatorCheckBox.sep_spec = separatorSpec if self.params.default_separator and \ separatorSpec.id_ == self.params.default_separator.id_: predefinedSeparatorCheckBox.setChecked(True) self.predefinedSeparatorsButtonsGroup.addButton( predefinedSeparatorCheckBox) self.separatorsGroupBox.connect(self.predefinedSeparatorsButtonsGroup, SIGNAL("buttonClicked(QAbstractButton *)"), self.predefinedSeparatorButtonClicked) if not self.params.no_custom_separator == True: self.customSeparatorCheckBox = CheckBoxWidget( self.predefinedSeparatorsComposite, i18n="separator.custom.checkbox", i18n_def="Custom") self.customSeparatorCheckBox.sep_spec = Separator.CUSTOM self.separatorsGroupBox.connect(self.customSeparatorCheckBox, SIGNAL("clicked()"), self.customSeparatorButtonClicked) self.customSeparatorEdit = LineEditWidget( self.predefinedSeparatorsComposite, maxLength=15, width=get_width_of_n_letters(14), text_changed_handler=self.customSeparatorButtonClicked, enabled=False) self.setEnabled(self.params.enabled)
def setSeparator(self, _separator): if _separator: separatorSign = Separator.getSeparatorSign(_separator) if separatorSign == Separator.WHITE_SPACE: for button in self.predefinedSeparatorsButtonsGroup.buttons(): if button.separator_spec.id_ == Separator.WHITE_SPACE.id_: # @UndefinedVariable @IgnorePep8 button.setChecked(True) return elif separatorSign == Separator.CUSTOM: self.customSeparatorEdit.setText(_separator) self.__uncheckPredefinedButtons__() elif not separatorSign == Separator.NONE: for button in self.predefinedSeparatorsButtonsGroup.buttons(): if button.sep_spec.id_ == separatorSign.id_: if not self.params.no_custom_separator == True: self.__customSeparatorClear__() button.setChecked(True) return
def getSeparatorLabels(): """ to get default separator label names """ return commas(Separator.getSeparatorsLabels())