def draw(self, context): """ Draw the widget. This method is called automatically. Don't call it yourself. If you want to force a redrawing of the widget, call the queue_draw() method. @type context: cairo.Context @param context: The context to draw on. """ label.begin_drawing() rect = self.get_allocation() rect = Gdk.Rectangle( 0, 0, rect.width, rect.height) #transform rect to context coordinates context.set_line_width(1) rect = self.draw_basics(context, rect) maximum_value = max(bar.get_value() for bar in self._bars) #find out the size of the value labels value_label_size = 0 if self._draw_labels: for bar in self._bars: value_label_size = max( value_label_size, bar.get_value_label_size(context, rect, self._mode, len(self._bars), self._bar_padding)) value_label_size += 3 #find out the size of the labels: label_size = 0 if self._draw_labels: for bar in self._bars: label_size = max( label_size, bar.get_label_size(context, rect, self._mode, len(self._bars), self._bar_padding)) label_size += 3 rect = self._do_draw_grid(context, rect, maximum_value, value_label_size, label_size) self._do_draw_bars(context, rect, maximum_value, value_label_size, label_size) label.finish_drawing() if self._mode == MODE_VERTICAL: n = len(self._bars) minimum_width = rect.x + self._padding + ( n - 1) * self._bar_padding + n * 10 minimum_height = 100 + self._padding + rect.y elif self._mode == MODE_HORIZONTAL: n = len(self._bars) minimum_width = rect.x + self._bar_padding + 100 minimum_height = rect.y + self._padding + ( n - 1) * self._bar_padding + n * 10 self.set_size_request(minimum_width, minimum_height)
def draw(self, context): """ Draw the widget. This method is called automatically. Don't call it yourself. If you want to force a redrawing of the widget, call the queue_draw() method. @type context: cairo.Context @param context: The context to draw on. """ label.begin_drawing() rect = self.get_allocation() rect = gtk.gdk.Rectangle(0, 0, rect.width, rect.height) #transform rect to context coordinates context.set_line_width(1) rect = self.draw_basics(context, rect) if type(self._maximum_value) in [int, float]: maximum_value = self._maximum_value else: maximum_value = max(bar.get_value() for bar in self._bars) #find out the size of the value labels value_label_size = 0 if self._draw_labels: for bar in self._bars: value_label_size = max(value_label_size, bar.get_value_label_size(context, rect, self._mode, len(self._bars), self._bar_padding)) value_label_size += 3 #find out the size of the labels: label_size = 0 if self._draw_labels: for bar in self._bars: label_size = max(label_size, bar.get_label_size(context, rect, self._mode, len(self._bars), self._bar_padding)) label_size += 3 rect = self._do_draw_grid(context, rect, maximum_value, value_label_size, label_size) self._do_draw_bars(context, rect, maximum_value, value_label_size, label_size) label.finish_drawing() if self._mode == MODE_VERTICAL: n = len(self._bars) minimum_width = rect.x + self._padding + (n - 1) * self._bar_padding + n * 10 minimum_height = 100 + self._padding + rect.y elif self._mode == MODE_HORIZONTAL: n = len(self._bars) minimum_width = rect.x + self._bar_padding + 100 minimum_height = rect.y + self._padding + (n - 1) * self._bar_padding + n * 10 self.set_size_request(minimum_width, minimum_height)
def draw(self, context): """ Draw the widget. This method is called automatically. Don't call it yourself. If you want to force a redrawing of the widget, call the queue_draw() method. @type context: cairo.Context @param context: The context to draw on. """ label.begin_drawing() chart.init_sensitive_areas() rect = self.get_allocation() rect = gtk.gdk.Rectangle(0, 0, rect.width, rect.height) #transform rect to context coordinates context.set_line_width(1) rect = self.draw_basics(context, rect) maximum_value = max(group.get_maximum_value() for group in self._groups) bar_count = 0 for group in self._groups: bar_count += group.get_bar_count() value_label_size = 0 if self._draw_labels: for group in self._groups: value_label_size = max(value_label_size, group.get_value_label_size(context, rect, self._mode, bar_count, len(self._groups), self._group_padding, self._bar_padding)) label_size = 0 if self._draw_labels: for group in self._groups: label_size = max(label_size, group.get_label_size(context, rect, self._mode, bar_count, len(self._groups), self._group_padding, self._bar_padding, self._label_rotation)) label_size += 10 label_size += group.get_group_label_size(context, rect, self._mode, self._rotate_group_label_in_horizontal_mode) rect = self._do_draw_grid(context, rect, maximum_value, value_label_size, label_size) self._do_draw_groups(context, rect, maximum_value, value_label_size, label_size, bar_count) label.finish_drawing() n = len(self._groups) if self._mode == MODE_VERTICAL: minimum_width = rect.x + self._padding + bar_count * 10 + n * self._group_padding minimum_height = rect.y + self._padding + 200 elif self._mode == MODE_HORIZONTAL: minimum_width = rect.x + self._padding + 200 minimum_height = rect.y + self._padding + bar_count * 10 + n * self._group_padding self.set_size_request(minimum_width, minimum_height)
def draw(self, context): """ Draw the widget. This method is called automatically. Don't call it yourself. If you want to force a redrawing of the widget, call the queue_draw() method. @type context: cairo.Context @param context: The context to draw on. """ label.begin_drawing() rect = self.get_allocation() # initial context settings: line width & font context.set_line_width(1) font = Gtk.Label().style.font_desc.get_family() context.select_font_face(font, cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL) self.draw_basics(context, rect) self._do_draw_shadow(context, rect) self._do_draw_areas(context, rect) label.finish_drawing()
def draw(self, context): """ Draw the widget. This method is called automatically. Don't call it yourself. If you want to force a redrawing of the widget, call the queue_draw() method. @type context: cairo.Context @param context: The context to draw on. """ label.begin_drawing() rect = self.get_allocation() #initial context settings: line width & font context.set_line_width(1) font = Gtk.Label().style.font_desc.get_family() context.select_font_face(font, cairo.FONT_SLANT_NORMAL, \ cairo.FONT_WEIGHT_NORMAL) self.draw_basics(context, rect) self._do_draw_shadow(context, rect) self._do_draw_areas(context, rect) label.finish_drawing()