diff --git a/src/core/mixins/signals/main_signals_mixin.py b/src/core/mixins/signals/main_signals_mixin.py index 2efbedf..ad48d24 100644 --- a/src/core/mixins/signals/main_signals_mixin.py +++ b/src/core/mixins/signals/main_signals_mixin.py @@ -18,13 +18,10 @@ class MainSignalsMixin(ListSignalsMixin, TggleAndCheckBoxSignals, SourceviewSign if self.selected_style_id not in self.all_styles_dict: self.all_styles_dict[self.selected_style_id] = StyleProperties() - color_scale = 255.0/65535.0 if data == self.br_color_btn: - color = data.get_color() - self.all_styles_dict[self.selected_style_id].background = ('#%02x%02x%02x' % (color.red * color_scale, color.green * color_scale, color.blue * color_scale)) + self.all_styles_dict[self.selected_style_id].background = self.get_hex(data) elif data == self.fr_color_btn: - color = data.get_color() - self.all_styles_dict[self.selected_style_id].foreground = ('#%02x%02x%02x' % (color.red * color_scale, color.green * color_scale, color.blue * color_scale)) + self.all_styles_dict[self.selected_style_id].foreground = self.get_hex(data) elif data == self.bold_tggle_btn: self.all_styles_dict[self.selected_style_id].bold = data.get_active() elif data == self.italic_tggle_btn: @@ -35,3 +32,12 @@ class MainSignalsMixin(ListSignalsMixin, TggleAndCheckBoxSignals, SourceviewSign self.all_styles_dict[self.selected_style_id].strikethrough = data.get_active() self.update_sample_view() + + def get_hex(self, data): + color_scale = 255.0 / 65535.0 + color = data.get_color() + red = color.red * color_scale + green = color.green * color_scale + blue = color.blue * color_scale + + return ('#%02x%02x%02x' % (int(red), int(green), int(blue)))