diff options
author | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-02-14 14:13:53 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-02-14 14:13:53 (GMT) |
commit | 122dba88aa4ee35b8742abb3f5e492ef694b5fcf (patch) | |
tree | 5eddf80d5ff0373b3f2aaf4e35bb764af82db0b1 /activity.py | |
parent | 3eddead0d1572ae37d58937e8ce9abf8badd6cb9 (diff) |
Plot the measure data
Some bugs...
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
Diffstat (limited to 'activity.py')
-rw-r--r-- | activity.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/activity.py b/activity.py index 9ceec6a..7425a0e 100644 --- a/activity.py +++ b/activity.py @@ -48,6 +48,7 @@ from sugar.datastore import datastore from charts import Chart from readers import StopWatch +from readers import Measure def rgb_to_html(color): @@ -76,6 +77,7 @@ def get_user_color(): STOPWATCH_MIME_TYPE = "application/x-stopwatch-activity" +CSV_MIME_TYPE = "text/csv" COLOR1 = gtk.gdk.Color(get_user_color()[0]) COLOR2 = gtk.gdk.Color(get_user_color()[1]) @@ -155,6 +157,13 @@ class SimpleGraph(activity.Activity): activity_btn_toolbar.insert(import_stopwatch, -1) import_stopwatch.show() + + import_measure = ToolButton("import-measure") + import_measure.connect("clicked", self.__import_measure_cb) + activity_btn_toolbar.insert(import_measure, -1) + + import_measure.show() + activity_btn_toolbar.keep.hide() toolbarbox.toolbar.insert(activity_button, 0) @@ -516,6 +525,33 @@ class SimpleGraph(activity.Activity): f.close() + def __import_measure_cb(self, widget): + boolean, file_path, title = self._object_chooser(CSV_MIME_TYPE, + 'Measure') + + if boolean: + reader = Measure() + f = open(file_path) + + reader.set_data(f) + + self.v_label.entry.set_text('Values') + self.h_label.entry.set_text('Samples') + + self.chart_data = [] + self.labels_and_values.model.clear() + + chart_data = reader.get_chart_data() + + # Load the data + for row in chart_data: + self._add_value(None, + label=row[0], value=float(row[1])) + + self.update_chart() + + f.close() + def _save_as_image(self, widget): if self.current_chart: jobject = datastore.create() |