def start(self): print "decryption start" self.wordlist = None try: self.language = gcompris.gcompris_gettext( gcompris.get_locale_name(gcompris.get_locale()) ) self.wordlist = gcompris.get_wordlist("decryption/default-$LOCALE.xml") except: pass # Fallback to wordsgame list if not self.wordlist: try: self.language = gcompris.gcompris_gettext( gcompris.get_locale_name(gcompris.get_locale()) ) self.wordlist = gcompris.get_wordlist("wordsgame/default-$LOCALE.xml") except: pass # Fallback to english if not self.wordlist: try: self.wordlist = gcompris.get_wordlist("decryption/default-en.xml") self.language = _("English") except: pass # Fallback to English wordsgame list if not self.wordlist: self.wordlist = gcompris.get_wordlist("wordsgame/default-en.xml") self.language = _("English") if not self.wordlist: gcompris.utils.dialog(_("Could not find the list of words."), stop_board) return; # 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.next_level()
def start(self): # 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.backitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item()) svghandle = gcompris.utils.load_svg("hangman/back.svgz") goocanvas.Svg( parent = self.backitem, svg_handle = svghandle, pointer_events = goocanvas.EVENTS_NONE ) # 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.backitem) # Get the name of the language for the current locale self.wordlist = None try: self.language = gcompris.gcompris_gettext( gcompris.get_locale_name(gcompris.get_locale()) ) self.wordlist = gcompris.get_wordlist("wordsgame/default-$LOCALE.xml") except: pass if not self.wordlist: # Fallback to english self.wordlist = gcompris.get_wordlist("wordsgame/default-en.xml") self.language = _("English") if not self.wordlist: gcompris.utils.dialog(_("Could not find the list of words."), stop_board) return; self.gcomprisBoard.level = 1 self.gcomprisBoard.maxlevel = self.wordlist.number_of_level * 3 self.gcomprisBoard.sublevel = 1 self.gcomprisBoard.number_of_sublevel = 10 # Set the buttons we want in the bar gcompris.bar_set(gcompris.BAR_LEVEL) gcompris.bar_location(gcompris.BOARD_WIDTH - 160, -1, 0.6) # Set a background image gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item()) self.display_level()
def displayLesson(self, lesson): # Keep the triplet shown to the user to know when # we can move to the exercices self.tripletSeen = set() try: self.lessonroot.remove() except: pass self.currentTripletId = 0 self.lessonroot = goocanvas.Group(parent=self.rootitem) goocanvas.Rect(parent=self.lessonroot, x=20, y=10, width=gcompris.BOARD_WIDTH - 40, height=65, fill_color_rgba=0xAAAAAA99L, stroke_color_rgba=0x111111AAL, line_width=2.0, radius_x=3, radius_y=3) goocanvas.Text(parent=self.lessonroot, x=gcompris.BOARD_WIDTH / 2, y=40.0, text=gcompris.gcompris_gettext(lesson.name), fill_color="black", font=gcompris.skin.get_font("gcompris/title"), anchor=gtk.ANCHOR_CENTER, alignment=pango.ALIGN_CENTER, width=300) # Previous Button item = goocanvas.Svg( parent=self.lessonroot, svg_handle=gcompris.skin.svg_get(), svg_id="#PREVIOUS", ) gcompris.utils.item_absolute_move(item, 100, gcompris.BOARD_HEIGHT / 2) item.connect("button_press_event", self.previous_event, None) gcompris.utils.item_focus_init(item, None) # Next Button item = goocanvas.Svg( parent=self.lessonroot, svg_handle=gcompris.skin.svg_get(), svg_id="#NEXT", ) gcompris.utils.item_absolute_move(item, gcompris.BOARD_WIDTH - 130, gcompris.BOARD_HEIGHT / 2) item.connect("button_press_event", self.next_event, None) gcompris.utils.item_focus_init(item, None) self.counteritem = goocanvas.Text( parent=self.lessonroot, x=gcompris.BOARD_WIDTH - 40, y=gcompris.BOARD_HEIGHT - 40, fill_color="black", font=gcompris.skin.get_font("gcompris/board/tiny"), anchor=gtk.ANCHOR_CENTER, alignment=pango.ALIGN_CENTER) # The triplet area w = 400 h = 300 goocanvas.Rect(parent=self.lessonroot, x=(gcompris.BOARD_WIDTH - w) / 2, y=(gcompris.BOARD_HEIGHT - h) / 2, width=w, height=h + 50, fill_color_rgba=0xCECECECCL, stroke_color_rgba=0x111111CCL, line_width=2.0, radius_x=3, radius_y=3) self.imageitem = goocanvas.Image(parent=self.lessonroot) self.imageitem.connect("button_press_event", self.next_event, None) self.descriptionitem = goocanvas.Text( parent=self.lessonroot, x=gcompris.BOARD_WIDTH / 2, y=gcompris.BOARD_HEIGHT - 80, fill_color="black", font=gcompris.skin.get_font("gcompris/subtitle"), anchor=gtk.ANCHOR_CENTER, alignment=pango.ALIGN_CENTER, width=500) self.displayImage(lesson.getTriplets()[self.currentTripletId])
def displayLesson(self, lesson): # Keep the triplet shown to the user to know when # we can move to the exercices self.tripletSeen = set() try: self.lessonroot.remove() except: pass self.currentTripletId = 0 self.lessonroot = goocanvas.Group( parent = self.rootitem ) goocanvas.Rect( parent = self.lessonroot, x = 20, y = 10, width = gcompris.BOARD_WIDTH - 40, height = 65, fill_color_rgba = 0xAAAAAA99L, stroke_color_rgba = 0x111111AAL, line_width = 2.0, radius_x = 3, radius_y = 3) goocanvas.Text( parent = self.lessonroot, x = gcompris.BOARD_WIDTH / 2, y = 40.0, text = gcompris.gcompris_gettext(lesson.name), font = gcompris.skin.get_font("gcompris/title"), fill_color = "white", anchor = gtk.ANCHOR_CENTER, alignment = pango.ALIGN_CENTER, width = 300 ) # Previous Button item = goocanvas.Svg( parent = self.lessonroot, svg_handle = gcompris.skin.svg_get(), svg_id = "#PREVIOUS", ) gcompris.utils.item_absolute_move(item, 100, gcompris.BOARD_HEIGHT / 2) item.connect("button_press_event", self.previous_event, None) gcompris.utils.item_focus_init(item, None) # Next Button item = goocanvas.Svg(parent = self.lessonroot, svg_handle = gcompris.skin.svg_get(), svg_id = "#NEXT", ) gcompris.utils.item_absolute_move(item, gcompris.BOARD_WIDTH - 130, gcompris.BOARD_HEIGHT / 2) item.connect("button_press_event", self.next_event, None) gcompris.utils.item_focus_init(item, None) self.counteritem = goocanvas.Text( parent = self.lessonroot, x = gcompris.BOARD_WIDTH - 40, y = gcompris.BOARD_HEIGHT - 40, font = gcompris.skin.get_font("gcompris/board/tiny"), fill_color = "white", anchor = gtk.ANCHOR_CENTER, alignment = pango.ALIGN_CENTER ) # The triplet area w = 400 h = 300 goocanvas.Rect( parent = self.lessonroot, x = (gcompris.BOARD_WIDTH - w) / 2, y = (gcompris.BOARD_HEIGHT - h) / 2 - 20, width = w, height = h + 50, fill_color_rgba = 0xCECECEAAL, stroke_color_rgba = 0x111111CCL, line_width = 2.0, radius_x = 3, radius_y = 3) self.imageitem = goocanvas.Image( parent = self.lessonroot ) self.imageitem.connect("button_press_event", self.next_event, None) goocanvas.Rect( parent = self.lessonroot, x = (gcompris.BOARD_WIDTH - w) / 2, y = (gcompris.BOARD_HEIGHT - h) / 2 - 10 + h, width = w, height = 40, fill_color_rgba = 0x999999BBL, stroke_color_rgba = 0x111111AAL, line_width = 2.0, radius_x = 3, radius_y = 3) self.descriptionitem = goocanvas.Text( parent = self.lessonroot, x = gcompris.BOARD_WIDTH / 2, y = gcompris.BOARD_HEIGHT - 100, fill_color = "white", font = gcompris.skin.get_font("gcompris/subtitle"), anchor = gtk.ANCHOR_CENTER, alignment = pango.ALIGN_CENTER, width = 500 )