def __init__(self, parent, **params): get_or_put(params, 'i18n', 'time.units.group.title') get_or_put(params, 'i18n_def', 'Time units') get_or_put(params, 'layout', QHBoxLayout()) self.default_unit = params.get('default_unit', Millisecond) super(TimeUnitsWidget, self).__init__(parent, **params) self.__unitsButtonsGroup__ = ButtonGroupWidget(self) self.__change_unit_handler__ = params.get('change_unit_handler', None) for time_unit in get_units_for_type(TimeUnit): unitCheckBox = CheckBoxWidget(self, i18n_def="%s [%s]" % (time_unit.name, time_unit.label)) #add artificially property unit for later use in getUnit method unitCheckBox.unit = time_unit if time_unit == self.default_unit: unitCheckBox.setChecked(True) self.__unitsButtonsGroup__.addButton(unitCheckBox) self.connect(self.__unitsButtonsGroup__, SIGNAL("buttonClicked(QAbstractButton *)"), self.__buttonClicked__) self.__old_button_unit__ = None
def __createAnnotationButtons__(self): self.__button_group__ = ButtonGroupWidget(self) unique_annotations0 = get_unique_annotations( self.data_accessor.annotation0) empty = is_empty(unique_annotations0) self.set_title(empty) self.__all_button__ = CheckBoxWidget( self, i18n_def='ALL', clicked_handler=self.__all_button_handler__) self.__button_group__.addButton(self.__all_button__) for unique_annotation in unique_annotations0: annotationCheckBox = CheckBoxWidget( self, i18n_def=str(unique_annotation)) self.__button_group__.addButton(annotationCheckBox) self.__button_group__.setExclusive(False) self.__button_group__.connect(self.__button_group__, BUTTON_CLICKED_SIGNAL, self.__button_handler__)