Commit 331e4d67 authored by Srishti Sethi's avatar Srishti Sethi

Fourth Activity:Story of Louis Braille

parent 3d03663e
SUBDIRS =
pythondir = $(PYTHON_PLUGIN_DIR)
dist_python_DATA= louis_braille.py
xmldir = $(pkgdatadir)/@PACKAGE_DATA_DIR@
xml_in_files = \
louis_braille.xml.in
xml_DATA = $(xml_in_files:.xml.in=.xml)
# Do not use the INTLTOOL_XML_RULE, we don't need to embed the translations
# in the file themselves. GCompris pick the translations from the po file at
# runtime.
#
$(xml_DATA): %.xml: %.xml.in
sed -e "s/\(<\{1\}\/*\)_/\1/g" $< > $@
# Use this directive and instead of the one above to embed the translations
# in the xml files directly, this is needed for the tool gcompris2spip
#@INTLTOOL_XML_RULE@
icondir = $(pkgdatadir)/@PACKAGE_DATA_DIR@
icon_DATA = louis_braille.svg
EXTRA_DIST = $(icon_DATA) ${xml_in_files} init_path.sh
CLEANFILES = $(xml_DATA)
../boards/python/gcompris
\ No newline at end of file
# Set the different path for this activity
# This is sourced by runit.sh
path=$1
activity=louis_braille
plugindir=$path/../boards/.libs
pythonplugindir=$path/../braille_alphabets-activity:$path/../louis_braille-activity
resourcedir=$path/resources
section="/experimental"
# gcompris - louis_braille.py
#
# Copyright (C) 2003, 2008 Bruno Coudoin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# louis_braille activity.
import gtk
import gtk.gdk
import gcompris
import gcompris.utils
import gcompris.skin
import goocanvas
import pango
import ConfigParser
from BrailleChar import *
from gcompris import gcompris_gettext as _
COLOR_ON = 0X00FFFFL
COLOR_OFF= 0X00000000L
CIRCLE_FILL = "red"
CELL_WIDTH = 30
LOUIS_BRAILLE_NAME = ['L','O','U','I','S','B','R','A','I','L','L','E']
class Gcompris_louis_braille:
"""Empty gcompris python class"""
def __init__(self, gcomprisBoard):
# Save the gcomprisBoard, it defines everything we need
# to know from the core
self.gcomprisBoard = gcomprisBoard
self.gcomprisBoard.level=1
self.gcomprisBoard.sublevel=1
self.gcomprisBoard.number_of_sublevel=1
self.gcomprisBoard.maxlevel = 11
# Needed to get key_press
gcomprisBoard.disable_im_context = True
def start(self):
# Set the buttons we want in the bar
gcompris.bar_set (0)
gcompris.bar_location(gcompris.BOARD_WIDTH - 160, -1, 0.6)
# Set a background image
gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
"louis_braille/back.png")
# Create our rootitem. We put each canvas item in it so at the end we
# only have to kill it. The canvas deletes all the items it contains
# automaticaly.
self.rootitem = goocanvas.Group(parent =
self.gcomprisBoard.canvas.get_root_item())
#Previous Button
ok = goocanvas.Svg(parent = self.rootitem,
svg_handle = gcompris.skin.svg_get(),
svg_id = "#PREVIOUS",
tooltip = "Click to move to previous story page"
)
ok.translate(-300,50)
ok.connect("button_press_event", self.previous_event, self.gcomprisBoard.level)
gcompris.utils.item_focus_init(ok, None)
#Next Button
ok = goocanvas.Svg(parent = self.rootitem,
svg_handle = gcompris.skin.svg_get(),
svg_id = "#NEXT",
tooltip = "Click to move to next story page"
)
ok.translate(75,-58)
ok.connect("button_press_event", self.next_event, self.gcomprisBoard.level)
gcompris.utils.item_focus_init(ok, None)
#Display name of louis braille
for index in range(5):
BrailleChar(self.rootitem,(index+1) *(CELL_WIDTH + 20)+30,
20, 50, LOUIS_BRAILLE_NAME[index] ,COLOR_ON, COLOR_OFF,
CIRCLE_FILL, CIRCLE_FILL, True,False ,False, None)
for index in range(5,12):
BrailleChar(self.rootitem,(index+1) *(CELL_WIDTH + 20)+65,
20, 50, LOUIS_BRAILLE_NAME[index] ,COLOR_ON, COLOR_OFF,
CIRCLE_FILL, CIRCLE_FILL,True,False ,False, None)
self.read_data()
self.display_game(self.gcomprisBoard.level)
def read_data(self):
'''Load the activity data'''
config = ConfigParser.RawConfigParser()
p = gcompris.get_properties()
filename = gcompris.DATA_DIR + '/' + self.gcomprisBoard.name + '/activity.desktop'
try:
gotit = config.read(filename)
if not gotit:
gcompris.utils.dialog(_("Cannot find the file '{filename}'").format(filename=filename),None)
return False
except ConfigParser.Error as error:
gcompris.utils.dialog(_("Failed to parse data set '{filename}' with error:\n{error}").
format(filename=filename, error=error), None)
return False
self.dataset = config
return True
def display_game(self, level):
#Checking for newline in activity.desktop
story = self.dataset.get(str(level),"story")
story = story.replace("\\n", "\n")
#Displaying the YEAR
goocanvas.Text(parent = self.rootitem,
x=420.0,
y=410.0,
text=str(self.dataset.get(str(level),"year")),
fill_color="black",
anchor = gtk.ANCHOR_CENTER,
alignment = pango.ALIGN_CENTER,
font = 'SANS 17'
)
#Displaying the STORY
goocanvas.Text(parent = self.rootitem,
x=440.0,
y=450.0,
text=str(story),
fill_color="black",
anchor = gtk.ANCHOR_CENTER,
alignment = pango.ALIGN_CENTER,
font = 'SANS 17'
)
#Displaying the IMAGE
goocanvas.Image(parent = self.rootitem,
pixbuf = gcompris.utils.load_pixmap
(str(self.dataset.get(str(level),"image"))),
x = 300,
y = 120,
)
def previous_event(self, event, target,item, level):
if (self.gcomprisBoard.level == 1):
self.gcomprisBoard.level = self.gcomprisBoard.maxlevel
else :
self.gcomprisBoard.level = level - 1
self.end()
self.start()
def next_event(self, event, target, item, level):
if (self.gcomprisBoard.level == self.gcomprisBoard.maxlevel):
self.gcomprisBoard.level = 1
else :
self.gcomprisBoard.level = level + 1
self.end()
self.start()
def end(self):
# Remove the root item removes all the others inside it
self.rootitem.remove()
def ok(self):
print("louis_braille ok.")
def repeat(self):
print("louis_braille repeat.")
def config(self):
print("louis_braille config.")
def key_press(self, keyval, commit_str, preedit_str):
utf8char = gtk.gdk.keyval_to_unicode(keyval)
strn = u'%c' % utf8char
print("Gcompris_louis_braille key press keyval=%i %s" % (keyval, strn))
def pause(self, pause):
print("louis_braille pause. %i" % pause)
def set_level(self, level):
print("louis_braille set level. %i" % level)
\ No newline at end of file
<?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="100"
height="100"
id="svg40739"
sodipodi:version="0.32"
inkscape:version="0.47 r22583"
version="1.0"
sodipodi:docname="python.svg">
<defs
id="defs40741">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 50 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="100 : 50 : 1"
inkscape:persp3d-origin="50 : 33.333333 : 1"
id="perspective22" />
<linearGradient
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255"
gradientTransform="matrix(0.275436,0,0,0.275436,-9.036391,-24.94534)"
gradientUnits="userSpaceOnUse"
id="linearGradient2149"
xlink:href="#linearGradient3195"
inkscape:collect="always" />
<radialGradient
r="109.16138"
fy="191.79465"
fx="191.85158"
cy="191.79465"
cx="191.85158"
gradientTransform="matrix(-0.05310125,0.872689,-0.600768,-0.03655593,224.2399,-59.43464)"
gradientUnits="userSpaceOnUse"
id="radialGradient2142"
xlink:href="#linearGradient2209"
inkscape:collect="always" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,224.2399,-59.43464)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2209"
id="radialGradient2502"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,-9.036391,-24.94534)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2499"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,-9.036391,-24.94534)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2492"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,224.2399,-59.43464)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2209"
id="radialGradient2490"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,411.631,-21.7361)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2028"
id="radialGradient2460"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,178.3546,12.7532)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2457"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,364.8811,-32.15133)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2454"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<linearGradient
id="linearGradient2164">
<stop
id="stop2166"
offset="0"
style="stop-color:#05fa4a;stop-opacity:1" />
<stop
id="stop2168"
offset="1"
style="stop-color:#21fa4a;stop-opacity:0" />
</linearGradient>
<linearGradient
id="linearGradient2170">
<stop
id="stop2172"
offset="0"
style="stop-color:white;stop-opacity:0.37440759" />
<stop
id="stop2174"
offset="1"
style="stop-color:white;stop-opacity:0" />
</linearGradient>
<linearGradient
id="linearGradient2182">
<stop
id="stop2184"
offset="0"
style="stop-color:#89b0f1;stop-opacity:1" />
<stop
id="stop2186"
offset="1"
style="stop-color:#89b0f1;stop-opacity:0" />
</linearGradient>
<linearGradient
id="linearGradient2188">
<stop
id="stop2190"
offset="0"
style="stop-color:white;stop-opacity:1" />
<stop
id="stop2192"
offset="1"
style="stop-color:white;stop-opacity:0" />
</linearGradient>
<linearGradient
id="linearGradient2194">
<stop
id="stop2196"
offset="0"
style="stop-color:#faed21;stop-opacity:1" />
<stop
id="stop2198"
offset="1"
style="stop-color:#faed21;stop-opacity:0" />
</linearGradient>
<radialGradient
gradientTransform="matrix(0.650783,-3.06516e-2,2.791861e-2,0.592758,124.1873,214.4504)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient8440"
id="radialGradient2200"
fy="551.19287"
fx="410.15085"
r="197.44826"
cy="551.19287"
cx="410.15085" />
<linearGradient
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient10241"
id="linearGradient2202"
y2="300.84381"
x2="871.53973"
y1="566.73724"
x1="56.840466" />
<linearGradient
gradientTransform="translate(-723.2674,480.0855)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient10241"
id="linearGradient2204"
y2="300.84381"
x2="871.53973"
y1="566.73724"
x1="56.840466" />
<radialGradient
gradientTransform="matrix(0.650783,-3.06516e-2,2.791861e-2,0.592758,338.933,901.3419)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient8440"
id="radialGradient2206"
fy="551.19287"
fx="410.15085"
r="197.44826"
cy="551.19287"
cx="410.15085" />
<radialGradient
gradientTransform="matrix(0.628232,8.120038e-4,-8.375586e-4,0.64804,-113.341,354.6752)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient15608"
id="radialGradient2208"
fy="1036.5964"
fx="-330.87396"
r="197.44826"
cy="1036.5964"
cx="-330.87396" />
<radialGradient
gradientTransform="matrix(0.628232,8.120038e-4,-8.375586e-4,0.64804,-113.341,354.6752)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient15608"
id="radialGradient2210"
fy="1036.5964"
fx="-330.87396"
r="197.44826"
cy="1036.5964"
cx="-330.87396" />
<linearGradient
gradientTransform="translate(-723.2674,480.0855)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient10241"
id="linearGradient2212"
y2="300.84381"
x2="871.53973"
y1="566.73724"
x1="56.840466" />
<radialGradient
gradientTransform="matrix(0.628232,8.120038e-4,-8.375586e-4,0.64804,-113.341,354.6752)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient15608"
id="radialGradient2214"
fy="1036.5964"
fx="-330.87396"
r="197.44826"
cy="1036.5964"
cx="-330.87396" />
<linearGradient
gradientTransform="translate(-723.2674,480.0855)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient10241"
id="linearGradient2216"
y2="300.84381"
x2="871.53973"
y1="566.73724"
x1="56.840466" />
<linearGradient
gradientTransform="matrix(0.550543,0,0,0.550543,-18.1832,263.505)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient10241"
id="linearGradient2218"
y2="300.84381"
x2="871.53973"
y1="566.73724"
x1="56.840466" />
<radialGradient
gradientTransform="matrix(0.345869,4.47043e-4,-4.61112e-4,0.356774,594.4075,251.9103)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient15608"
id="radialGradient2220"
fy="1036.5964"
fx="-330.87396"
r="197.44826"
cy="1036.5964"
cx="-330.87396" />
<radialGradient
gradientTransform="matrix(0.628232,8.120038e-4,-8.375586e-4,0.64804,-113.341,354.6752)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient15608"
id="radialGradient2223"
fy="1036.5964"
fx="-330.87396"
r="197.44826"
cy="1036.5964"
cx="-330.87396" />
<linearGradient
gradientTransform="translate(-723.2674,480.0855)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient10241"
id="linearGradient2225"
y2="300.84381"
x2="871.53973"
y1="566.73724"
x1="56.840466" />
<linearGradient
gradientTransform="matrix(0.552861,0,0,0.552861,-8.679351,-52.47802)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2227"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<radialGradient
gradientTransform="matrix(-0.106586,1.75168,-1.205874,-7.337587e-2,459.558,-121.7057)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2209"
id="radialGradient2229"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<radialGradient
gradientTransform="matrix(-0.106586,1.75168,-1.205874,-7.337587e-2,459.558,-121.7057)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2209"
id="radialGradient2231"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<linearGradient
gradientTransform="matrix(0.552861,0,0,0.552861,-8.679351,-52.47802)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2233"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<linearGradient
gradientTransform="matrix(0.137222,0,0,0.137222,241.0501,5.28093)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2235"
y2="669.45007"
x2="306.77817"
y1="97.694176"
x1="369.43671" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,196.1709,-0.751182)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2237"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,429.4473,-35.24048)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient15608"
id="radialGradient2239"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,366.1663,-0.751182)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2241"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,599.4427,-35.24048)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient8440"
id="radialGradient2243"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,534.9284,-0.751182)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2245"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,768.2048,-35.24048)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2028"
id="radialGradient2247"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,768.2048,-35.24048)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2028"
id="radialGradient2249"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,534.9284,-0.751182)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2251"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,768.2048,-35.24048)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2028"
id="radialGradient2274"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,534.9284,-0.751182)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2276"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,534.9284,-0.751182)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2263"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,768.2048,-35.24048)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient2028"
id="radialGradient2261"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />
<linearGradient
gradientTransform="matrix(0.275436,0,0,0.275436,366.1663,-0.751182)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3195"
id="linearGradient2259"
y2="593.93323"
x2="324.75836"
y1="230.74762"
x1="355.05255" />
<radialGradient
gradientTransform="matrix(-5.310125e-2,0.872689,-0.600768,-3.655593e-2,599.4427,-35.24048)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient8440"
id="radialGradient2257"
fy="191.79465"
fx="191.85158"
r="109.16138"
cy="191.79465"
cx="191.85158" />