[gcompris/gcomprismusic] added load song feature
- From: Karthik Subramanian <karthiks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprismusic] added load song feature
- Date: Thu, 7 Jul 2011 14:28:16 +0000 (UTC)
commit 930a65b4e76bbfe497626c48f6dda6aceb99a2d3
Author: Karthik Subramanian <itskarthik s gmail com>
Date: Thu Jul 7 19:57:20 2011 +0530
added load song feature
src/piano-activity/piano.py | 62 ++++-
src/piano-activity/resources/piano/loadicon.svg | 306 +++++++++++++++++++++++
2 files changed, 362 insertions(+), 6 deletions(-)
---
diff --git a/src/piano-activity/piano.py b/src/piano-activity/piano.py
index 134c154..b5b71a9 100644
--- a/src/piano-activity/piano.py
+++ b/src/piano-activity/piano.py
@@ -26,6 +26,7 @@ import gcompris.sound
import goocanvas
import ConfigParser
import pango
+import time
from gcompris import gcompris_gettext as _
@@ -45,6 +46,7 @@ class Gcompris_piano:
gcomprisBoard.disable_im_context = True
self.save = False
+
#Open the config file
def read_data(self):
'''Load the activity data'''
@@ -186,6 +188,18 @@ class Gcompris_piano:
)
gcompris.utils.item_focus_init(self.saveicon, None)
+ self.loadicon = goocanvas.Image(
+ parent = self.rootitem,
+ x = 650,
+ y = 270,
+ width = 60,
+ height = 60,
+ pixbuf = gcompris.utils.load_pixmap("piano/loadicon.svg")
+ )
+ gcompris.utils.item_focus_init(self.loadicon, None)
+
+
+
self.labelicon = goocanvas.Image(
parent = self.rootitem,
x = 650,
@@ -208,9 +222,10 @@ class Gcompris_piano:
)
- self.saveicon.connect("button-press-event", self.savenotes)
- self.labelicon.connect("button-press-event",self.showlabel)
-
+ self.saveicon.connect("button-press-event", self.save_notes)
+ self.labelicon.connect("button-press-event", self.show_label)
+ self.loadicon.connect("button-press-event", self.load_file)
+
svghandle1 = gcompris.utils.load_svg("piano/pianobg2.svg")
svghandle2 = gcompris.utils.load_svg("piano/pianobg3.svg")
@@ -235,7 +250,7 @@ class Gcompris_piano:
)
self.pianobg2.translate(375, 200)
- def showlabel (self, item, event, attr):
+ def show_label (self, item, event, attr):
if self.labelflag == 0:
self.pianolabel.props.visibility = goocanvas.ITEM_VISIBLE
self.labelflag = 1
@@ -243,7 +258,7 @@ class Gcompris_piano:
self.pianolabel.props.visibility = goocanvas.ITEM_INVISIBLE
self.labelflag = 0
- def savenotes(self, item, event, attr):
+ def save_notes(self, item, event, attr):
if self.save == False :
self.save = True
gcompris.file_selector_save( self.gcomprisBoard, self.selector_section,
@@ -258,11 +273,46 @@ class Gcompris_piano:
self.notesfile.close()
self.savestatus.props.text = ""
self.save = False
+
+ def load_file(self, item, event, attr):
+ gcompris.file_selector_load( self.gcomprisBoard, self.selector_section,
+ self.file_type,
+ general_load, self)
-
def piano_to_file(self, filename):
self.notesfile = open(filename, 'wb')
+ def file_to_piano(self, filename):
+ print filename+" opening..."
+ file = open(filename, 'rb')
+ try:
+ notes = file.read()
+ print notes
+ notesarray = notes.split(' ')
+ gcompris.sound.policy_set(gcompris.sound.PLAY_AFTER_CURRENT)
+ for ch in notesarray :
+ # if ch in self.allowed1:
+ self.play_file(ch, self.pianobg1)
+ # elif ch in self.allowed and len(self.allowed)>13:
+ # self.play_file(ch, self.pianobg2)
+ gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)
+ except:
+ file.close()
+ print 'Cannot load ' , filename , "as GCompris Piano"
+ return
+
+ def play_file(self, notename, pianobg):
+ fname = 'piano/'+notename+'.wav'
+ print '#'+notename
+ print fname
+ self.pianobg1.props.visibility = goocanvas.ITEM_INVISIBLE
+ self.pianobg2.props.visibility = goocanvas.ITEM_INVISIBLE
+ pianobg.props.svg_id = '#' + notename
+ pianobg.props.visibility = goocanvas.ITEM_VISIBLE
+ print ("playing %s" % (notename))
+ gcompris.sound.play_ogg(fname)
+
+
def end(self):
print "piano end"
if self.save is True:
diff --git a/src/piano-activity/resources/piano/loadicon.svg b/src/piano-activity/resources/piano/loadicon.svg
new file mode 100644
index 0000000..18becaf
--- /dev/null
+++ b/src/piano-activity/resources/piano/loadicon.svg
@@ -0,0 +1,306 @@
+<?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"
+ width="193.89853"
+ height="175.7117"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="Open.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.0"
+ inkscape:export-filename="C:\Users\Joshua\Documents\Visual Studio 2005\Projects\Flash-cards_share_code\Flash-Cards Wpf\Flash-Cards Wpf\Svg Package\Open.png"
+ inkscape:export-xdpi="51.257099"
+ inkscape:export-ydpi="51.257099">
+ <defs
+ id="defs4">
+ <linearGradient
+ id="linearGradient3229">
+ <stop
+ style="stop-color:#ffec67;stop-opacity:0.64285713;"
+ offset="0"
+ id="stop3231" />
+ <stop
+ style="stop-color:#f2b300;stop-opacity:1;"
+ offset="1"
+ id="stop3233" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3223">
+ <stop
+ id="stop3225"
+ offset="0"
+ style="stop-color:#ffec67;stop-opacity:0.64285713;" />
+ <stop
+ id="stop3227"
+ offset="1"
+ style="stop-color:#f2b300;stop-opacity:1;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3217">
+ <stop
+ style="stop-color:#ffec67;stop-opacity:0.64285713;"
+ offset="0"
+ id="stop3219" />
+ <stop
+ style="stop-color:#f2b300;stop-opacity:1;"
+ offset="1"
+ id="stop3221" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3211">
+ <stop
+ id="stop3213"
+ offset="0"
+ style="stop-color:#ffec67;stop-opacity:0.64285713;" />
+ <stop
+ id="stop3215"
+ offset="1"
+ style="stop-color:#f2b300;stop-opacity:1;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3205">
+ <stop
+ style="stop-color:#ffec67;stop-opacity:0.64285713;"
+ offset="0"
+ id="stop3207" />
+ <stop
+ style="stop-color:#f2b300;stop-opacity:1;"
+ offset="1"
+ id="stop3209" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3199">
+ <stop
+ id="stop3201"
+ offset="0"
+ style="stop-color:#ffec67;stop-opacity:0.64285713;" />
+ <stop
+ id="stop3203"
+ offset="1"
+ style="stop-color:#f2b300;stop-opacity:1;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3193">
+ <stop
+ style="stop-color:#ffec67;stop-opacity:0.64285713;"
+ offset="0"
+ id="stop3195" />
+ <stop
+ style="stop-color:#f2b300;stop-opacity:1;"
+ offset="1"
+ id="stop3197" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3187">
+ <stop
+ id="stop3189"
+ offset="0"
+ style="stop-color:#ffec67;stop-opacity:0.64285713;" />
+ <stop
+ id="stop3191"
+ offset="1"
+ style="stop-color:#f2b300;stop-opacity:1;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3181">
+ <stop
+ style="stop-color:#ffec67;stop-opacity:0.64285713;"
+ offset="0"
+ id="stop3183" />
+ <stop
+ style="stop-color:#f2b300;stop-opacity:1;"
+ offset="1"
+ id="stop3185" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3173">
+ <stop
+ id="stop3177"
+ offset="0"
+ style="stop-color:#ffec67;stop-opacity:0.64285713;" />
+ <stop
+ id="stop3179"
+ offset="1"
+ style="stop-color:#f2b300;stop-opacity:1;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3170">
+ <stop
+ style="stop-color:#ffec67;stop-opacity:0.64285713;"
+ offset="0"
+ id="stop3172" />
+ <stop
+ style="stop-color:#f2b300;stop-opacity:1;"
+ offset="1"
+ id="stop3175" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3210">
+ <stop
+ id="stop3212"
+ offset="0"
+ style="stop-color:#ffec67;stop-opacity:0.64285713;" />
+ <stop
+ id="stop3214"
+ offset="1"
+ style="stop-color:#f2b300;stop-opacity:1;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3202">
+ <stop
+ id="stop3204"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1;" />
+ <stop
+ id="stop3206"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:1;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3192">
+ <stop
+ style="stop-color:#ffec67;stop-opacity:1;"
+ offset="0"
+ id="stop3200" />
+ <stop
+ style="stop-color:#f29100;stop-opacity:1;"
+ offset="1"
+ id="stop3198" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3172">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop3174" />
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="1"
+ id="stop3176" />
+ </linearGradient>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective2390"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3172"
+ id="linearGradient3178"
+ x1="128.81982"
+ y1="663.45343"
+ x2="322.71835"
+ y2="663.45343"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3192"
+ id="linearGradient3190"
+ x1="138.92136"
+ y1="604.86456"
+ x2="243.92645"
+ y2="715.98138"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3223"
+ id="linearGradient3208"
+ gradientUnits="userSpaceOnUse"
+ x1="304.58636"
+ y1="625.06763"
+ x2="153.01273"
+ y2="735.65399" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.49497475"
+ inkscape:cx="74.445738"
+ inkscape:cy="60.072143"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="644"
+ inkscape:window-height="898"
+ inkscape:window-x="606"
+ inkscape:window-y="-15" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-128.81982,-559.94227)">
+ <path
+ style="fill:url(#linearGradient3190);fill-opacity:1;fill-rule:evenodd;stroke:#9a7b08;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 148.55554,733.0277 L 131.31982,594.76307 L 188.89852,593.75292 L 192.93913,600.82399 L 247.48736,600.82399 L 281.83255,707.90015"
+ id="path2396"
+ sodipodi:nodetypes="cccccc" />
+ <path
+ style="fill:url(#linearGradient3208);fill-opacity:1.0;fill-rule:evenodd;stroke:#9a7b08;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 149.97607,730.21821 L 282.84271,707.90016 L 320.21835,609.91536 L 194.95943,615.97627 L 149.97607,730.21821 z"
+ id="path3182"
+ sodipodi:nodetypes="ccccc" />
+ <g
+ id="g3225"
+ transform="matrix(0.5093953,0.1452112,-0.1452112,0.5093953,288.20808,338.14773)">
+ <path
+ sodipodi:nodetypes="css"
+ id="path3216"
+ d="M 20.863832,471.73026 C 18.800485,451.74267 29.101333,431.53079 47.646197,426.74354 C 60.298006,423.47755 83.819978,422.91646 96.729346,457.19858"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:9.4395113;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.39215686" />
+ <path
+ transform="matrix(-0.4666609,0.180522,-0.180522,-0.4666609,188.6528,618.74379)"
+ d="M 99.51696,367.5816 L 18.340187,367.5816 L 58.928574,297.28046 L 99.51696,367.5816 z"
+ inkscape:randomized="0"
+ inkscape:rounded="0"
+ inkscape:flatsided="true"
+ sodipodi:arg2="1.5707963"
+ sodipodi:arg1="0.52359878"
+ sodipodi:r2="23.433716"
+ sodipodi:r1="46.867432"
+ sodipodi:cy="344.14789"
+ sodipodi:cx="58.928574"
+ sodipodi:sides="3"
+ id="path3220"
+ style="opacity:1;fill:#000000;fill-opacity:0.39215686;fill-rule:evenodd;stroke:none;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="star" />
+ </g>
+ </g>
+</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]