Commit 62c470a1 authored by Srishti Sethi's avatar Srishti Sethi

toggle repeat|proposing all letters|OK button|bar|debugging

parent b4ffe3aa
File mode changed from 100644 to 100755
......@@ -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
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment