[gcompris/gcomprisbraille] Added Repeat Icon|GOAL|braille tutor|integration with BrailleChar module



commit b4ffe3aa872ff1713a7fbb7ea9a5269657c815f4
Author: Srishti Sethi <srishakatux gmail com>
Date:   Mon Jun 6 15:19:16 2011 +0530

    Added Repeat Icon|GOAL|braille tutor|integration with BrailleChar module

 src/braille_alphabets-activity/BrailleChar.py      |  151 +++++++++++
 .../braille_alphabets.py                           |  271 +++++++++++++++++++-
 src/braille_alphabets-activity/resources/back.png  |  Bin 0 -> 1573 bytes
 .../resources/braille_tux.svgz                     |  Bin 0 -> 14786 bytes
 .../resources/mosaic.svgz                          |  Bin 0 -> 4491 bytes
 .../resources/target.svg                           |  148 +++++++++++
 6 files changed, 569 insertions(+), 1 deletions(-)
---
diff --git a/src/braille_alphabets-activity/BrailleChar.py b/src/braille_alphabets-activity/BrailleChar.py
new file mode 100644
index 0000000..f963e17
--- /dev/null
+++ b/src/braille_alphabets-activity/BrailleChar.py
@@ -0,0 +1,151 @@
+#  gcompris - BrailleChar.py
+#
+# Copyright (C) 2011 xxxx
+#
+#   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/>.
+#
+# This class display a braille char to a given location
+# The char may be static of dynamic. It maintains the value
+# of the dots and the char it represents in real time.
+#
+import gtk
+import gtk.gdk
+import gcompris
+import gcompris.utils
+import gcompris.skin
+import goocanvas
+import pango
+import gcompris.sound
+import string
+from gcompris import gcompris_gettext as _
+
+BRAILLE_LETTERS = {
+    "A": [1], "B": [1, 2], "C": [1, 4], "D": [1, 4, 5], "E": [1, 5],
+    "F": [1, 2, 4], "G": [1, 2, 4, 5], "H": [1, 2, 5], "I": [2, 4],
+    "J": [2, 4, 5], "K": [1, 3], "L": [1, 2, 3], "M": [1, 3, 4],
+    "N": [1, 3, 4, 5], "O": [1, 3, 5], "P": [1, 2, 3, 4], "Q": [1, 2, 3, 4, 5],
+    "R": [1, 2, 3, 5], "S": [2, 3, 4], "T": [2, 3, 4, 5], "U": [1, 3, 6],
+    "V": [1, 2, 3, 6], "W": [2, 4, 5, 6], "X": [1, 3, 4, 6], "Y": [1, 3, 4, 5, 6],
+    "Z": [1, 3, 5, 6], 1: [2],2 :[2,3], 3 : [2,5], 4: [2,5,6],5 : [2,6],
+    6 : [2,3,5],7 : [2,3,5,6],8 : [2,3,6], 9 : [3,5],0 :[3,5,6]
+}
+
+DOT_ON  = 0xFF0000FFL
+DOT_OFF = 0x00000000L
+
+class BrailleChar:
+  """Braille Char"""
+  def __init__(self, rootitem,
+               x, y, width, letter,
+               display_letter, clickable,
+               callback):
+
+    self.letter = letter
+    self.callback = callback
+    self.display_letter = display_letter
+    self.clickable = clickable
+
+    height = width * 1.33
+    cell_radius = (width / 7.5)
+    self.rootitem = goocanvas.Group(parent=rootitem)
+    if(letter == ''):
+        """no rect"""
+    else :
+        self.item = goocanvas.Rect(parent=self.rootitem,
+                          x=x,
+                          y=y,
+                          width=width,
+                          height=height,
+                          stroke_color="blue",
+                          fill_color="#DfDfDf",
+                          line_width=2.0)
+
+
+    self.text = goocanvas.Text(parent=self.rootitem,
+                               x=x + (width / 2.0),
+                               y=y + height + 15,
+                               text=str(letter),
+                               fill_color="blue",
+                               alignment=pango.ALIGN_CENTER,
+                               anchor = gtk.ANCHOR_CENTER,
+                               font = 'Sans BOLD')
+    if not display_letter:
+        self.text.props.visibility = goocanvas.ITEM_INVISIBLE
+
+    dot = 1
+    self.dot_items = []
+    for u in range(2):
+        for v in range(3):
+            cell = goocanvas.Ellipse(parent=self.rootitem,
+                                     center_x=x + width / 3.0 * ( u + 1 ),
+                                     center_y=y + height / 4.0 * ( v + 1 ),
+                                     radius_x=cell_radius,
+                                     radius_y=cell_radius,
+                                     stroke_color="blue",
+                                     fill_color="#DfDfDf",
+                                     line_width=width/25)
+            # To fill the circles in lower board with red color
+            if (clickable == True):
+                cell.connect("button_press_event", self.dot_event)
+                gcompris.utils.item_focus_init(cell, None)
+
+            if isinstance(letter,int):
+                fillings = BRAILLE_LETTERS.get(letter)
+            else :
+                fillings = BRAILLE_LETTERS.get(letter.upper())
+
+            if fillings == None:
+                """only braille cell"""
+            elif dot in fillings:
+                cell.set_property("fill_color_rgba", DOT_ON)
+            else :
+                cell.set_property("fill_color_rgba", DOT_OFF)
+
+            self.dot_items.append(cell)
+            dot += 1
+
+  def get_letter(self):
+      """Return the letter represented by this braille item"""
+      return self.letter
+
+  def calculate_char(self):
+      """Calculate the represented char"""
+      cells = []
+
+      # Create the dot list
+      for l in range(6):
+          if(self.dot_items[l].get_property("fill_color_rgba") == DOT_ON):
+              cells.append(l+1)
+
+      self.letter = ''
+      for k,v in BRAILLE_LETTERS.items():
+          if v == cells:
+              self.letter = k
+
+      if isinstance(self.letter,int):
+          self.text.set_property("text",self.letter)
+      else :
+          self.text.set_property("text", str.upper(self.letter))
+
+      if self.callback:
+          self.callback(self.letter)
+
+
+  def dot_event(self, event, target, item):
+      """A dot has been clicked, change its state and calculate our new letter value"""
+      if target.get_property("fill_color_rgba") == DOT_ON:
+          target.set_property("fill_color_rgba", DOT_OFF)
+      else:
+          target.set_property("fill_color_rgba", DOT_ON)
+      self.calculate_char()
\ No newline at end of file
diff --git a/src/braille_alphabets-activity/braille_alphabets.py b/src/braille_alphabets-activity/braille_alphabets.py
index a93c333..e61ea05 100644
--- a/src/braille_alphabets-activity/braille_alphabets.py
+++ b/src/braille_alphabets-activity/braille_alphabets.py
@@ -1 +1,270 @@
-#  gcompris - braille_alphabets.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/>.## braille_alphabets activity.import gtkimport gtk.gdkimport gcomprisimport gcompris.utilsimport gcompris.skinimport goocanvasimport pangoimport gcompris.soundimport stringfrom gcompris import gcompris_gettext as _braille_letters = {    "a": 
 [1], "b": [1, 2], "c": [1, 4], "d": [1, 4, 5], "e": [1, 5],    "f": [1, 2, 4], "g": [1, 2, 4, 5], "h": [1, 2, 5], "i": [2, 4],    "j": [2, 4, 5], "k": [1, 3], "l": [1, 2, 3], "m": [1, 3, 4],    "n": [1, 3, 4, 5], "o": [1, 3, 5], "p": [1, 2, 3, 4], "q": [1, 2, 3, 4, 5],    "r": [1, 2, 3, 5], "s": [2, 3, 4], "t": [2, 3, 4, 5], "u": [1, 3, 6],    "v": [1, 2, 3, 6], "w": [2, 4, 5, 6], "x": [1, 3, 4, 6], "y": [1, 3, 4, 5, 6],    "z": [1, 3, 5, 6],}cell_width = 40x1 = 190y1 = 150red_fill = 4278190335class Gcompris_braille_alphabets:  """Empty gcompris python class"""  def __init__(self, gcomprisBoard):    # Save the gcomprisBoard, it defines everything we need    # to know from the core    #defining the number of levels in activity    self.gcomprisBoard = gcomprisBoard    self.gcomprisBoard.level = 1    self.gcomprisBoard.maxlevel=2    self.gcomprisBoard.sublevel=1    self.gcomprisBoard.number_of_sublevel=1    # Needed to get key_press    gcomprisBoard
 .disable_im_context = True  def start(self):    # Set the buttons we want in the bar    gcompris.bar_set_level(self.gcomprisBoard)    gcompris.bar_set(gcompris.BAR_LEVEL)    # Set a background image    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),                            "mosaic_bg.svgz")    # 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())    self.display_game()  def end(self):    # Remove the root item removes all the others inside it    self.rootitem.remove()  def ok(self):    print("learnbraille ok.")  def repeat(self):    print("learnbraille repeat.")  def config(self):    print("learnbraille config.")  def key_press(self, keyval, commit_str, preedit_str):    utf8char = gtk.gdk.keyva
 l_to_unicode(keyval)    strn = u'%c' % utf8char    print("Gcompris_learnbraille key press keyval=%i %s" % (keyval, strn))  def pause(self, pause):    print("learnbraille pause. %i" % pause)  def set_level(self, level):    gcompris.sound.play_ogg("sounds/receive.wav")    self.gcomprisBoard.level = level    self.gcomprisBoard.sublevel = 1    gcompris.bar_set_level(self.gcomprisBoard)    print("braille_alphabets set level. %i" % self.gcomprisBoard.level)    self.increment_level()  def increment_level(self):    gcompris.sound.play_ogg("sounds/bleep.wav")    self.end()    self.start()  def display_game(self):    goocanvas.Text(parent=self.rootitem, x=390.0, y=70.0, text=_("Alphabet"),                   width=500, height=500, fill_color="blue",                   anchor=gtk.ANCHOR_CENTER, font='BOLD')    """call braille cell"""    self.braille_cell()    self.board_lower(self.gcomprisBoard.level)    """Call lower board 1 or 2"""  def board_lower(sel
 f,level):    if(level ==1):        self.board_lower1()    elif(level == 2) :        self.board_lower2()  def board_lower1(self):      for i, letter in enumerate(string.ascii_uppercase[:13]):          tile = self.braille_tile(letter, cell_width, i)  def braille_tile(self, letter, cell_width, index_x):        padding = cell_width * 0.21        cell_size = cell_width / 2 - padding        inner_padding = cell_width * 0.08        cell_radius = cell_size - inner_padding * 2        item = goocanvas.Rect(parent=self.rootitem,                                   x=index_x * (cell_width + 10) + 60,                                    y=350, width=40,                                    height=60,                                    stroke_color="blue",                                    fill_color="#DfDfDf",                                    line_width=2.0)        item.connect("button_press_event", self.braille_char, x1, y1, letter, True, True)        gcompri
 s.utils.item_focus_init(item, None)        goocanvas.Text(parent=self.rootitem, x=(index_x * (cell_width + 10) + 60) + 10,                        y=425, text=str(letter),                        fill_color="blue",                         font='BOLD')        cells = []        for u in range(2):            for v in range(3):                cell = goocanvas.Ellipse(parent=self.rootitem,                                          center_x=index_x * 50 + u * 20 + 70,                                          center_y=v * 15 + 365,                                          radius_x=cell_radius,                                          radius_y=cell_radius,                                          stroke_color="blue",                                           line_width=2.0)                #keep a separate track so we don't mix up with other cells                cells.append(cell)        #To fill the circles in lower board with red color        fillings = braille_le
 tters.get(letter.lower())        for index_x in range(6):            cells[index_x].connect("button_press_event", self.braille_char, x1, y1, letter, True, True)            gcompris.utils.item_focus_init(cells[index_x], item)            if(index_x + 1) in fillings:                cells[index_x].set_property("fill_color", "red")            else :                cells[index_x].set_property("fill_color", "#DfDfDf")  def braille_char(self, event, target, item, a, b, letter, clickable, displayable):      """Checking the booleans to evaluate if text is to displayed & if its clickable"""      if(displayable == True):          #load an image in alphabet area before displaying text          goocanvas.Image(parent=self.rootitem,                          pixbuf=gcompris.utils.load_pixmap("drawing.svg"),                          x=100,                          y=80,                          width=200,                          height=200)          text1 = goocanvas.Tex
 t(parent=self.rootitem,          x=a,          y=b,          fill_color="blue",          font="Sans 78",          anchor=gtk.ANCHOR_CENTER,          text=str(letter))      if(clickable == True):          text1.connect("button_press_event", self.display_letter, letter)          gcompris.utils.item_focus_init(text1, None)  def display_letter(self, item, event, target, letter):      #To fill the points in braille cell area      self.fillings = braille_letters.get(letter.lower())      for i in range(6):            if(i + 1) in self.fillings:                self.c[i].set_property("fill_color", "red")            else :                self.c[i].set_property("fill_color", "#DfDfDf")  def board_lower2(self):      for i, letter in enumerate(string.ascii_uppercase[13:]):          tile = self.braille_tile(letter, cell_width, i)  """Braille Cell function to represent the dots & braille code"""  def braille_cell(self):      #Braille Cell Array      self.c = []
       goocanvas.Text(parent=self.rootitem,                      x=540.0, y=70.0,                     text=_("Braille Cell"),                     fill_color="blue",                     font='BOLD')      for i in range(2):          for j in range(3):                  goocanvas.Text(parent=self.rootitem,                                 text=(str(j + 1 + i * 3)),                                 font='Sans 30',                                 fill_color="blue",                                 x=i * 140 + 510,                                 y=j * 50 + 100)                  cell1 = goocanvas.Ellipse(parent=self.rootitem,                                            center_x=i * 50 + 570,                                            center_y=j * 50 + 120,                                            radius_x=20, radius_y=20,                                            stroke_color="blue",                                            fill_color="#DfDfDf",                 
                            line_width=5.0)                  #to ensure that cells do not mess up & append                  #them to array                  self.c.append(cell1)      #To make the points clickable in braille cell area      for index in range(6):          self.c[index].connect("button_press_event",self.change_color,index)          gcompris.utils.item_focus_init(self.c[index],None)  """function being called on click of a point"""  def change_color(self,item,event,target,incr):      self.cell = []      #set the property of point to transparent if it is red      if(self.c[incr].get_property("fill_color_rgba") == red_fill):          self.c[incr].set_property("fill_color","#DfDfDf")          self.click_display(item,target,event)      else :          #set the property of point to red if it is transparent          self.c[incr].set_property("fill_color","red")          self.click_display(item,target,event)  """Appends the point clicked in an array
 """  def click_display(self,item,target,event):      for l in range(6):          if(self.c[l].get_property("fill_color_rgba") == red_fill):              self.cell.append(l+1)      if(self.gcomprisBoard.level == 1):          for k,v in braille_letters.items()[:13]:              if v == self.cell:                  self.braille_char(item,target,event,x1,y1,string.upper(k),False,True)      elif(self.gcomprisBoard.level == 2):          for k,v in braille_letters.items()[13:]:              if v == self.cell:                  self.braille_char(item,target,event,x1,y1,string.upper(k),False,True)
\ No newline at end of file
+#  gcompris - braille_alphabets.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/>.
+#
+# braille_alphabets activity.
+import gtk
+import gtk.gdk
+import gcompris
+import gcompris.utils
+import gcompris.skin
+import gcompris.bonus
+import goocanvas
+import pango
+import gcompris.sound
+import string
+import random
+from gcompris import gcompris_gettext as _
+from BrailleChar import *
+
+cell_width = 40
+braille_desc = {'intro' : "A system of writing for the blinds that \n"
+                "uses characters made of raised dots. \n\n"
+                "The braille Cell is composed of 6 dot \n"
+                "cells organized in form of two vertical\n"
+                "columns with 3 dots {1,2,3} side\n"
+                "by side on left and 3 dots side by\n"
+                "on right {4,5,6}"}
+class Gcompris_braille_alphabets:
+  """Empty gcompris python class"""
+
+
+  def __init__(self, gcomprisBoard):
+    # Save the gcomprisBoard, it defines everything we need
+    # to know from the core
+    #defining the number of levels in activity
+    self.gcomprisBoard = gcomprisBoard
+    self.gcomprisBoard.level = 1
+    self.gcomprisBoard.maxlevel=6
+    self.gcomprisBoard.sublevel=1
+    self.gcomprisBoard.number_of_sublevel=1
+
+    # Needed to get key_press
+    gcomprisBoard.disable_im_context = True
+
+  def start(self):
+    # Set the buttons we want in the bar
+    gcompris.bar_set_level(self.gcomprisBoard)
+    gcompris.bar_set(gcompris.BAR_LEVEL)
+    pixmap = gcompris.utils.load_svg("target.svg")
+    gcompris.bar_set_repeat_icon(pixmap)
+    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
+
+    # 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())
+    self.board_upper(self.gcomprisBoard.level)
+
+  def end(self):
+    # Remove the root item removes all the others inside it
+    self.rootitem.remove()
+
+  def ok(self):
+    print("learnbraille ok.")
+
+  def repeat(self):
+    self.end()
+    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
+    self.rootitem = goocanvas.Group(parent=
+                                   self.gcomprisBoard.canvas.get_root_item())
+    #Place alphabets & numbers in array format
+    for i, letter in enumerate(string.ascii_uppercase[:10]):
+        tile = BrailleChar(self.rootitem, i*(cell_width+30)+60,
+                              60, 50, letter ,True ,False,None)
+    for i, letter in enumerate(string.ascii_uppercase[10:20]):
+        tile = BrailleChar(self.rootitem, i*(cell_width+30)+60,
+                              150, 50, letter ,True ,False,None)
+    for i, letter in enumerate(string.ascii_uppercase[20:25]):
+        tile = BrailleChar(self.rootitem, i*(cell_width+30)+60,
+                              250, 50, letter ,True ,False,None)
+    for letter in range(0,10):
+          tile = BrailleChar(self.rootitem,letter *(cell_width+30)+60,
+                             350, 50, letter ,True,False ,None)
+    #Move back item
+    self.backitem = goocanvas.Image(parent = self.rootitem,
+                    pixbuf = gcompris.utils.load_pixmap("back.png"),
+                    x = 600,
+                    y = 450,
+                    tooltip = "Move Back"
+                    )
+    self.backitem.connect("button_press_event", self.move_back)
+    gcompris.utils.item_focus_init(self.backitem, None)
+
+  def move_back(self,event,target,item):
+      self.end()
+      self.start()
+
+  def config(self):
+    print("learnbraille config.")
+
+  def key_press(self, keyval, commit_str, preedit_str):
+    utf8char = gtk.gdk.keyval_to_unicode(keyval)
+    strn = u'%c' % utf8char
+    print("Gcompris_learnbraille key press keyval=%i %s" % (keyval, strn))
+
+  def pause(self,pause):
+    if(pause == 0):
+        self.increment_level()
+        self.end()
+        self.start()
+        return
+
+  def set_level(self,level):
+    gcompris.sound.play_ogg("sounds/receive.wav")
+    self.gcomprisBoard.level = level
+    self.gcomprisBoard.sublevel = 1
+    gcompris.bar_set_level(self.gcomprisBoard)
+    self.end()
+    self.start()
+
+  def increment_level(self):
+    gcompris.sound.play_ogg("sounds/bleep.wav")
+    self.gcomprisBoard.sublevel += 1
+
+    if(self.gcomprisBoard.sublevel>self.gcomprisBoard.number_of_sublevel):
+        self.gcomprisBoard.sublevel=1
+        self.gcomprisBoard.level += 1
+        if(self.gcomprisBoard.level > self.gcomprisBoard.maxlevel):
+            self.gcomprisBoard.level = self.gcomprisBoard.maxlevel
+
+  def board_upper(self,level):
+    if(level == 1):
+        gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
+                            "braille_tux.svgz")
+        goocanvas.Text(parent=self.rootitem,
+                                 x=390,
+                                 y=100,
+                                 fill_color="dark blue",
+                                 font="Sans 15",
+                                 anchor=gtk.ANCHOR_CENTER,
+                                 text="Braille : Unlocking the Code")
+        #Braille Description
+        goocanvas.Text(parent=self.rootitem,
+                                 x=520,
+                                 y=260,
+                                 fill_color="dark blue",
+                                 font="Sans 15",
+                                 anchor=gtk.ANCHOR_CENTER,
+                                 text=braille_desc.get('intro'))
+
+        #TUX svghandle
+        svghandle = gcompris.utils.load_svg("braille_tux.svgz")
+        self.tuxitem = goocanvas.Svg(
+                                     parent = self.rootitem,
+                                     svg_handle = svghandle,
+                                     svg_id = "#TUX-5",
+                                     tooltip = "I am braille TUX"
+                                     )
+        self.tuxitem.connect("button_press_event", self.next_level)
+        gcompris.utils.item_focus_init(self.tuxitem, None)
+
+        goocanvas.Text(parent = self.rootitem,
+                        x = 410,
+                        y= 430,
+                        fill_color ="black",
+                        font = "Sans 10",
+                        anchor= gtk.ANCHOR_CENTER,
+                        text = "Finished reading braille ! Now click \n"
+                        "me and try reproducing braille characters")
+    elif(level ==2):
+        self.random_letter = string.uppercase[random.randint(0,6)]
+        range_lower= 0
+        range_upper= 7
+        self.braille_cell()
+        self.board_tile(range_lower,range_upper)
+    elif(level == 3) :
+        range_lower= 7
+        range_upper= 14
+        self.random_letter = string.uppercase[random.randint(7,13)]
+        self.braille_cell()
+        self.board_tile(range_lower,range_upper)
+    elif(level == 4):
+        range_lower= 14
+        range_upper= 21
+        self.random_letter = string.uppercase[random.randint(14,20)]
+        self.braille_cell()
+        self.board_tile(range_lower,range_upper)
+    elif(level == 5):
+        range_lower= 21
+        range_upper= 26
+        self.random_letter = string.uppercase[random.randint(21,25)]
+        self.braille_cell()
+        self.board_tile(range_lower,range_upper)
+    elif(level == 6):
+        range_lower= 0
+        range_upper= 10
+        self.random_letter = random.randint(0,8)
+        self.braille_cell()
+        self.board_number(range_lower,range_upper)
+
+  def next_level(self,event,target,item):
+      self.pause(0)
+
+  def board_tile(self,range_x,range_y):
+      for i, letter in enumerate(string.ascii_uppercase[range_x:range_y]):
+          tile = BrailleChar(self.rootitem, i*(cell_width+60)+60,
+                              80, 50, letter ,True ,False ,None)
+  def board_number(self,num_1,num_2):
+      for letter in range(num_1,num_2):
+          tile = BrailleChar(self.rootitem,letter *(cell_width+30)+60,
+                             80, 50, letter ,True,False ,None)
+
+  def display_letter(self,letter):
+      goocanvas.Text(parent=self.rootitem,
+                                 x=600,
+                                 y=350,
+                                 fill_color="blue",
+                                 font="Sans 78",
+                                 anchor=gtk.ANCHOR_CENTER,
+                                 text=str(letter))
+
+  def braille_cell(self):
+      gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
+                            "mosaic.svgz")
+      goocanvas.Text(parent = self.rootitem,
+                     x = 100,
+                     y = 200,
+                     text="Click on the dots in braille cell area to produce letter"
+                      + ' '+str(self.random_letter),
+                     fill_color="blue",
+                     font='SANS 15')
+
+      goocanvas.Text(parent=self.rootitem, x=800.0, y=260.0, text="Alphabet",
+                   width=500, height=500, fill_color="blue",
+                   anchor=gtk.ANCHOR_CENTER, font='Sans BOLD')
+
+      goocanvas.Text(parent=self.rootitem,
+                      x=160.0, y=250.0,
+                     text=_("Braille Cell"),
+                     fill_color="blue",
+                     font='Sans BOLD')
+      BrailleChar(self.rootitem, 150, 270, 120, '',False,True,callback = self.letter_change)
+      for i in range(2):
+          for j in range(3):
+                  goocanvas.Text(parent=self.rootitem,
+                                 text=(str(j + 1 + i * 3)),
+                                 font='Sans 20',
+                                 fill_color="blue",
+                                 x=i * 120 + 140,
+                                 y=j * 45 + 290)
+
+  def letter_change(self, letter):
+      if(self.random_letter == letter):
+          self.display_letter(letter)
+          gcompris.bonus.display(gcompris.bonus.WIN,gcompris.bonus.SMILEY)
\ No newline at end of file
diff --git a/src/braille_alphabets-activity/resources/back.png b/src/braille_alphabets-activity/resources/back.png
new file mode 100644
index 0000000..2701f21
Binary files /dev/null and b/src/braille_alphabets-activity/resources/back.png differ
diff --git a/src/braille_alphabets-activity/resources/braille_tux.svgz b/src/braille_alphabets-activity/resources/braille_tux.svgz
new file mode 100644
index 0000000..a374d91
Binary files /dev/null and b/src/braille_alphabets-activity/resources/braille_tux.svgz differ
diff --git a/src/braille_alphabets-activity/resources/mosaic.svgz b/src/braille_alphabets-activity/resources/mosaic.svgz
new file mode 100644
index 0000000..29292ca
Binary files /dev/null and b/src/braille_alphabets-activity/resources/mosaic.svgz differ
diff --git a/src/braille_alphabets-activity/resources/target.svg b/src/braille_alphabets-activity/resources/target.svg
new file mode 100644
index 0000000..f04b225
--- /dev/null
+++ b/src/braille_alphabets-activity/resources/target.svg
@@ -0,0 +1,148 @@
+<?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:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="64px"
+   height="64px"
+   id="svg3211"
+   version="1.1"
+   inkscape:version="0.48.0 r9654"
+   sodipodi:docname="target.svg">
+  <defs
+     id="defs3213" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="5.5"
+     inkscape:cx="32"
+     inkscape:cy="32"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:document-units="px"
+     inkscape:grid-bbox="true"
+     inkscape:window-width="1280"
+     inkscape:window-height="701"
+     inkscape:window-x="0"
+     inkscape:window-y="37"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata3216">
+    <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>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer">
+    <g
+       id="g34218"
+       transform="matrix(0.74091789,-0.00895527,0.00790171,0.72102019,-4.4493366,-4.3813411)">
+      <path
+         id="path2941"
+         d="m 41.876434,78.550846 -1.099019,2.060663 -0.274755,4.415703 1.373774,2.649422 1.64853,2.649422 5.495097,0.29438 3.846569,-3.238183 -0.274755,-2.943802 -0.54951,-2.649422 -1.373774,-3.238183 -7.418382,-0.29438 -1.373775,0.29438 z"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
+         inkscape:connector-curvature="0" />
+      <g
+         transform="translate(-0.639516,-2.131719)"
+         id="g34199">
+        <path
+           style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
+           d="m 41.142176,9.6151159 c 0,0 15.987893,1.2790311 17.266924,1.2790311 1.279031,0 14.282517,5.116126 14.282517,5.116126 l 11.724454,12.790314 c 0,0 2.558063,10.019079 2.771235,11.084938 0.213172,1.06586 -1.918547,15.348377 -1.918547,16.84058 0,1.492203 -5.755642,13.42983 -5.755642,13.42983 l -9.166391,10.23225 c 0,0 -10.658595,2.558064 -14.282517,2.558064 -3.623922,0 -13.003486,0.639515 -15.774721,0.639515 -2.771234,0 -15.348376,-3.837094 -16.627408,-4.902954 C 22.383049,77.616951 10.445423,69.090075 10.658595,67.811044 10.871767,66.532012 5.7556412,56.512934 6.6083288,54.381215 7.4610164,52.249496 7.4610163,38.819666 7.4610163,38.819666 c 0,0 4.2634377,-9.805908 5.7556417,-12.363971 1.492203,-2.558062 4.902953,-6.181984 6.395156,-7.887359 1.492204,-1.705376 9.805908,-5.54247 9.805908,-5.54247 L 41.142176,9.6151159 z"
+           id="path2935"
+           sodipodi:nodetypes="csccssccssssscsscc"
+           inkscape:connector-curvature="0" />
+        <path
+           style="fill:#2165cd;fill-opacity:1;fill-rule:evenodd;stroke:none"
+           d="m 42.273349,15.051 c 0,0 14.129427,1.091047 15.259781,1.091047 1.130353,0 12.622287,4.364188 12.622287,4.364188 l 10.36158,10.910469 c 0,0 2.260708,8.546535 2.4491,9.45574 0.188393,0.909206 -1.695531,13.092564 -1.695531,14.365452 0,1.272887 -5.086594,11.455993 -5.086594,11.455993 l -8.100871,8.728374 c 0,0 -9.419618,2.182095 -12.622287,2.182095 -3.20267,0 -11.491934,0.545523 -13.941035,0.545523 -2.4491,0 -13.564249,-3.27314 -14.694604,-4.182347 -1.130354,-0.909205 -11.680325,-8.182851 -11.491933,-9.273898 0.188392,-1.091047 -4.333024,-9.637581 -3.579455,-11.455992 0.75357,-1.818412 0.75357,-13.274405 0.75357,-13.274405 0,0 3.767846,-8.364694 5.086593,-10.546788 1.318747,-2.182094 4.333024,-5.273393 5.65177,-6.728122 1.318747,-1.45473 8.666049,-4.727871 8.666049,-4.727871 L 42.273349,15.051 z"
+           id="path34196"
+           sodipodi:nodetypes="csccssccssssscsscc"
+           inkscape:connector-curvature="0" />
+      </g>
+      <g
+         transform="translate(-87.61365,-33.04165)"
+         id="g34189">
+        <path
+           style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
+           d="m 111.27573,66.958356 11.51128,-10.871767 c 0,0 10.44542,-0.426344 13.643,-0.639516 3.19758,-0.213172 11.29811,2.558063 11.29811,2.558063 0,0 6.8215,5.329297 7.03468,6.821501 0.21317,1.492203 3.83709,10.871766 3.41075,13.429829 -0.42635,2.558063 -1.49221,9.166392 -1.91855,10.445423 -0.42634,1.279031 -9.37956,9.592736 -10.87177,10.445423 C 143.89103,100 131.52706,101.06586 127.26362,100 c -4.26344,-1.06586 -13.643,-5.116126 -13.643,-6.395157 0,-1.279032 -3.19758,-11.298111 -3.83709,-14.495689 -0.63952,-3.197579 1.27903,-12.150798 1.4922,-12.150798 z"
+           id="path2933"
+           sodipodi:nodetypes="ccscsssssssc"
+           inkscape:connector-curvature="0" />
+        <path
+           style="fill:#ffcc00;fill-opacity:1;fill-rule:evenodd;stroke:none"
+           d="m 114.80451,87.049609 9.74244,8.915227 c 0,0 8.84036,0.349616 11.54659,0.524425 2.70624,0.174809 9.56202,-2.097701 9.56202,-2.097701 0,0 5.7733,-4.370209 5.95372,-5.593867 0.18041,-1.223659 3.24747,-8.915227 2.88664,-11.012927 -0.36083,-2.0977 -1.2629,-7.51676 -1.62373,-8.56561 -0.36084,-1.04885 -7.93829,-7.866377 -9.2012,-8.56561 -1.2629,-0.699234 -11.727,-1.573276 -15.33531,-0.699234 -3.60831,0.874043 -11.54659,4.195401 -11.54659,5.244251 0,1.048851 -2.70624,9.264844 -3.24748,11.886969 -0.54125,2.622126 1.08249,9.964077 1.2629,9.964077 z"
+           id="path34187"
+           sodipodi:nodetypes="ccscsssssssc"
+           inkscape:connector-curvature="0" />
+        <g
+           id="g34181"
+           transform="translate(86.72317,32.58648)">
+          <path
+             sodipodi:nodetypes="cscscscssc"
+             id="path34183"
+             d="m 35.546664,49.58198 c 0,0 -0.415835,-6.958638 -0.151997,-8.0605 0.263839,-1.101861 4.901081,-7.365561 4.901081,-7.365561 0,0 5.10562,-1.865964 9.854703,-1.039569 4.749084,0.826397 6.992246,2.104826 8.086283,4.345154 0.690182,1.413329 2.63838,6.335704 1.846867,9.365822 -0.791514,3.03012 -2.902218,6.61117 -2.902218,6.61117 0,0 -5.27676,4.682911 -6.595951,4.958376 -1.31919,0.275466 -7.459145,-1.003565 -9.306012,-2.105427 -1.846865,-1.101861 -5.996594,-6.433999 -5.732756,-6.709465 z"
+             style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
+             inkscape:connector-curvature="0" />
+          <path
+             sodipodi:nodetypes="cscscscssc"
+             id="path34185"
+             d="m 48.337813,54.969999 c 0,0 -4.852783,-0.938451 -5.556353,-1.313515 -0.703569,-0.375065 -4.086051,-4.662326 -4.086051,-4.662326 0,0 -0.275176,-3.835394 1.225465,-6.952261 1.500643,-3.116867 2.818346,-4.432852 4.569539,-4.79027 1.104754,-0.225481 4.862815,-0.69784 6.784657,0.378894 1.921843,1.076735 3.961959,3.156563 3.961959,3.156563 0,0 2.172878,4.448483 2.102286,5.403119 -0.07059,0.954635 -2.155127,4.947296 -3.273829,6.022116 -1.1187,1.07482 -5.590699,2.987372 -5.727673,2.75768 z"
+             style="fill:#ff140e;fill-opacity:1;fill-rule:evenodd;stroke:none"
+             inkscape:connector-curvature="0" />
+        </g>
+      </g>
+      <g
+         transform="translate(-0.639516,-2.131719)"
+         id="g34206">
+        <path
+           style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
+           d="m 21.337915,74.632545 -5.344101,5.651787 -4.500296,5.394889 -1.6876106,5.908688 0.2812686,2.312095 8.156786,0.770699 5.344101,-4.110392 -1.125075,-4.62419 1.968879,-4.110391 5.62537,-3.596593 -8.719322,-3.596592 z"
+           id="path2937"
+           inkscape:connector-curvature="0" />
+        <path
+           style="fill:#85c751;fill-opacity:1;fill-rule:evenodd;stroke:none"
+           d="m 22.369847,76.385351 -3.743079,5.020853 -3.748481,3.828822 -1.405762,2.350884 -0.133982,2.903916 3.316201,0.692412 3.734239,-1.680492 -0.769628,-2.447263 0.493096,-4.326456 5.77782,-4.87644 -3.520424,-1.466236 z"
+           id="path34204"
+           sodipodi:nodetypes="ccccccccccc"
+           inkscape:connector-curvature="0" />
+      </g>
+      <g
+         transform="matrix(-1,0,0,1,92.62318,-1.279032)"
+         id="g34210">
+        <path
+           style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"
+           d="m 21.337915,74.632545 -5.344101,5.651787 -4.500296,5.394889 -1.6876106,5.908688 0.2812686,2.312095 8.156786,0.770699 5.344101,-4.110392 -1.125075,-4.62419 1.968879,-4.110391 5.62537,-3.596593 -8.719322,-3.596592 z"
+           id="path34212"
+           inkscape:connector-curvature="0" />
+        <path
+           style="fill:#85c751;fill-opacity:1;fill-rule:evenodd;stroke:none"
+           d="m 22.583019,75.959008 -3.956251,5.447196 -3.748481,3.828822 -1.405762,2.350884 -0.133982,2.903916 3.316201,0.692412 3.734239,-1.680492 -0.769628,-2.447263 0.493096,-4.326456 5.351476,-4.87644 -2.880908,-1.892579 z"
+           id="path34214"
+           sodipodi:nodetypes="ccccccccccc"
+           inkscape:connector-curvature="0" />
+      </g>
+      <path
+         id="path34216"
+         d="m 49.337452,81.606312 0.606355,1.06586 0.151589,2.283984 -0.757944,1.370391 -0.909534,1.37039 -3.031778,0.152266 -2.122245,-1.674922 0.151589,-1.522657 0.303178,-1.37039 0.757944,-1.674922 4.092901,-0.152266 0.757945,0.152266 z"
+         style="fill:#85c751;fill-opacity:1;fill-rule:evenodd;stroke:none"
+         inkscape:connector-curvature="0" />
+    </g>
+  </g>
+</svg>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]