[gcompris/gcomprisbraille: 15/32] toggle repeat|proposing all letters|OK button|bar|debugging
- From: Srishti Sethi <srishs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprisbraille: 15/32] toggle repeat|proposing all letters|OK button|bar|debugging
- Date: Tue, 14 Jun 2011 06:15:45 +0000 (UTC)
commit 62c470a195d2b3522f6d1bcb7f5d172814325500
Author: Srishti Sethi <srishakatux gmail com>
Date: Thu Jun 9 01:45:38 2011 +0530
toggle repeat|proposing all letters|OK button|bar|debugging
.../braille_alphabets.py | 137 ++++++++++++++------
src/braille_alphabets-activity/resources/back.png | Bin 1573 -> 1573 bytes
.../resources/braille_tux.svgz | Bin 14786 -> 14786 bytes
.../resources/mosaic.svgz | Bin 4491 -> 4491 bytes
4 files changed, 97 insertions(+), 40 deletions(-)
---
diff --git a/src/braille_alphabets-activity/BrailleChar.py b/src/braille_alphabets-activity/BrailleChar.py
old mode 100644
new mode 100755
diff --git a/src/braille_alphabets-activity/braille_alphabets.py b/src/braille_alphabets-activity/braille_alphabets.py
old mode 100644
new mode 100755
index e61ea05..85d9776
--- a/src/braille_alphabets-activity/braille_alphabets.py
+++ b/src/braille_alphabets-activity/braille_alphabets.py
@@ -38,6 +38,19 @@ braille_desc = {'intro' : "A system of writing for the blinds that \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}"}
+
+#Array Declaration
+letter_arr_one = ['A','B','C','D','E','F','G']
+random.shuffle(letter_arr_one)
+letter_arr_two = ['H','I','J','K','L','M','N']
+random.shuffle(letter_arr_two)
+letter_arr_three = ['O','P','Q','R','S','T','U']
+random.shuffle(letter_arr_three)
+letter_arr_four = ['V','W','V','X','Y','Z']
+random.shuffle(letter_arr_four)
+letter_arr_five = [0,1,2,3,4,5,6,7,8,9]
+random.shuffle(letter_arr_five)
+
class Gcompris_braille_alphabets:
"""Empty gcompris python class"""
@@ -46,22 +59,28 @@ class Gcompris_braille_alphabets:
# Save the gcomprisBoard, it defines everything we need
# to know from the core
#defining the number of levels in activity
+ self.counter = 0
self.gcomprisBoard = gcomprisBoard
self.gcomprisBoard.level = 1
self.gcomprisBoard.maxlevel=6
self.gcomprisBoard.sublevel=1
self.gcomprisBoard.number_of_sublevel=1
+ #Boolean variable decaration
+ self.mapActive = False
+
# 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)
+ gcompris.bar_set_level(self.gcomprisBoard)
+
pixmap = gcompris.utils.load_svg("target.svg")
gcompris.bar_set_repeat_icon(pixmap)
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
+ gcompris.bar_location(300,-1,0.6)
# 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
@@ -79,32 +98,41 @@ class Gcompris_braille_alphabets:
print("learnbraille ok.")
def repeat(self):
- self.end()
- gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
- self.rootitem = goocanvas.Group(parent=
+ if(self.mapActive):
+ self.end()
+ self.start()
+ self.mapActive = False
+ else :
+ self.rootitem.props.visibility = goocanvas.ITEM_INVISIBLE
+ 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,
+ gcompris.set_default_background(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,
+ 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,
+ 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,
+ 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,
+ #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)
+ self.backitem.connect("button_press_event", self.move_back)
+ gcompris.utils.item_focus_init(self.backitem, None)
+
+ self.mapActive = True
+
def move_back(self,event,target,item):
self.end()
@@ -120,10 +148,11 @@ class Gcompris_braille_alphabets:
def pause(self,pause):
if(pause == 0):
- self.increment_level()
+ self.counter +=1
+ if (self.counter == self.sublevel):
+ self.increment_level()
self.end()
self.start()
- return
def set_level(self,level):
gcompris.sound.play_ogg("sounds/receive.wav")
@@ -134,6 +163,7 @@ class Gcompris_braille_alphabets:
self.start()
def increment_level(self):
+ self.counter = 0
gcompris.sound.play_ogg("sounds/bleep.wav")
self.gcomprisBoard.sublevel += 1
@@ -141,7 +171,8 @@ class Gcompris_braille_alphabets:
self.gcomprisBoard.sublevel=1
self.gcomprisBoard.level += 1
if(self.gcomprisBoard.level > self.gcomprisBoard.maxlevel):
- self.gcomprisBoard.level = self.gcomprisBoard.maxlevel
+ self.gcomprisBoard.level = 1
+
def board_upper(self,level):
if(level == 1):
@@ -183,38 +214,50 @@ class Gcompris_braille_alphabets:
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.sublevel = range_upper - range_lower
self.board_tile(range_lower,range_upper)
+ self.random_letter = letter_arr_one[self.counter]
+ self.braille_cell()
+
elif(level == 3) :
range_lower= 7
range_upper= 14
- self.random_letter = string.uppercase[random.randint(7,13)]
- self.braille_cell()
+ self.sublevel = range_upper - range_lower
self.board_tile(range_lower,range_upper)
+ self.random_letter = letter_arr_two[self.counter]
+ self.braille_cell()
+
elif(level == 4):
range_lower= 14
range_upper= 21
- self.random_letter = string.uppercase[random.randint(14,20)]
- self.braille_cell()
+ self.sublevel = range_upper - range_lower
self.board_tile(range_lower,range_upper)
+ self.random_letter = letter_arr_three[self.counter]
+ self.braille_cell()
+
elif(level == 5):
range_lower= 21
range_upper= 26
- self.random_letter = string.uppercase[random.randint(21,25)]
- self.braille_cell()
+ self.sublevel = range_upper - range_lower
self.board_tile(range_lower,range_upper)
+ self.random_letter = letter_arr_four[self.counter]
+ self.braille_cell()
+
elif(level == 6):
range_lower= 0
range_upper= 10
- self.random_letter = random.randint(0,8)
- self.braille_cell()
+ self.sublevel = range_upper - range_lower
self.board_number(range_lower,range_upper)
+ self.random_letter = letter_arr_five[self.counter]
+ self.braille_cell()
+
def next_level(self,event,target,item):
- self.pause(0)
+ self.increment_level()
+ self.end()
+ self.start()
def board_tile(self,range_x,range_y):
for i, letter in enumerate(string.ascii_uppercase[range_x:range_y]):
@@ -228,7 +271,7 @@ class Gcompris_braille_alphabets:
def display_letter(self,letter):
goocanvas.Text(parent=self.rootitem,
x=600,
- y=350,
+ y=370,
fill_color="blue",
font="Sans 78",
anchor=gtk.ANCHOR_CENTER,
@@ -237,6 +280,7 @@ class Gcompris_braille_alphabets:
def braille_cell(self):
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
"mosaic.svgz")
+
goocanvas.Text(parent = self.rootitem,
x = 100,
y = 200,
@@ -245,10 +289,6 @@ class Gcompris_braille_alphabets:
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"),
@@ -264,7 +304,24 @@ class Gcompris_braille_alphabets:
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
+ #OK Button
+ ok = goocanvas.Svg(parent = self.rootitem,
+ svg_handle = gcompris.skin.svg_get(),
+ svg_id = "#OK",
+ tooltip = "Click to confirm your selection of dots"
+ )
+ ok.translate(30,-185)
+
+ ok.connect("button_press_event", self.ok_event)
+ gcompris.utils.item_focus_init(ok, None)
+
+ def ok_event(self,item,target,event):
+ if(self.random_letter == self.correct_letter):
+ self.display_letter(self.correct_letter)
+ gcompris.bonus.display(gcompris.bonus.WIN,gcompris.bonus.SMILEY)
+ else :
+ gcompris.bonus.display(gcompris.bonus.LOOSE,gcompris.bonus.SMILEY)
+
+
+ def letter_change(self,letter):
+ self.correct_letter = letter
\ No newline at end of file
diff --git a/src/braille_alphabets-activity/braille_alphabets.xml.in b/src/braille_alphabets-activity/braille_alphabets.xml.in
old mode 100644
new mode 100755
diff --git a/src/braille_alphabets-activity/braillebug.svg b/src/braille_alphabets-activity/braillebug.svg
old mode 100644
new mode 100755
diff --git a/src/braille_alphabets-activity/resources/back.png b/src/braille_alphabets-activity/resources/back.png
old mode 100644
new mode 100755
diff --git a/src/braille_alphabets-activity/resources/braille_tux.svgz b/src/braille_alphabets-activity/resources/braille_tux.svgz
old mode 100644
new mode 100755
diff --git a/src/braille_alphabets-activity/resources/drawing.svg b/src/braille_alphabets-activity/resources/drawing.svg
old mode 100644
new mode 100755
diff --git a/src/braille_alphabets-activity/resources/mosaic.svgz b/src/braille_alphabets-activity/resources/mosaic.svgz
old mode 100644
new mode 100755
diff --git a/src/braille_alphabets-activity/resources/target.svg b/src/braille_alphabets-activity/resources/target.svg
old mode 100644
new mode 100755
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]