[billreminder] Updated graphic lib and now can handle empty datasets with no warnings.
- From: Og B. Maciel <ogmaciel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [billreminder] Updated graphic lib and now can handle empty datasets with no warnings.
- Date: Fri, 27 Nov 2009 23:55:21 +0000 (UTC)
commit b62686758b963fd1eda6342716e5234b9a348522
Author: Og B. Maciel <ogmaciel gnome org>
Date: Fri Nov 27 18:45:57 2009 -0500
Updated graphic lib and now can handle empty datasets with no warnings.
src/gui/widgets/charting.py | 10 +++++-----
src/gui/widgets/graphics.py | 15 ++++++---------
2 files changed, 11 insertions(+), 14 deletions(-)
---
diff --git a/src/gui/widgets/charting.py b/src/gui/widgets/charting.py
index 4385600..ff45c0f 100644
--- a/src/gui/widgets/charting.py
+++ b/src/gui/widgets/charting.py
@@ -292,10 +292,10 @@ class BarChart(Chart):
self.layout.set_text(self.keys[i])
label_w, label_h = self.layout.get_pixel_size()
- intended_x = (bar_width * i) + (bar_width - label_w) / 2.0
+ intended_x = (bar_width * i) + (bar_width - label_w) / 2.0 + self.graph_x
if not prev_label_end or intended_x > prev_label_end:
- self.context.move_to(intended_x, self.graph_height - 4)
+ self.context.move_to(intended_x, self.graph_height + 4)
context.show_layout(self.layout)
prev_label_end = intended_x + label_w + 3
@@ -385,13 +385,13 @@ class BarChart(Chart):
self.layout.set_text(self.value_format % i)
label_w, label_h = self.layout.get_pixel_size()
context.move_to(legend_width - label_w - 8,
- self.get_pixel(y_value=y) - label_h / 2)
+ y - label_h / 2)
self.set_color(graphics.Colors.aluminium[4])
context.show_layout(self.layout)
self.set_color((255, 255, 255))
- self.context.move_to(legend_width, self.get_pixel(y_value=y))
- self.context.line_to(self.width, self.get_pixel(y_value=y))
+ self.context.move_to(legend_width, y)
+ self.context.line_to(self.width, y)
#stack keys
diff --git a/src/gui/widgets/graphics.py b/src/gui/widgets/graphics.py
index c7a02a5..2bdebb9 100644
--- a/src/gui/widgets/graphics.py
+++ b/src/gui/widgets/graphics.py
@@ -54,7 +54,7 @@ class Area(gtk.DrawingArea):
self.__prev_mouse_regions = None
self.tweener = pytweener.Tweener(0.4, pytweener.Easing.Cubic.easeInOut)
- self.framerate = 30 #thirty seems to be good enough to avoid flicker
+ self.framerate = 80
self.last_frame_time = None
self.__animating = False
@@ -82,10 +82,8 @@ class Area(gtk.DrawingArea):
self.tweener.update(time_since_start)
self.queue_draw()
- self.window.process_updates(True)
self.last_frame_time = dt.datetime.now()
-
return self.__animating
@@ -145,9 +143,8 @@ class Area(gtk.DrawingArea):
""" exposure events """
def do_configure_event(self, event):
- (self.__width, self.__height) = self.window.get_size()
- self.queue_draw()
-
+ (self.width, self.height) = self.window.get_size()
+
def do_expose_event(self, event):
self.width, self.height = self.window.get_size()
self.context = self.window.cairo_create()
@@ -220,7 +217,7 @@ class Area(gtk.DrawingArea):
""" simple example """
-class SimpleAnimation(Area):
+class SampleArea(Area):
def __init__(self):
Area.__init__(self)
self.rect_x, self.rect_y = 10.5, 10.5
@@ -247,10 +244,10 @@ class BasicWindow:
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Graphics Module")
- self.window.set_size_request(500, 500)
+ self.window.set_size_request(300, 300)
self.window.connect("delete_event", self.delete_event)
- self.graphic = SimpleAnimation()
+ self.graphic = SampleArea()
box = gtk.VBox()
box.pack_start(self.graphic)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]