예제 #1
0
def get_user_fill_color(type='gdk'):
    """Returns the user fill color"""
    color = profile.get_color()
    if type == 'gdk':
        rcolor = Color(color.get_fill_color()).get_gdk_color()

    elif type == 'str':
        rcolor = color.get_fill_color()

    return rcolor
예제 #2
0
    def _set_font_option(self, *args):
        if not hasattr(self, 'font_name_combo'):
            return

        self._font_option = args[-1]

        font, size, color = self._get_chart_font_options(self._font_option)

        self.font_name_combo.set_font_name(font)
        self.font_size.set_font_size(size)
        self.text_color_btn.set_color(Color(color).get_gdk_color())
예제 #3
0
    def load_from_file(self, f):
        try:
            data = json.load(f)
        finally:
            f.close()

        self.metadata['title'] = data['title']
        self.x_label = data['x_label']
        self.y_label = data['y_label']
        self.chart_color = data['chart_color']
        self.chart_line_color = data['chart_line_color']
        self.current_chart.type = data['current_chart.type']

        # Make it compatible with old Chart instances
        if 'font_options' in data:
            self._font_options = data['font_options']

        chart_data = data['chart_data']

        # Update charts buttons
        self._update_chart_active_button()

        # Update the controls in the config subtoolbar
        self.chart_color_btn.set_color(Color(self.chart_color).get_gdk_color())
        self.line_color_btn.set_color(Color(self.chart_line_color).
                                      get_gdk_color())

        # If the saved label is not '', set the text entry with the saved label
        if self.x_label != '':
            self.h_label.entry.set_text(self.x_label)

        if self.y_label != '':
            self.v_label.entry.set_text(self.y_label)

        # load the data
        for row in chart_data:
            self._add_value(None, label=row[0], value=float(row[1]))

        self.update_chart()
예제 #4
0
    def __draw_bar(self, widget, context, votos, total, xo_color):
        """
        Graphic the percent of votes from one option.
        """
        stroke_color = Color(xo_color.get_stroke_color())
        fill_color = Color(xo_color.get_fill_color())

        rect = widget.get_allocation()
        w, h = (rect.width, rect.height)
        percent = votos * 100 / total
        width = w * percent / 100

        context.rectangle(0, h / 2 - 10, width, 20)
        context.set_source_rgba(*fill_color.get_rgba())
        context.fill_preserve()
        context.set_source_rgba(*stroke_color.get_rgba())
        context.set_line_width(3)
        context.stroke()

        return True
예제 #5
0
selected_colors = {
    "text": (0.0, 0.0, 0.0),
    "fg": (0.0, 0.0, 0.0),
    "bg": (0.0, 0.0, 0.0),
    "border": (0.0, 0.0, 0.0),  # bounding box
    "fill": (0.0, 0.0, 0.0)  # bounding box
}

default_font = None

default_font_size = '10'

try:
    # Sugar specific tweak
    xo_col = get_color()
    rf, gf, bf, af = Color(xo_col.get_fill_color()).get_rgba()
    rs, gs, bs, as_ = Color(xo_col.get_stroke_color()).get_rgba()

    # Use white or black text for best contrast
    if rf + gf + bf < 0.5:
        rt, gt, bt = 1, 1, 1
    else:
        rt, gt, bt = 0, 0, 0
    primary_colors = {
        "bg": (rf, gf, bf),
        "fg": (rs, gs, bs),
        "text": (rt, gt, bt)
    }
except:
    primary_colors = {
        "bg": (0.2, 0.6, 1.0),