Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-03-09 13:59:14 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-03-09 13:59:14 (GMT)
commit7bfe9246498b483495f163536ff9f1f3385211f6 (patch)
tree8ab8e423c8a6a4f4e8fd35e8d1e4a3d2b9889d34
parent0d488062920a9e84aee8d695ac261455bf2b154d (diff)
Choose measure channel
-rw-r--r--activity.py31
-rw-r--r--icons/measure-channel-1.svg130
-rw-r--r--icons/measure-channel-2.svg129
-rw-r--r--readers.py12
4 files changed, 297 insertions, 5 deletions
diff --git a/activity.py b/activity.py
index a9c0844..cee3b06 100644
--- a/activity.py
+++ b/activity.py
@@ -135,12 +135,16 @@ class SimpleGraph(activity.Activity):
import_stopwatch = ToolButton("import-stopwatch")
import_stopwatch.connect("clicked", self.__import_stopwatch_cb)
+ import_stopwatch.set_tooltip(_("Read StopWatch data"))
activity_btn_toolbar.insert(import_stopwatch, -1)
import_stopwatch.show()
import_measure = ToolButton("import-measure")
- import_measure.connect("clicked", self.__import_measure_cb)
+ import_measure.set_tooltip(_("Read Measure data"))
+ import_measure.connect("clicked", self._measure_btn_clicked)
+ self._create_measure_palette(import_measure)
+
activity_btn_toolbar.insert(import_measure, -1)
import_measure.show()
@@ -319,6 +323,27 @@ class SimpleGraph(activity.Activity):
self.show_all()
+ def _create_measure_palette(self, button):
+ palette = button.get_palette()
+ hbox = gtk.HBox()
+
+ channel1 = ToolButton("measure-channel-1")
+ channel1.connect("clicked", self.__import_measure_cb, 1)
+
+ channel2 = ToolButton("measure-channel-2")
+ channel2.connect("clicked", self.__import_measure_cb, 2)
+
+ hbox.pack_start(channel1, False, True, 0)
+ hbox.pack_end(channel2, False, True, 0)
+
+ hbox.show_all()
+
+ palette.set_content(hbox)
+
+ def _measure_btn_clicked(self, button):
+ palette = button.get_palette()
+ palette.popup()
+
def _add_value(self, widget, label="", value="0.0"):
data = (label, float(value))
if not data in self.chart_data:
@@ -507,14 +532,14 @@ class SimpleGraph(activity.Activity):
f.close()
- def __import_measure_cb(self, widget):
+ def __import_measure_cb(self, widget, channel=1):
matches_mime_type, file_path, title = self._object_chooser(
_CSV_MIME_TYPE,
_('Measure'))
if matches_mime_type:
f = open(file_path)
- reader = MeasureReader(f)
+ reader = MeasureReader(f, channel)
self._graph_from_reader(reader)
f.close()
diff --git a/icons/measure-channel-1.svg b/icons/measure-channel-1.svg
new file mode 100644
index 0000000..1a8fa62
--- /dev/null
+++ b/icons/measure-channel-1.svg
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="55"
+ height="55"
+ viewBox="0 0 55 55"
+ id="svg2"
+ xml:space="preserve"
+ inkscape:version="0.48.2 r9819"
+ sodipodi:docname="measure_channel1.svg"><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1280"
+ inkscape:window-height="746"
+ id="namedview5593"
+ showgrid="false"
+ inkscape:zoom="4.4363636"
+ inkscape:cx="-22.515939"
+ inkscape:cy="7.280768"
+ inkscape:window-x="0"
+ inkscape:window-y="26"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg2"
+ showguides="true"
+ inkscape:guide-bbox="true" /><metadata
+ id="metadata25"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
+ id="defs33"><linearGradient
+ inkscape:collect="always"
+ id="linearGradient6103"><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop6105" /><stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop6107" /></linearGradient>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6103"
+ id="linearGradient6113"
+ x1="-77.199659"
+ y1="39.804963"
+ x2="-43.648659"
+ y2="39.804963"
+ gradientUnits="userSpaceOnUse" /></defs><g
+ transform="matrix(0.85173375,0,0,0.8470252,-0.54383938,9.673194)"
+ style="fill:none;stroke:#ffffff;stroke-opacity:1;display:block"
+ display="block"
+ id="activity-measure"><g
+ id="g6214"
+ style="fill:none;stroke:#ffffff;stroke-opacity:1"><path
+ style="fill:none;stroke:#ffffff;stroke-opacity:1"
+ inkscape:connector-curvature="0"
+ d="m 48.143,36.983 c 0,3.3 -2.7,6 -6,6 H 12.705 c -3.3,0 -6,-2.7 -6,-6 v -18.77 c 0,-3.3 2.7,-6 6,-6 h 29.438 c 3.3,0 6,2.7 6,6 v 18.77 z"
+ id="path6216" /><path
+ style="fill:none;stroke:#ffffff;stroke-width:3.50000000000000000;stroke-linejoin:round;stroke-opacity:1"
+ inkscape:connector-curvature="0"
+ d="m 48.143,36.983 c 0,3.3 -2.7,6 -6,6 H 12.705 c -3.3,0 -6,-2.7 -6,-6 v -18.77 c 0,-3.3 2.7,-6 6,-6 h 29.438 c 3.3,0 6,2.7 6,6 v 18.77 z"
+ id="path6218" /></g><path
+ style="fill:none;stroke:#ffffff;stroke-width:3.50000000000000000;stroke-linejoin:round;stroke-opacity:1"
+ inkscape:connector-curvature="0"
+ d="m 8.007,27.598 c 10.118,0 6.243,9.431 11.213,9.431 4.375,0 2.154,-19.154 6.279,-19.154 4.875,0 1.719,19.154 6.719,19.154 4.406,0 1.781,-11.529 5.156,-11.529 3.375,0 2,4.875 4.25,4.875 2.375,0 0.25,-3.375 5.75,-3.375"
+ id="path6220" /></g><text
+ xml:space="preserve"
+ style="font-size:49.01127243000000533px;font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#ffffff;font-family:gargi;-inkscape-font-specification:gargi Medium;stroke-opacity:1"
+ x="32.003532"
+ y="40.800385"
+ id="text3843"
+ sodipodi:linespacing="125%"
+ transform="scale(1.0088912,0.9911872)"><tspan
+ sodipodi:role="line"
+ id="tspan3845"
+ x="32.003532"
+ y="40.800385">1</tspan></text>
+
+</svg> \ No newline at end of file
diff --git a/icons/measure-channel-2.svg b/icons/measure-channel-2.svg
new file mode 100644
index 0000000..4c0a91a
--- /dev/null
+++ b/icons/measure-channel-2.svg
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="55"
+ height="55"
+ viewBox="0 0 55 55"
+ id="svg2"
+ xml:space="preserve"
+ inkscape:version="0.48.2 r9819"
+ sodipodi:docname="measure_channel2.svg"><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1280"
+ inkscape:window-height="746"
+ id="namedview5593"
+ showgrid="false"
+ inkscape:zoom="4.4363636"
+ inkscape:cx="-14.538935"
+ inkscape:cy="7.280768"
+ inkscape:window-x="0"
+ inkscape:window-y="26"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg2"
+ showguides="true"
+ inkscape:guide-bbox="true" /><metadata
+ id="metadata25"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs33"><linearGradient
+ inkscape:collect="always"
+ id="linearGradient6103"><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop6105" /><stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop6107" /></linearGradient>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6103"
+ id="linearGradient6113"
+ x1="-77.199659"
+ y1="39.804963"
+ x2="-43.648659"
+ y2="39.804963"
+ gradientUnits="userSpaceOnUse" /></defs><g
+ transform="matrix(0.72645535,0,0,0.71529558,-0.8274669,14.435716)"
+ style="fill:none;stroke:#ffffff;stroke-opacity:1;display:block"
+ display="block"
+ id="activity-measure"><g
+ id="g6214"
+ style="fill:none;stroke:#ffffff;stroke-opacity:1"><path
+ style="fill:none;stroke:#ffffff;stroke-opacity:1"
+ inkscape:connector-curvature="0"
+ d="m 48.143,36.983 c 0,3.3 -2.7,6 -6,6 H 12.705 c -3.3,0 -6,-2.7 -6,-6 v -18.77 c 0,-3.3 2.7,-6 6,-6 h 29.438 c 3.3,0 6,2.7 6,6 v 18.77 z"
+ id="path6216" /><path
+ style="fill:none;stroke:#ffffff;stroke-width:3.50000000000000000;stroke-linejoin:round;stroke-opacity:1"
+ inkscape:connector-curvature="0"
+ d="m 48.143,36.983 c 0,3.3 -2.7,6 -6,6 H 12.705 c -3.3,0 -6,-2.7 -6,-6 v -18.77 c 0,-3.3 2.7,-6 6,-6 h 29.438 c 3.3,0 6,2.7 6,6 v 18.77 z"
+ id="path6218" /></g><path
+ style="fill:none;stroke:#ffffff;stroke-width:3.50000000000000000;stroke-linejoin:round;stroke-opacity:1"
+ inkscape:connector-curvature="0"
+ d="m 8.007,27.598 c 10.118,0 6.243,9.431 11.213,9.431 4.375,0 2.154,-19.154 6.279,-19.154 4.875,0 1.719,19.154 6.719,19.154 4.406,0 1.781,-11.529 5.156,-11.529 3.375,0 2,4.875 4.25,4.875 2.375,0 0.25,-3.375 5.75,-3.375"
+ id="path6220" /></g><text
+ xml:space="preserve"
+ style="font-size:44.88426970999999810px;font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#ffffff;font-family:gargi;-inkscape-font-specification:gargi Medium;stroke-opacity:1"
+ x="32.185669"
+ y="40.162285"
+ id="text3843"
+ sodipodi:linespacing="125%"
+ transform="scale(0.98760782,1.0125477)"><tspan
+ sodipodi:role="line"
+ id="tspan3845"
+ x="32.185669"
+ y="40.162285">2</tspan></text>
+</svg> \ No newline at end of file
diff --git a/readers.py b/readers.py
index 286b330..0b19b80 100644
--- a/readers.py
+++ b/readers.py
@@ -92,10 +92,11 @@ class StopWatchReader():
class MeasureReader():
- def __init__(self, file):
+ def __init__(self, file, channel):
"""Import chart data from file."""
self._reader = csv.reader(file)
+ self._channel = str(channel - 1)
def get_chart_data(self):
"""Return data suitable for pyCHA."""
@@ -108,7 +109,14 @@ class MeasureReader():
if count > 6:
label, value = row[0].split(": ")
- chart_data.append((label, float(value)))
+ split = label.split(".")
+
+ if len(split) > 1:
+ if split[1] == self._channel:
+ chart_data.append((split[0], float(value)))
+
+ elif len(split) < 1:
+ chart_data.append((split[0], float(value)))
return chart_data