Ejemplo n.º 1
0
  def start(self):

    # GCompris initialisation
    self.gcomprisBoard.level=1
    self.gcomprisBoard.maxlevel=1
    self.gcomprisBoard.sublevel=0
    self.gcomprisBoard.number_of_sublevel=0

    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    # 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.doc = Document(self)

    # initialisation
    self.draw_tools()
    self.draw_animtools()

    self.doc.timeline.draw()
    if self.gcomprisBoard.mode == 'draw':
      self.doc.timeline.hide()

    self.color_rootitem = goocanvas.Group(
      parent =  self.gcomprisBoard.canvas.get_root_item())
    self.color = Color(self.color_rootitem, self.drawing_area)
    self.color.draw()

    self.draw_drawing_area()
    self.draw_playing_area()

    gcompris.bar_set(0)
    gcompris.bar_location(10, -1, 0.6)
Ejemplo n.º 2
0
  def start(self):
   
    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)

    # Set a background image
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            "morse/morse.png")
    
    self.rootitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())
    
    for i in ascii_uppercase:
      if i < "E":
        rect = MorseDes(self.rootitem,self.xaxis1,self.yaxis,100,True,False,"rectangle",self.on,self.off,"brown","black",i,"A")
        self.xaxis1 = self.xaxis1 + self.space

      if "E" < i and i <= "J":
        rect = MorseDes(self.rootitem,self.xaxis2,self.yaxis+70,100,True,False,"rectangle",self.on,self.off,"brown","black",i,"B")
        self.xaxis2 = self.xaxis2 + self.space
    self.w = gtk.Button ("Start Animation")
    self.rootitem.add_child(self.w)

    gcompris.bar_set(0)
    gcompris.bar_location(5,-1, 0.6)
    gcompris.bar_set_level(self.gcomprisBoard)
Ejemplo n.º 3
0
  def start(self):
    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(300,-1,0.6)
    gcompris.bar_set_level(self.gcomprisBoard)

    #REPEAT ICON
    pixmap = gcompris.utils.load_svg("braille_alphabets/target.svg")
    gcompris.bar_set_repeat_icon(pixmap)
    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
    gcompris.bar_location(300,-1,0.7)

    # 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.root = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())
    #To create a group item for horizontal and vertical text
    self.horizontalTextRoot = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())
    self.verticalTextRoot = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    #Display the sublevel
    gcompris.score.start(gcompris.score.STYLE_NOTE, 530, 460,
                         self.gcomprisBoard.number_of_sublevel)
    gcompris.score.set(self.gcomprisBoard.sublevel)

    # Set a background image
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            "braille_fun/hillside.svg")

    self.display_game(self.gcomprisBoard.level)
Ejemplo n.º 4
0
    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.game_complete = False
        self.rootitem = goocanvas.Group(parent=self.gcomprisBoard.canvas.get_root_item())

        self.background = goocanvas.Image(
            parent=self.rootitem, pixbuf=gcompris.utils.load_pixmap("place_your_satellite/background.jpg"), x=1, y=1
        )

        image = "place_your_satellite/planet" + str(self.gcomprisBoard.level) + ".png"
        self.planet = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap(image),
            x=gcompris.BOARD_WIDTH / 2 - 50 - (self.gcomprisBoard.level * 10),
            y=gcompris.BOARD_HEIGHT / 2 - 50 - (self.gcomprisBoard.level * 10),
        )

        self.instructions(
            _("Click anywhere on the screen to place the satellite " "at a distance from the planet.")
            + "\n"
            + _("Then click on the satellite and drag a line that sets " "the speed of the satellite")
        )
        self.message = Message(self.rootitem, 400, 50, 20)
        self.distanceIndicator = Message(self.rootitem, 400, 480, 5)
        self.satellite = Satellite(self, self.rootitem, self.gcomprisBoard.level)
        self.speed = Speed(self.satellite, self.rootitem)

        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_REPEAT | gcompris.BAR_LEVEL)
        gcompris.bar_location(2, -1, 0.5)
        gcompris.bar_set_level(self.gcomprisBoard)
    def game(self):
        self.game_completed = False

        self.rootitem = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())

        # Set a background image
        gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                                "intro_gravity/background.png")

        # Load planet on the left (saturn) and it's slider
        planet_left = Fixed_planet(self.rootitem, 70, 200, "saturn.png")
        Slider(self.rootitem, self, 20, 200, planet_left)

        # Planet on right (neptune) and it's slider
        planet_right = Fixed_planet(self.rootitem, 680, 200, "neptune.png")
        Slider(self.rootitem, self, 780, 200, planet_right)

        # Load the tux_ship
        self.ship_instance = Spaceship(self, self.rootitem,
                                       gcompris.BOARD_WIDTH / 2.0, 200,
                                       self.gcomprisBoard.level, planet_left,
                                       planet_right)
        # Set the buttons we want in the bar
        gcompris.bar_set(0)
        gcompris.bar_location(2, -1, 0.5)

        # Message button
        self.message = Message(self.rootitem, 400, 320, 20, self.tuto_event)

        self.tuto_step = 0
        self.tutorial(self.tuto_step)
Ejemplo n.º 6
0
  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.game_complete = False
    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    self.background = goocanvas.Image(
      parent = self.rootitem,
      pixbuf = gcompris.utils.load_pixmap(
              "place_your_satellite/background.jpg"),
      x = 1,
      y = 1)

    image = "place_your_satellite/planet" + str(self.gcomprisBoard.level) +\
            ".png"
    self.planet = goocanvas.Image(
      parent = self.rootitem,
      pixbuf = gcompris.utils.load_pixmap(image),
      x = gcompris.BOARD_WIDTH/2 - 50 - (self.gcomprisBoard.level * 10),
      y = gcompris.BOARD_HEIGHT/2 - 50 - (self.gcomprisBoard.level * 10))

    self.instructions()
    self.satellite = Satellite(self, self.rootitem, self.gcomprisBoard.level)
    self.speed = Speed(self.satellite, self.rootitem)

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_REPEAT | gcompris.BAR_LEVEL)
    gcompris.bar_location(2,-1,0.5)
    gcompris.bar_set_level(self.gcomprisBoard)
Ejemplo n.º 7
0
  def game(self):
    self.game_completed = False

    self.rootitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())

    # Set a background image
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                           "intro_gravity/background.png")

    # Load planet on the left (saturn) and it's slider
    planet_left = Fixed_planet(self.rootitem,
                                    70, 200, "saturn.png")
    Slider(self.rootitem, self, 20, 200, planet_left)

    # Planet on right (neptune) and it's slider
    planet_right = Fixed_planet(self.rootitem,
                                     680, 200, "neptune.png")
    Slider(self.rootitem, self, 780, 200, planet_right)

    # Load the tux_ship
    self.ship_instance = Spaceship(self, self.rootitem,
                              gcompris.BOARD_WIDTH/2.0, 200,
                              self.gcomprisBoard.level,
                              planet_left,
                              planet_right)
    # Set the buttons we want in the bar
    gcompris.bar_set(0)
    gcompris.bar_location(2,-1,0.5)

    # Message button
    self.message = Message(self.rootitem, 400, 320, 20, self.tuto_event)

    self.tuto_step = 0
    self.tutorial(self.tuto_step)
Ejemplo n.º 8
0
  def start(self):
    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    #Boolean variable declaration
    self.mapActive = False

    #CONSTANT Declarations
    self.board_paused = 0
    self.timerAnim = 0
    self.counter = 0
    self.gamewon = 0
    self.score_player_a = 0
    self.score_player_b = 0
    self.tile_counter = 0
    self.rectangle_counter = 0

    #REPEAT ICON
    pixmap = gcompris.utils.load_svg("braille_alphabets/target.svg")
    gcompris.bar_set_repeat_icon(pixmap)
    gcompris.bar_set(gcompris.BAR_REPEAT_ICON)
    gcompris.bar_location(320,-1,0.8)

    # 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.root = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    self.lotto_board()
Ejemplo n.º 9
0
  def start(self):

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(300,-1,0.8)
    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    #Boolean variable declaration
    self.mapActive = False

    #REPEAT ICON
    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
    # automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())
    gcompris.bar_set_level(self.gcomprisBoard)


    #Display title of activity
    goocanvas.Text(parent = self.rootitem,
                   x=400.0,
                   y=100.0,
                   text=_("Dicey - Dicey"),
                   fill_color="black",
                   anchor = gtk.ANCHOR_CENTER,
                   alignment = pango.ALIGN_CENTER,
                   font = 'SANS 20'
                   )
    self.display_function(self.gcomprisBoard.level)
Ejemplo n.º 10
0
    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)

        self.wordlist = gcompris.get_wordlist("wordsgame/default-$LOCALE.xml")
        if not self.wordlist:
            # Fallback to english
            self.wordlist = gcompris.get_wordlist("wordsgame/default-en.xml")

        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()
Ejemplo n.º 11
0
    def start(self):
        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(275, -1, 0.8)

        self.saved_policy = gcompris.sound.policy_get()
        gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)
        gcompris.sound.pause()
        # Set a background image
        gcompris.set_default_background(
            self.gcomprisBoard.canvas.get_root_item())

        # 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_level(self.gcomprisBoard.level)

        if not (gcompris.get_properties().fx):
            gcompris.utils.dialog(
                _("Error: This activity cannot be \
played with the\nsound effects disabled.\nGo to the configuration \
dialogue to\nenable the sound."), None)
Ejemplo n.º 12
0
    def start(self):
        self.board_paused = False
        self.game_start = False
        # 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())
        land_rootitem = goocanvas.Group(parent=self.rootitem)

        # Set a background image
        level = str(self.gcomprisBoard.level)
        image = 'land_safe/background' + level + '.jpg'
        gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                                image)

        #Set the land
        image = 'land_safe/land' + str(level) + '.png'
        pixbuf = gcompris.utils.load_pixmap(image)
        land = goocanvas.Image(parent=land_rootitem,
                               pixbuf=pixbuf,
                               x=-550,
                               y=gcompris.BOARD_HEIGHT - 125)
        land.lower(None)

        # Text for Gravity
        gravity = str(0.58 * self.gcomprisBoard.level)
        text = _('Gravity: %s') % (gravity)
        gravity_text = goocanvas.Text(parent=self.rootitem,
                                      x=760,
                                      y=50,
                                      fill_color="white",
                                      anchor=gtk.ANCHOR_E,
                                      alignment=pango.ALIGN_CENTER,
                                      text=_(text))
        bounds = gravity_text.get_bounds()
        gap = 20

        gravity_back = goocanvas.Rect(parent=self.rootitem,
                                      radius_x=6,
                                      radius_y=6,
                                      x=bounds.x1 - gap,
                                      y=bounds.y1 - gap,
                                      width=bounds.x2 - bounds.x1 + gap * 2,
                                      height=bounds.y2 - bounds.y1 + gap * 2,
                                      stroke_color_rgba=0xFFFFFFFFL,
                                      fill_color_rgba=0xCCCCCC44L)

        # Load spaceship
        self.space_ship = Spaceship(self, self.rootitem, land_rootitem,
                                    self.gcomprisBoard.level)

        gcompris.bar_set_level(self.gcomprisBoard)

        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_location(2, -1, 0.5)

        self.ready_button(self.rootitem)
Ejemplo n.º 13
0
    def start(self):
        self.board_paused = False
        self.game_start = False
        # 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())
        land_rootitem = goocanvas.Group(parent=self.rootitem)

        # Set a background image
        level = str(self.gcomprisBoard.level)
        image = "land_safe/background" + level + ".jpg"
        gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(), image)

        # Set the land
        image = "land_safe/land" + str(level) + ".png"
        pixbuf = gcompris.utils.load_pixmap(image)
        land = goocanvas.Image(parent=land_rootitem, pixbuf=pixbuf, x=-550, y=gcompris.BOARD_HEIGHT - 125)
        land.lower(None)

        # Text for Gravity
        gravity = str(0.58 * self.gcomprisBoard.level)
        text = _("Gravity: %s") % (gravity)
        gravity_text = goocanvas.Text(
            parent=self.rootitem,
            x=760,
            y=50,
            fill_color="white",
            font=gcompris.skin.get_font("gcompris/board/small"),
            anchor=gtk.ANCHOR_E,
            alignment=pango.ALIGN_CENTER,
            text=_(text),
        )
        bounds = gravity_text.get_bounds()
        gap = 20

        gravity_back = goocanvas.Rect(
            parent=self.rootitem,
            radius_x=6,
            radius_y=6,
            x=bounds.x1 - gap,
            y=bounds.y1 - gap,
            width=bounds.x2 - bounds.x1 + gap * 2,
            height=bounds.y2 - bounds.y1 + gap * 2,
            stroke_color_rgba=0xFFFFFFFFL,
            fill_color_rgba=0xCCCCCC44L,
        )

        # Load spaceship
        self.space_ship = Spaceship(self, self.rootitem, land_rootitem, self.gcomprisBoard.level)

        gcompris.bar_set_level(self.gcomprisBoard)

        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_location(2, -1, 0.5)

        self.ready_button(self.rootitem)
Ejemplo n.º 14
0
 def base_setup(self):
   gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(), "encryption/background.jpg")
   gcompris.bar_set(gcompris.BAR_LEVEL)
   gcompris.bar_set_level(self.gcomprisBoard)
   gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
   gcompris.bar_location(630, -1, 0.5)
   p = key_value(self.rootitem, self.VALUE)
   self.display_arrow()
   self.display_images(p.get_pair())
Ejemplo n.º 15
0
  def start(self):

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(-1,-1,0.8)
    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    # 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())

    #set background
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            "dice_area.svg")

    gcompris.score.start(gcompris.score.STYLE_NOTE, 570, 490,
                         self.gcomprisBoard.number_of_sublevel)
    gcompris.bar_set_level(self.gcomprisBoard)
    gcompris.score.set(self.gcomprisBoard.sublevel)

    #Display title of activity
    goocanvas.Text(parent = self.rootitem,
                   x=400.0,
                   y=100.0,
                   text="Dicey - Dicey",
                   fill_color="black",
                   anchor = gtk.ANCHOR_CENTER,
                   alignment = pango.ALIGN_CENTER,
                   font = 'SANS 20'
                   )
    goocanvas.Text(parent = self.rootitem,
                   x=280.0,
                   y=200.0,
                   text="___",
                   anchor = gtk.ANCHOR_CENTER,
                   font='SANS 25')
    goocanvas.Text(parent = self.rootitem,
                   x=520.0,y=200.0,
                   text="=",
                   anchor = gtk.ANCHOR_CENTER,
                   font='SANS 25')
    goocanvas.Text(parent = self.rootitem,
                   x=650.0,y=300.0,
                   text="___",
                   anchor = gtk.ANCHOR_CENTER,
                   font='SANS 25')
    goocanvas.Text(parent = self.rootitem,
                   x=350.0,y=352.0,
                   text="Choose an operator to begin",
                   anchor = gtk.ANCHOR_CENTER,
                   font='SANS 15')
    self.display_function(self.gcomprisBoard.level)
Ejemplo n.º 16
0
  def game(self):
    self.game_completed = False

    self.rootitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())

    # Set a background image
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                           "intro_gravity/background.svg")

    # Load planet on the left (saturn) and it's slider
    planet_left = Fixed_planet(self.rootitem,
                                    70, 200, "saturn.png")
    Slider(self.rootitem, 20, 200, planet_left)

    # Planet on right (neptune) and it's slider
    planet_right = Fixed_planet(self.rootitem,
                                     680, 200, "neptune.png")
    Slider(self.rootitem, 780, 200, planet_right)

    # Load the tux_ship
    self.ship_instance = Spaceship(self, self.rootitem,
                              gcompris.BOARD_WIDTH/2.0, 200,
                              self.gcomprisBoard.level,
                              planet_left,
                              planet_right)
    # Set the buttons we want in the bar
    gcompris.bar_set(0)
    gcompris.bar_location(2,-1,0.5)

    # Ready button
    self.ready_text = goocanvas.Text(
      parent = self.rootitem,
      x = 395,
      y = 100,
      fill_color = "white",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER,
      text = _("I'm ready") )
    self.ready_text.connect('button_press_event', self.ready_event, False)
    bounds = self.ready_text.get_bounds()
    gap = 20

    self.ready_back = goocanvas.Rect(
      parent = self.rootitem,
      radius_x = 6,
      radius_y = 6,
      x = bounds.x1 - gap,
      y = bounds.y1 - gap,
      width = bounds.x2 - bounds.x1 + gap * 2,
      height = bounds.y2 - bounds.y1 + gap * 2,
      stroke_color_rgba = 0xFFFFFFFFL,
      fill_color_rgba = 0xCCCCCC44L)
    gcompris.utils.item_focus_init(self.ready_back, None)
    gcompris.utils.item_focus_init(self.ready_text, self.ready_back)
    self.ready_back.connect('button_press_event', self.ready_event)
Ejemplo n.º 17
0
 def start(self):
   self.gcomprisBoard.level=1
   self.gcomprisBoard.maxlevel=9
   self.gcomprisBoard.sublevel=1
   self.gcomprisBoard.number_of_sublevel=1
   gcompris.bar_set(gcompris.BAR_LEVEL)
   gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
   gcompris.bar_set_level(self.gcomprisBoard)
   gcompris.bar_location(-1, -1, 0.8)
   self.set_level(1)
   self.game_start()
  def start(self):
    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    # 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.root = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())


    #Creating a Red Border
    goocanvas.Rect(
      parent = self.root,
      x = 10,
      y = 10,
      width = 780,
      height = 500,
      stroke_color = "dark red",
      line_width=40)

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(300,-1,0.6)
    gcompris.bar_set_level(self.gcomprisBoard)

    #REPEAT ICON
    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
    gcompris.bar_location(300,-1,0.7)

    goocanvas.Text(
      parent = self.root,
      x=400.0,
      y=50.0,
      text=_("Braille these Objects"),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER,
      font = 'SANS 20'
      )
    goocanvas.Text(
      parent = self.root,
      x=320.0,
      y=100.0,
      text=_("Category : "),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER,
      font = 'SANS 15'
      )
    self.read_data()
    self.display_game(self.gcomprisBoard.level)
Ejemplo n.º 19
0
  def start(self):
    #definition of attributs
    self.MAX=0
    self.gcomprisBoard.level=1
    self.load_activity()
    self.gcomprisBoard.maxlevel = len(self.data_activity)

    #Display and configuration of menu bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_set_level(self.gcomprisBoard)
    gcompris.bar_location(gcompris.BOARD_WIDTH - 160, -1, 0.7)

    #Start of level 1
    self.set_level()
Ejemplo n.º 20
0
    def start(self):
        #definition of attributs
        self.MAX = 0
        self.gcomprisBoard.level = 1
        self.load_activity()
        self.gcomprisBoard.maxlevel = len(self.data_activity)

        #Display and configuration of menu bar
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(gcompris.BOARD_WIDTH - 190, -1, 0.7)

        #Start of level 1
        self.set_level()
Ejemplo n.º 21
0
  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()
Ejemplo n.º 22
0
    def start(self):
        print "lang start"
        self.saved_policy = gcompris.sound.policy_get()
        gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)

        # init config to default values
        self.config_dict = self.init_config()

        print "init self.config_dict :", self.config_dict

        # change configured values
        print "gcompris.get_board_conf() : ", gcompris.get_board_conf()
        self.config_dict.update(gcompris.get_board_conf())

        print "self.config_dict final :", self.config_dict

        if self.config_dict.has_key('locale_sound'):
            gcompris.set_locale(self.config_dict['locale_sound'])

        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL | gcompris.BAR_REPEAT
                         | gcompris.BAR_CONFIG)
        gcompris.bar_location(gcompris.BOARD_WIDTH / 2 - 100, -1, 0.6)

        # Set a background image
        gcompris.set_default_background(
            self.gcomprisBoard.canvas.get_root_item())

        # 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.langLib = LangLib(gcompris.DATA_DIR + "/lang/lang.xml")
        self.chapters = self.langLib.getChapters()
        # FIXME Do not manage Chapter yet
        self.currentChapterId = 0

        # Manage levels (a level is a lesson in the lang model)
        self.gcomprisBoard.level = 1
        self.gcomprisBoard.maxlevel = \
            len ( self.chapters.getChapters()[self.currentChapterId].getLessons() )
        gcompris.bar_set_level(self.gcomprisBoard)

        self.currentExercise = None
        self.currentLesson = self.langLib.getLesson(
            self.currentChapterId, self.gcomprisBoard.level - 1)
        self.displayLesson(self.currentLesson)
  def start(self):
    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_set_level(self.gcomprisBoard)

    pixmap = gcompris.utils.load_svg("braille_alphabets/target.svg")
    gcompris.bar_set_repeat_icon(pixmap)
    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
    gcompris.bar_location(20, -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
    # automaticaly.

    self.rootitem = goocanvas.Group(parent=
                                   self.gcomprisBoard.canvas.get_root_item())
    self.board_upper(self.gcomprisBoard.level)
Ejemplo n.º 24
0
  def start(self):

    self.gcomprisBoard.level=1
    self.gcomprisBoard.maxlevel=4
    self.gcomprisBoard.sublevel=1
    self.gcomprisBoard.number_of_sublevel=1

    gcompris.bar_set(gcompris.BAR_LEVEL)

    gcompris.bar_set_level(self.gcomprisBoard)
    gcompris.bar_location(gcompris.BOARD_WIDTH - 160, -1, 0.7)

    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            "guessnumber/cave.png")

    self.display_game()
Ejemplo n.º 25
0
  def start(self):
    print "lang start"
    self.saved_policy = gcompris.sound.policy_get()
    gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)

    # init config to default values
    self.config_dict = self.init_config()

    print "init self.config_dict :", self.config_dict

    # change configured values
    print "gcompris.get_board_conf() : ", gcompris.get_board_conf()
    self.config_dict.update(gcompris.get_board_conf())

    print "self.config_dict final :", self.config_dict

    if self.config_dict.has_key('locale_sound'):
      gcompris.set_locale(self.config_dict['locale_sound'])

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT|gcompris.BAR_CONFIG)
    gcompris.bar_location(gcompris.BOARD_WIDTH / 2 - 100, -1, 0.6)

    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    # 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.langLib = LangLib(gcompris.DATA_DIR + "/lang/lang.xml")
    self.chapters = self.langLib.getChapters()
    # FIXME Do not manage Chapter yet
    self.currentChapterId = 0

    # Manage levels (a level is a lesson in the lang model)
    self.gcomprisBoard.level = 1
    self.gcomprisBoard.maxlevel = \
        len ( self.chapters.getChapters()[self.currentChapterId].getLessons() )
    gcompris.bar_set_level(self.gcomprisBoard)

    self.currentExercise = None
    self.currentLesson = self.langLib.getLesson(self.currentChapterId,
                                                self.gcomprisBoard.level - 1)
    self.displayLesson( self.currentLesson )
Ejemplo n.º 26
0
  def start(self):
    self.lost = False
    gcompris.bar_set_level(self.gcomprisBoard)

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(2, -1, 0.5)

    # 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())

    # Set a background image
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            'color_mix/background.jpg')

    text = goocanvas.Text(
      parent = self.rootitem,
      x = 250,
      y = 80,
      fill_color = "black",
      font = gcompris.skin.get_font("gcompris/subtitle"),
      anchor = gtk.ANCHOR_CENTER,
      width = 150,
      alignment = pango.ALIGN_CENTER,
      text = _("Match the color "))

    # Set the points for the sliders
    c_points = goocanvas.Points( [(242, 210), (130, 175)] )
    m_points = goocanvas.Points( [(390, 352), (390, 470)] )
    y_points = goocanvas.Points( [(548, 208), (665, 175)] )

    colors = Colors(self, self.rootitem, self.gcomprisBoard.level, 255)

    # Pass the points of the buttons and slider for the color tubes
    color1_tube = Color_tubes(self.rootitem, colors, 'cyan_tube.png',
                              1, 80, 120, c_points, 242, 210, 130, 175,
                              self.gcomprisBoard.level, -1)
    color2_tube = Color_tubes(self.rootitem, colors, 'magenta_tube.png',
                              2, 350, 290, m_points, 390, 352, 390, 470,
                              self.gcomprisBoard.level, -1)
    color3_tube = Color_tubes(self.rootitem, colors, 'yellow_tube.png',
                              3, 460, 120, y_points, 548, 208, 665, 175,
                              self.gcomprisBoard.level, -1)
Ejemplo n.º 27
0
  def start(self):
    self.lost = False
    gcompris.bar_set_level(self.gcomprisBoard)

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(2, -1, 0.5)

    # 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())

    # Set a background image
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            'color_mix/background.jpg')

    text = goocanvas.Text(
      parent = self.rootitem,
      x = 250,
      y = 80,
      fill_color = "black",
      font = gcompris.skin.get_font("gcompris/subtitle"),
      anchor = gtk.ANCHOR_CENTER,
      width = 150,
      alignment = pango.ALIGN_CENTER,
      text = _("Match the color"))

    # Set the points for the sliders
    c_points = goocanvas.Points( [(242, 210), (130, 175)] )
    m_points = goocanvas.Points( [(390, 352), (390, 470)] )
    y_points = goocanvas.Points( [(548, 208), (665, 175)] )

    colors = Colors(self, self.rootitem, self.gcomprisBoard.level, 255)

    # Pass the points of the buttons and slider for the color tubes
    color1_tube = Color_tubes(self.rootitem, colors, 'cyan_tube.png',
                              1, 80, 120, c_points, 242, 210, 130, 175,
                              self.gcomprisBoard.level, -1)
    color2_tube = Color_tubes(self.rootitem, colors, 'magenta_tube.png',
                              2, 350, 290, m_points, 390, 352, 390, 470,
                              self.gcomprisBoard.level, -1)
    color3_tube = Color_tubes(self.rootitem, colors, 'yellow_tube.png',
                              3, 460, 120, y_points, 548, 208, 665, 175,
                              self.gcomprisBoard.level, -1)
Ejemplo n.º 28
0
  def start_explorer(self):

    if (self.gcomprisBoard.level == 1):
      self.context = self.EXTERNAL
    else:
      self.context = self.INTERNAL

    gcompris.bar_location(630, -1, 0.5)

    ok = goocanvas.Svg(parent = self.rootitem,
                       svg_handle = gcompris.skin.svg_get(),
                       svg_id = "#OK",
                       tooltip = _("Next")
                       )
    ok.translate(150, -50)
    ok.connect("button_press_event", self.next_level_click)
    gcompris.utils.item_focus_init(ok, None)

    # Border around the TextView
    self.border = goocanvas.Rect(parent = self.rootitem,
                   x = 20,
                   y = 390,
                   width = 600,
                   height = 110,
                   stroke_color = "blue",
                   line_width = 2.0
                   )

    # Create a TextView with some text in it
    self.desc_tb = gtk.TextBuffer()
    self.desc_tv = gtk.TextView(self.desc_tb)
    self.desc_tv.set_editable(False)
    self.desc_tb.set_text(_("Mouse-over any part"))
    self.desc_tv.set_wrap_mode(gtk.WRAP_CHAR)

    self.widget = goocanvas.Widget(parent = self.rootitem,
                                   widget = self.desc_tv,
                                   x = 30,
                                   y = 400,
                                   width = 580,
                                   height = 100,
                                   anchor = gtk.ANCHOR_NW,
                                   )

    self.header()
    self.render_parts()
Ejemplo n.º 29
0
    def start(self):
        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_set_level(self.gcomprisBoard)

        pixmap = gcompris.utils.load_svg("braille_alphabets/target.svg")
        gcompris.bar_set_repeat_icon(pixmap)
        gcompris.bar_set(gcompris.BAR_LEVEL | gcompris.BAR_REPEAT_ICON)
        gcompris.bar_location(20, -1, 0.6)

        # The root item for the help
        self.map_rootitem = \
            goocanvas.Group( parent = self.gcomprisBoard.canvas.get_root_item() )
        BrailleMap(self.map_rootitem, self.move_back)
        self.map_rootitem.props.visibility = goocanvas.ITEM_INVISIBLE

        self.rootitem = None
        self.display_level(self.gcomprisBoard.level)
Ejemplo n.º 30
0
  def start(self):
    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_set_level(self.gcomprisBoard)

    pixmap = gcompris.utils.load_svg("braille_alphabets/target.svg")
    gcompris.bar_set_repeat_icon(pixmap)
    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT_ICON)
    gcompris.bar_location(20, -1, 0.6)

    # The root item for the help
    self.map_rootitem = \
        goocanvas.Group( parent = self.gcomprisBoard.canvas.get_root_item() )
    BrailleMap(self.map_rootitem, self.move_back)
    self.map_rootitem.props.visibility = goocanvas.ITEM_INVISIBLE

    self.rootitem = None
    self.display_level(self.gcomprisBoard.level)
Ejemplo n.º 31
0
  def start(self):
    gcompris.bar_set_level(self.gcomprisBoard)

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(2, -1, 0.5)

    # 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())

    # Set a background image
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            'color_mix/background.jpg')

    text = goocanvas.Text(
      parent = self.rootitem,
      x = 250,
      y = 80,
      fill_color = "black",
      font = gcompris.skin.get_font("gcompris/subtitle"),
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER,
      text = _("Match the \n color "))

    # Set the points for the sliders
    r_points = goocanvas.Points( [(242, 212), (130, 177)] )
    b_points = goocanvas.Points( [(548, 213), (665, 177)] )
    m_points = goocanvas.Points( [(390, 372), (390, 490)] )

    colors = Colors(self, self.rootitem, self.gcomprisBoard.level, 0)

    # Pass the points of the buttons and slider for the color tubes
    red_tube = Color_tubes(self.rootitem, colors, 'torch_red.png',
                           1, 90, 115, r_points, 232, 210, 120, 175,
                           self.gcomprisBoard.level, 1)
    green_tube = Color_tubes(self.rootitem, colors, 'torch_green.png',
                             2, 265, 265, m_points, 390, 372, 390, 490,
                             self.gcomprisBoard.level, 1)
    blue_tube = Color_tubes(self.rootitem, colors, 'torch_blue.png',
                            3, 462, 115, b_points, 554, 210, 672, 175,
                            self.gcomprisBoard.level, 1)
Ejemplo n.º 32
0
  def start(self):
    self.gcomprisBoard.level=1
    self.gcomprisBoard.maxlevel=4
    self.gcomprisBoard.sublevel=1
    self.gcomprisBoard.number_of_sublevel=1

    self.board_paused = False

    # 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())

    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    self.display_sea_area()

    self.root_weather_item = goocanvas.Group(parent = self.rootitem)

    # Display the weather now
    self.display_weather()

    # And finaly the players boats
    self.init_boats()

    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT);


    # The OK Button
    item = goocanvas.Svg(parent = self.rootitem,
                         svg_handle = gcompris.skin.svg_get(),
                         svg_id = "#OK"
                         )
    zoom = 0.7
    item.translate( (item.get_bounds().x1 * -1)
                     + ( gcompris.BOARD_WIDTH / 2 + 25 ) / zoom,
                    (item.get_bounds().y1 * -1)
                     + (gcompris.BOARD_HEIGHT - 125) / zoom )
    item.scale(zoom, zoom)
    item.connect("button_press_event", self.ok_event)
    gcompris.utils.item_focus_init(item, None)

    gcompris.bar_set_level(self.gcomprisBoard)
    gcompris.bar_location(gcompris.BOARD_WIDTH/2 - 90, -1, 0.6)
Ejemplo n.º 33
0
    def display_level(self, level):
        self.score = 0
        if hasattr(self, 'staff'):
            self.staff.clear()
            self.staff.eraseAllNotes()
        drawBasicPlayHomePagePart1(self)

        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(20, -1, 0.6)

        if level <= 6:
            self.staff = TrebleStaff(100, 80, self.rootitem, numStaves=1)
            self.staff.noteSpacingX = 32
        else:
            self.staff = BassStaff(100, 90, self.rootitem, numStaves=1)
            self.staff.noteSpacingX = 28

        self.staff.endx = 200

        if level not in [6, 12]:
            self.colorCodeNotesButton = textButton(100, 215, _("Color code notes?"), self, 'green')

            self.colorCodeNotesButton.connect("button_press_event", self.color_code_notes)
            gcompris.utils.item_focus_init(self.colorCodeNotesButton, None)
        else:
            self.staff.colorCodeNotes = False

        self.staff.drawStaff()
        self.staff.rootitem.scale(2.0, 2.0)

        self.givenOption = []
        self.show_melody()
        self.kidsNoteList = []
        self.piano = PianoKeyboard(250, 300, self.rootitem)
        if level in [4, 5, 6, 12, 11, 10]:
            self.piano.blackKeys = True

        self.piano.draw(300, 175, self.keyboard_click)

        textBox(_("Click the piano keys that match the written notes."), 388, 60, self, fill_color='gray', width=200)

        drawBasicPlayHomePagePart2(self)
Ejemplo n.º 34
0
    def start(self):
        self.gcomprisBoard.level = 1
        self.gcomprisBoard.maxlevel = 4
        self.gcomprisBoard.sublevel = 1
        self.gcomprisBoard.number_of_sublevel = 1

        self.board_paused = False

        # 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())

        gcompris.set_default_background(
            self.gcomprisBoard.canvas.get_root_item())

        self.display_sea_area()

        self.root_weather_item = goocanvas.Group(parent=self.rootitem)

        # Display the weather now
        self.display_weather()

        # And finaly the players boats
        self.init_boats()

        gcompris.bar_set(gcompris.BAR_LEVEL | gcompris.BAR_REPEAT)

        # The OK Button
        item = goocanvas.Svg(parent=self.rootitem,
                             svg_handle=gcompris.skin.svg_get(),
                             svg_id="#OK")
        zoom = 0.7
        item.translate(
            (item.get_bounds().x1 * -1) +
            (gcompris.BOARD_WIDTH / 2 + 25) / zoom,
            (item.get_bounds().y1 * -1) + (gcompris.BOARD_HEIGHT - 135) / zoom)
        item.scale(zoom, zoom)
        item.connect("button_press_event", self.ok_event)
        gcompris.utils.item_focus_init(item, None)

        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(gcompris.BOARD_WIDTH / 2 - 105, -1, 0.6)
Ejemplo n.º 35
0
  def start(self):
    print "computer_simulation start"

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)

    gcompris.bar_set_level(self.gcomprisBoard)

    gcompris.bar_location(gcompris.BOARD_WIDTH - 190, -1, 0.7)

    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    # 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()
Ejemplo n.º 36
0
    def start(self):
        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(275, -1, 1)

        self.saved_policy = gcompris.sound.policy_get()
        gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)
        gcompris.sound.pause()

        # Set a background image
        gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

        # 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_level(self.gcomprisBoard.level)
Ejemplo n.º 37
0
    def start(self):
        print "computer_simulation start"

        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL)

        gcompris.bar_set_level(self.gcomprisBoard)

        gcompris.bar_location(gcompris.BOARD_WIDTH - 190, -1, 0.7)

        # Set a background image
        gcompris.set_default_background(
            self.gcomprisBoard.canvas.get_root_item())

        # 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()
Ejemplo n.º 38
0
  def start(self):

    # GCompris initialisation
    self.gcomprisBoard.level=1
    self.gcomprisBoard.maxlevel=1
    self.gcomprisBoard.sublevel=0
    self.gcomprisBoard.number_of_sublevel=0

    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    # 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.doc = Document(self)

    # initialisation
    self.draw_tools()
    self.draw_animtools()

    self.doc.timeline.draw()
    if self.gcomprisBoard.mode == 'draw':
      self.doc.timeline.hide()

    self.color_rootitem = goocanvas.Group(
      parent =  self.gcomprisBoard.canvas.get_root_item())
    self.color = Color(self.color_rootitem, self.drawing_area)
    self.color.draw()

    self.draw_drawing_area()
    self.draw_playing_area()

    gcompris.bar_set(gcompris.BAR_JOURNAL)
    gcompris.bar_location(10, -1, 0.6)

    if gcompris.sugar_detected():
      journal_file = gcompris.sugar_load()
      if journal_file:
        fles.doc.file_to_anim(journal_file)
Ejemplo n.º 39
0
    def start(self):
        self.reseted = False
        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_location(300, -1, 0.6)
        gcompris.bar_set_level(self.gcomprisBoard)

        #REPEAT ICON
        pixmap = gcompris.utils.load_svg("braille_alphabets/target.svg")
        gcompris.bar_set_repeat_icon(pixmap)
        gcompris.bar_set(gcompris.BAR_LEVEL | gcompris.BAR_REPEAT_ICON)
        gcompris.bar_location(300, -1, 0.7)

        # 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.root = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())
        #To create a group item for horizontal and vertical text
        self.horizontalTextRoot = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())
        self.verticalTextRoot = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())

        # The root item for the help
        self.map_rootitem = \
            goocanvas.Group( parent = self.gcomprisBoard.canvas.get_root_item() )
        BrailleMap(self.map_rootitem, self.move_back)
        self.map_rootitem.props.visibility = goocanvas.ITEM_INVISIBLE

        # Display the sublevel
        gcompris.score.start(gcompris.score.STYLE_NOTE, 530, 460,
                             self.gcomprisBoard.number_of_sublevel)

        # Set a background image
        gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                                "braille_fun/hillside.svg")

        self.display_game(self.gcomprisBoard.level)
Ejemplo n.º 40
0
  def display_game(self):
    gcompris.bar_location(gcompris.BOARD_WIDTH - 120, -1, 0.8)

    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    n_lines = 11
    self.reordering = Reordering(self, n_lines)

    # Insert the lines in the correct order
    for index in range(n_lines):
      self.reordering.add_line( _(str(self.dataset.get(str(index + 1),
                                                       "story"))) )

      ok = goocanvas.Svg(parent = self.rootitem,
                         svg_handle = gcompris.skin.svg_get(),
                         svg_id = "#OK",
                         tooltip = _("Click to confirm your sequence")
                         )
      ok.translate(200,-70)
      ok.connect("button_press_event", self.ok_event)
      gcompris.utils.item_focus_init(ok, None)
    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.game_complete = False
        self.rootitem = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())

        self.background = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap(
                "place_your_satellite/background.jpg"),
            x=1,
            y=1)

        image = "place_your_satellite/planet" + str(self.gcomprisBoard.level) +\
                ".png"
        self.planet = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap(image),
            x=gcompris.BOARD_WIDTH / 2 - 50 - (self.gcomprisBoard.level * 10),
            y=gcompris.BOARD_HEIGHT / 2 - 50 - (self.gcomprisBoard.level * 10))

        self.instructions(
            _('Click anywhere on the screen to place the satellite '
              'at a distance from the planet.') + "\n" +
            _('Then click on the satellite and drag a line that sets '
              'the speed of the satellite'))
        self.message = Message(self.rootitem, 400, 50, 20)
        self.distanceIndicator = Message(self.rootitem, 400, 480, 5)
        self.satellite = Satellite(self, self.rootitem,
                                   self.gcomprisBoard.level)
        self.speed = Speed(self.satellite, self.rootitem)

        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_REPEAT | gcompris.BAR_LEVEL)
        gcompris.bar_location(2, -1, 0.5)
        gcompris.bar_set_level(self.gcomprisBoard)
Ejemplo n.º 42
0
  def start(self):
    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(300,-1,0.6)
    gcompris.bar_set_level(self.gcomprisBoard)

    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            "rhymes_riddles/riddle.jpg")
    gcompris.set_cursor(gcompris.CURSOR_SELECT)

    #REPEAT ICON
    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
    # automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    self.display_game(self.gcomprisBoard.level)
Ejemplo n.º 43
0
  def start(self):
    # load pixmaps for the ui.
    #
    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT)
    gcompris.bar_set_level(self.gcomprisBoard)
    gcompris.bar_location(10, -1, 0.7)

    # Create persistent over levels root item canvas for the board
    self.rootitem_p = goocanvas.Group(
      parent = self.gcomprisBoard.canvas.get_root_item()
      )

    self.profbutton = self.prof_button(self,
                                       self.rootitem_p,
                                       profs[self.gcomprisBoard.level - 1])

    self.answer = self.answer_button(self.rootitem_p,
                                     self.scales[self.gcomprisBoard.sublevel-1],
                                     self.pixmap_green_ball,
                                     self.number_balls[self.gcomprisBoard.sublevel-1])

    #
    self.newGame()
Ejemplo n.º 44
0
    def start(self):
        # Set a background image
        gcompris.set_default_background(
            self.gcomprisBoard.canvas.get_root_item())

        #Boolean variable declaration
        self.mapActive = False

        #CONSTANT Declarations
        self.board_paused = 0
        self.timerAnim = 0
        self.counter = 0
        self.gamewon = 0
        self.score_player_a = 0
        self.score_player_b = 0
        self.tile_counter = 0
        self.rectangle_counter = 0

        #REPEAT ICON
        pixmap = gcompris.utils.load_svg("braille_alphabets/target.svg")
        gcompris.bar_set_repeat_icon(pixmap)
        gcompris.bar_set(gcompris.BAR_REPEAT_ICON)
        gcompris.bar_location(320, -1, 0.8)

        # 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.root = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())

        self.lotto_board()

        # The root item for the help
        self.map_rootitem = \
            goocanvas.Group( parent = self.gcomprisBoard.canvas.get_root_item() )
        BrailleMap(self.map_rootitem, self.move_back)
        self.map_rootitem.props.visibility = goocanvas.ITEM_INVISIBLE
Ejemplo n.º 45
0
    def start(self):
        """ Load data and start the activity """

        self.gcomprisBoard.maxlevel = 3
        self.gcomprisBoard.sublevel = 1
        self.gcomprisBoard.number_of_sublevel = 1

        # Set the buttons we want in the bar.
        # We need to set BAR_LEVEL, in order to see the "help" icon!?!
        gcompris.bar_set(gcompris.BAR_LEVEL)

        gcompris.bar_location(0, -1, 0.8)

        # Setup a nugget-blocking-area for the GCompris bar, to avoid placing the nugget behind
        # the bar.
        # The bar is in the lower, left corner of the screen with dimensions: width = 196; height = 50
        self.gc_bar_blocker = BlockingArea(0, 470, 196, 520)

        # 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
        # automatically.
        self.rootitem = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())
        self.rootitem.connect("button_press_event", self.on_button_press)
        self.rootitem.connect("motion_notify_event", self.on_mouse_move)

        svghandle = gcompris.utils.load_svg("mining/rockwall.svgz")

        self.viewport = Viewport(self, self.rootitem)

        rockwall_img = goocanvas.Svg(parent=self.viewport.get_gc_group(),
                                     svg_handle=svghandle,
                                     svg_id="#BACKGROUND")

        # the further zoom logic highly depends on the following conditions
        assert (gcompris.BOARD_WIDTH == (rockwall_img.get_bounds().x2 /
                                         self.source_image_scale))
        assert (gcompris.BOARD_HEIGHT == (rockwall_img.get_bounds().y2 /
                                          self.source_image_scale))

        self.lorry = Lorry(svghandle, self.rootitem)

        self.placer = Placer(self)

        self.decorations = Decorations(svghandle, self.viewport.get_gc_group(),
                                       self.placer)

        self.nugget = Nugget(svghandle, self.viewport.get_gc_group())

        # create sparkling last, so it is on above the nugget
        self.sparkling = Sparkling(svghandle, self.viewport.get_gc_group())

        # prepare the tutorial
        self.tutorial = mining_tutorial.MiningTutorial(self.rootitem)

        # prepare the teacher icon to start the tutorial with
        self.teacher_img = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap("mining/tux-teacher.png"),
            x=850,
            y=850,
            visibility=goocanvas.ITEM_INVISIBLE)
        self.teacher_img.scale(0.5, 0.5)
        self.teacher_img.connect("button_press_event", self.start_tutorial)
        gcompris.utils.item_focus_init(self.teacher_img, None)

        # initialize the level, to start with
        self.set_level(1)
Ejemplo n.º 46
0
    def display_level(self, x=None, y=None, z=None):

        # Create a rootitem.
        if hasattr(self, 'rootitem'):
            self.rootitem.remove()
        self.rootitem = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())

        # silence any currently playing music
        if not self.first_run:
            gcompris.sound.play_ogg('boards/sounds/silence1s.ogg')
            self.first_run = False

        level = self.gcomprisBoard.level

        # set the game bar in the bottom left
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(20, -1, 0.6)

        self.locationSeen = 0

        # -------------------------------------------------------------
        # Load Background Image
        # -------------------------------------------------------------
        if not hasattr(self, 'data'):
            self.read_data()  # read in the data from content.desktop.in file

        # only allow second level if content file has the tag 'SoundMatchingGameText'
        if hasattr(self, 'SoundMatchingGameText'):
            self.gcomprisBoard.maxlevel = 3

        self.map = goocanvas.Image(
            parent=self.rootitem,
            x=self.backgroundx,
            y=self.backgroundy,
            pixbuf=gcompris.utils.load_pixmap(self.activityDataFilePath +
                                              self.background))

        if RECORD_LOCATIONS:
            self.recordLocationsForDeveloper()
        else:

            self.drawLocations()

            if level == 1:
                self.writeText(self.generalText)
            else:
                # prepare game for play
                self.progressBar = ProgressBar(self.rootitem, 200, 480, 400,
                                               25,
                                               len(self.data.sections()) - 1)

                if level == 2 and self.gcomprisBoard.maxlevel == 3:

                    self.remainingItems = self.allSoundClips[:]
                    self.writeText(self.SoundMatchingGameText)
                    # PLAY BUTTON
                    self.playButton = goocanvas.Image(
                        parent=self.rootitem,
                        pixbuf=gcompris.utils.load_pixmap(
                            'explore/playbutton.png'),
                        x=65,
                        y=110,
                    )
                    self.playButton.connect("button_press_event",
                                            self.playCurrentMusicSelection)
                    self.writeText(_('Click to play sound'), 100, 70)
                    gcompris.utils.item_focus_init(self.playButton, None)
                    self.playRandom()
                elif level == 3 or level == 2:

                    self.remainingItems = self.allTextPrompts[:]
                    self.writeText(self.TextMatchingGameText)
                    self.playRandom()
Ejemplo n.º 47
0
    def display_level(self, level):
        self.score = 0
        if hasattr(self, 'staff'):
            self.staff.clear()
            self.staff.eraseAllNotes()

        if self.rootitem:
            self.rootitem.remove()

        self.rootitem = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())

        # set background
        goocanvas.Image(parent=self.rootitem,
                        x=0,
                        y=0,
                        pixbuf=gcompris.utils.load_pixmap(
                            'piano_composition/playActivities/background/' +
                            str(level % 6 + 1) + '.jpg'))

        if hasattr(self, 'staff'):
            self.staff.clear()

        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(20, -1, 0.6)

        if level <= 6:
            self.staff = TrebleStaff(100, 80, self.rootitem, numStaves=1)
            self.staff.noteSpacingX = 32
        else:
            self.staff = BassStaff(100, 90, self.rootitem, numStaves=1)
            self.staff.noteSpacingX = 28

        self.staff.endx = 200

        if level not in [6, 12]:
            colorCodeNotesButton = TextButton(100, 215, _("Color code notes?"),
                                              self.rootitem, 0x990011FFL, 180)

            colorCodeNotesButton.getBackground().connect(
                "button_press_event", self.color_code_notes)
        else:
            self.staff.colorCodeNotes = False

        self.staff.drawStaff()
        self.staff.rootitem.scale(2.0, 2.0)

        self.givenOption = []
        if not self.first_run:
            self.show_melody()
        self.kidsNoteList = []
        self.piano = PianoKeyboard(250, 305, self.rootitem)
        if level in [4, 5, 6, 12, 11, 10]:
            self.piano.blackKeys = True

        self.piano.draw(300, 175, self.keyboard_click)

        textBox(_("Click the piano keys that match the written notes."),
                388,
                60,
                self.rootitem,
                fill_color_rgba=0x999999AAL,
                width=200)

        bx = 600
        by = 340

        goocanvas.Rect(parent=self.rootitem,
                       x=bx - 10,
                       y=by - 8,
                       width=120,
                       height=63,
                       stroke_color="black",
                       fill_color_rgba=0x33333399L,
                       line_width=2.0,
                       radius_x=3,
                       radius_y=3)

        # PLAY BUTTON
        self.playButton = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap('piano_composition/play.svg'),
            x=bx,
            y=by,
            tooltip="\n\n" + _('Play'))
        self.playButton.connect("button_press_event",
                                self.staff.playComposition)

        gcompris.utils.item_focus_init(self.playButton, None)

        # ERASE BUTTON
        self.eraseButton = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap(
                'piano_composition/edit-clear.svg'),
            x=bx + 50,
            y=by,
            tooltip="\n\n" + _("Erase Attempt"))
        self.eraseButton.connect("button_press_event", self.erase_entry)
        gcompris.utils.item_focus_init(self.eraseButton, None)
        self.show_erase(False)
Ejemplo n.º 48
0
    def start(self):
        self.boardSize = 490.0
        self.nbColumns = 7
        self.nbLines = 6
        self.stoneSize = 70.0
        self.maxVictory = 3
        self.maxLevel = 4
        self.boardItem = None
        self.timerAnim = 0
        self.humanVictory = 0
        self.endAnimCallback = None
        self.gcomprisBoard.level = 1
        self.gcomprisBoard.maxlevel = 9
        self.gcomprisBoard.sublevel = 1
        self.gcomprisBoard.number_of_sublevel = 1
        self.mode = (self.gcomprisBoard.mode == "2players") and 2 or 1
        if self.mode == 1:
            board_bar = gcompris.BAR_LEVEL
            gcompris.bar_set_level(self.gcomprisBoard)
        else:
            board_bar = 0
        # 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())

        board_bar = board_bar | gcompris.BAR_REPEAT
        gcompris.bar_set(board_bar)
        gcompris.bar_location(gcompris.BOARD_WIDTH - 230, -1, 0.7)

        selector = \
            goocanvas.Image(
                parent = self.rootitem,
            pixbuf = gcompris.utils.load_pixmap("connect4/back.png"),
            x=0.0,
            y=0.0
            )
        selector.connect("motion_notify_event", self.columnItemEvent, 0)
        selector.connect("button_press_event", self.columnItemEvent, 0)

        if self.mode == 1:
            self.prof = \
                goocanvas.Image(
                    parent = self.rootitem,
                pixbuf = gcompris.utils.load_pixmap("connect4/tux-teacher.png"),
                x=10,
                y=350.0
                )
            self.prof.connect("button_press_event", self.profItemEvent, 0)
            gcompris.utils.item_focus_init(self.prof, None)

        self.timericon = gcompris.anim.CanvasItem(
            gcompris.anim.Animation("connect4/sablier.txt"), self.rootitem)
        self.timericon.goocanvas.props.visibility = goocanvas.ITEM_INVISIBLE

        self.player_stone = None

        for i in range(2):
            goocanvas.Image(parent=self.rootitem,
                            pixbuf=gcompris.utils.load_pixmap(
                                "connect4/stone_%d.png" % (i + 1)),
                            x=25,
                            y=175 + i * 73)
        self.score_item = \
            goocanvas.Text(
                parent = self.rootitem,
                font=gcompris.skin.get_font("gcompris/board/huge bold"),
                x=60,
                y=250,
                anchor = gtk.ANCHOR_CENTER,
                fill_color_rgba=0xFF0000FFL)

        self.update_scores((0, 0))

        self.newGame()
Ejemplo n.º 49
0
    def start(self):
        self.saved_policy = gcompris.sound.policy_get()
        gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)
        gcompris.sound.pause()

        # init config to default values
        self.config_dict = self.init_config()

        # change configured values
        self.config_dict.update(gcompris.get_board_conf())

        if self.config_dict.has_key('locale_sound'):
            gcompris.set_locale(self.config_dict['locale_sound'])

        # Set the buttons we want in the bar
        handle = gcompris.utils.load_svg("lang/repeat.svg")
        gcompris.bar_set_repeat_icon(handle)
        gcompris.bar_set(gcompris.BAR_LEVEL | gcompris.BAR_REPEAT_ICON
                         | gcompris.BAR_CONFIG)
        gcompris.bar_location(gcompris.BOARD_WIDTH / 2 - 100, -1, 0.6)

        # Set a background image
        gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                                "lang/background.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.langLib = LangLib(gcompris.DATA_DIR + "/lang/words.xml")
        self.chapters = self.langLib.getChapters()

        if self.gcomprisBoard.mode == "":
            gcompris.utils.dialog(
                "ERROR, missing 'mode' in the xml menu to specify the chapter",
                None)
            return
        self.currentChapterName = self.gcomprisBoard.mode

        # Manage levels (a level is a lesson in the lang model)
        self.gcomprisBoard.level = 1
        try:
            self.gcomprisBoard.maxlevel = \
                len ( self.chapters.getChapters()[self.currentChapterName].getLessons() )
        except:
            gcompris.utils.dialog(
                "ERROR, missing chapter '" + self.currentChapterName + "'",
                None)
            return

        if self.gcomprisBoard.maxlevel == 0:
            gcompris.utils.dialog(
                _("ERROR, we found no words in this language.") + " " +
                _("Please consider contributing a voice set."), None)
            return

        gcompris.bar_set_level(self.gcomprisBoard)

        self.currentExerciseModes = []
        self.currentExercise = None
        self.currentLesson = self.langLib.getLesson(
            self.currentChapterName, self.gcomprisBoard.level - 1)
        self.displayLesson(self.currentLesson)
        self.pause(0)
Ejemplo n.º 50
0
    def start(self):
        self.gcomprisBoard.level = 1
        self.gcomprisBoard.maxlevel = 9
        self.gcomprisBoard.sublevel = 1
        self.gcomprisBoard.number_of_sublevel = 1
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_location(5, -1, 0.8)

        gcompris.bar_set_level(self.gcomprisBoard)

        self.ballinc = 20  # Event loop timer for the ball move

        # 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())

        svghandle = gcompris.utils.load_svg("penalty/penalty_bg.svgz")
        goocanvas.Svg(parent=self.rootitem,
                      svg_handle=svghandle,
                      svg_id="#BACKGROUND",
                      pointer_events=goocanvas.EVENTS_NONE)

        # Help
        self.help_item = goocanvas.Text(
            parent=self.rootitem,
            font=gcompris.skin.get_font("gcompris/board/medium"),
            x=gcompris.BOARD_WIDTH / 2,
            y=gcompris.BOARD_HEIGHT - 170,
            anchor=gtk.ANCHOR_CENTER,
            fill_color="white")
        self.help_item.props.visibility = goocanvas.ITEM_INVISIBLE

        # Tux
        item = goocanvas.Svg(parent=self.rootitem,
                             svg_handle=svghandle,
                             svg_id="#TUX")
        item.connect("button_press_event", self.help)

        # The activity help
        item = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=svghandle,
            svg_id="#HELP",
        )
        item.connect("button_press_event", self.help)
        # This item is clickeable and it must be seen
        gcompris.utils.item_focus_init(item, None)

        # The click indicator
        indicator_h = 30
        indicator_w = 10
        y_ref = 107

        self.indicator = []
        self.indicator.append(
            Indicator(self.rootitem, gcompris.BOARD_WIDTH / 2 - 350, y_ref,
                      indicator_w, indicator_h, 0, 200))
        self.indicator.append(
            Indicator(self.rootitem, gcompris.BOARD_WIDTH / 2, y_ref - 80,
                      indicator_h, indicator_w, 1, 100))
        self.indicator.append(
            Indicator(self.rootitem, gcompris.BOARD_WIDTH / 2 + 350, y_ref,
                      indicator_w, indicator_h, 2, 200))

        self.balloon = Balloon(self, svghandle, 10, 10)
        self.balloon.item.connect("button_press_event", self.shoot_item_event)

        self.next_level()
Ejemplo n.º 51
0
    def display_level(self, level):

        self.recordedHits = []

        if self.updateTimer:
            gobject.source_remove(self.updateTimer)
            self.updateTimer = 0

        if hasattr(self, 'staff'):
            self.staff.clear()

        if self.rootitem:
            self.rootitem.remove()

        self.rootitem = goocanvas.Group(
            parent=self.gcomprisBoard.canvas.get_root_item())

        # set background
        goocanvas.Image(parent=self.rootitem,
                        x=0,
                        y=0,
                        pixbuf=gcompris.utils.load_pixmap(
                            'piano_composition/playActivities/background/' +
                            str(level % 6 + 1) + '.jpg'))

        goocanvas.Rect(parent=self.rootitem,
                       x=200,
                       y=160,
                       width=400,
                       height=30,
                       stroke_color="black",
                       fill_color='white',
                       line_width=3.0,
                       radius_x=1.0,
                       radius_y=1.0)
        textBox(_("Beat Count:"), 260, 175, self.rootitem, noRect=True)
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(20, -1, 0.6)

        self.staff = TrebleStaff(450, 175, self.rootitem, numStaves=1)

        self.staff.noteSpacingX = 36
        self.staff.endx = 200
        self.staff.labelBeatNumbers = True
        self.staff.drawStaff()
        self.staff.rootitem.scale(2.0, 2.0)
        self.staff.rootitem.translate(-350, -75)

        self.remainingOptions = self.getInitialRhythmOptions()

        self.givenOption = []

        # RECORD BUTTON
        self.drum = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap('play_rhythm/drumhead.png'),
            x=300,
            y=60,
            tooltip="\n\n\n" + _('Beat the rhythm on this drum.'))
        self.drum.connect("button_press_event", self.record_click)
        gcompris.utils.item_focus_init(self.drum, None)

        # METRONOME BUTTON
        self.metronomeButton = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap('play_rhythm/metronome.png'),
            x=40,
            y=150,
            tooltip="\n\n\n" +
            _('For a little help, click the metronome to hear the tempo.'))
        self.metronomeButton.connect("button_press_event", self.play_metronome)
        gcompris.utils.item_focus_init(self.metronomeButton, None)

        bx = 650
        by = 230

        goocanvas.Rect(parent=self.rootitem,
                       x=bx - 10,
                       y=by - 8,
                       width=120,
                       height=63,
                       stroke_color="black",
                       fill_color_rgba=0x33333399L,
                       line_width=2.0,
                       radius_x=3,
                       radius_y=3)
        # PLAY BUTTON
        self.playButton = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap('piano_composition/play.svg'),
            x=bx,
            y=by,
            tooltip="\n\n" + _('Play'))
        self.playButton.connect("button_press_event",
                                self.staff.playComposition)
        self.playButton.connect("button_press_event", self.stopMetronome)

        gcompris.utils.item_focus_init(self.playButton, None)

        # ERASE BUTTON
        self.eraseButton = goocanvas.Image(
            parent=self.rootitem,
            pixbuf=gcompris.utils.load_pixmap(
                'piano_composition/edit-clear.svg'),
            x=bx + 50,
            y=by,
            tooltip="\n\n" + _("Erase Attempt"))
        self.eraseButton.connect("button_press_event", self.erase_entry)
        gcompris.utils.item_focus_init(self.eraseButton, None)

        self.metronomePlaying = False

        if level in [1, 3, 5, 7, 9, 11]:
            # show playing line, but no metronome
            self.playingLine = True
        else:
            # show metronome, but no playing line
            self.playingLine = False
        self.staff.drawPlayingLine = self.playingLine

        self.readyForFirstDrumBeat = True

        if not self.first_run:
            self.show_rhythm()
        self.updateBoard(1)

        self.playButton.connect("button_press_event",
                                self.compositionIsPlaying)
Ejemplo n.º 52
0
  def start(self):
    gcompris.bar_set (0)
    gcompris.bar_location(gcompris.BOARD_WIDTH - 160, -1, 0.6)
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
    self.rootitem = goocanvas.Group(parent =  self.gcomprisBoard.canvas.get_root_item())

    # The global area
    # ---------------
    self.global_area_sw = gtk.ScrolledWindow()
    self.global_area_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
    self.global_area_sw.set_shadow_type(gtk.SHADOW_ETCHED_OUT)

    w = gcompris.BOARD_WIDTH - 240.0
    h = gcompris.BOARD_HEIGHT - 300.0
    y = 20.0 # The upper limit of the text boxes
    x  = 20.0

    self.global_area_tb = gtk.TextBuffer()
    self.global_area_tv = gtk.TextView(self.global_area_tb)
    self.global_area_tv.set_editable(False)
    self.global_area_sw.add(self.global_area_tv)

    self.global_area_tb.set_text(_("All messages will be displayed here.\n"))

    self.global_area_tv.set_wrap_mode(gtk.WRAP_CHAR)

    goocanvas.Widget(
      parent = self.rootitem,
      widget=self.global_area_sw,
      x=x,
      y=y,
      width=w,
      height= h,
      anchor=gtk.ANCHOR_NW)
    self.global_area_tv.show()
    self.global_area_sw.show()

    # The friend area
    # ---------------
    self.friend_area_sw = gtk.ScrolledWindow()
    self.friend_area_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
    self.friend_area_sw.set_shadow_type(gtk.SHADOW_ETCHED_OUT)

    w = 160.0
    h = gcompris.BOARD_HEIGHT - 240.0
    y = 20.0 # The upper limit of the text boxes
    x = gcompris.BOARD_WIDTH - w - 20.0

    self.friend_area_tb = gtk.TextBuffer()
    self.friend_area_tv = gtk.TextView(self.friend_area_tb)
    self.friend_area_tv.set_editable(False)
    self.friend_area_sw.add(self.friend_area_tv)
    # save name and selected color in a map
    self.friend_map = {}

    self.friend_area_tb.set_text("")

    self.friend_area_tv.set_wrap_mode(gtk.WRAP_CHAR)

    goocanvas.Widget(
      parent = self.rootitem,
      widget=self.friend_area_sw,
      x=x,
      y=y,
      width=w,
      height= h,
      anchor=gtk.ANCHOR_NW)
    self.friend_area_tv.show()
    self.friend_area_sw.show()

    # A label for the friend area

    goocanvas.Text(
      parent = self.rootitem,
      text=_("Your Friends"),
      font = gcompris.skin.get_font("gcompris/board/medium"),
      x=x+(w/2),
      y=y+h+15,
      anchor=gtk.ANCHOR_CENTER,
      )

    # The channel area
    # ---------------
    self.channel = gtk.Entry()
    w = 160.0
    h = 30.0
    y = gcompris.BOARD_HEIGHT - 160.0
    x = x


    goocanvas.Widget(
      parent = self.rootitem,
      widget=self.channel,
      x=x,
      y=y,
      width=w,
      height= h,
      anchor=gtk.ANCHOR_NW)

    self.channel.show()
    self.channel.set_text("")


    # A label for the channel area

    goocanvas.Text(
      parent = self.rootitem,
      text=_("Your Channel"),
      font = gcompris.skin.get_font("gcompris/board/medium"),
      x=x+(w/2),
      y=y+h+15,
      anchor=gtk.ANCHOR_CENTER,
      )

    # the entry area
    self.entry = gtk.Entry()
    self.entry.connect("activate", self.enter_callback, self.entry)
    x = 20.0
    w = gcompris.BOARD_WIDTH - x * 2
    h = 30.0
    y = gcompris.BOARD_HEIGHT - 70.0


    goocanvas.Widget(
      parent = self.rootitem,
      widget=self.entry,
      x=x,
      y=y,
      width=w,
      height= h,
      anchor=gtk.ANCHOR_NW)

    self.entry.show()
    self.entry.set_text(_("Type your message here, to send to other GCompris users on your local network."))

    # drawing area
    x = 20.0
    w = gcompris.BOARD_WIDTH - 300
    h = 200.0
    y = gcompris.BOARD_HEIGHT - 270.0
    self.colors = {}
    self.colors['bg'] = 0xFFFFFFFFL
    self.colors['border'] = 0x000000FFL

    self.drawboard = goocanvas.Rect(
      parent = self.rootitem,
      fill_color_rgba = self.colors['bg'],
      stroke_color_rgba = self.colors['border'],
      line_width = 1.0,
      x = x,
      y = y,
      width = w,
      height = h)
    self.drawboard.connect("button_press_event", self.draw_item_event)
    self.drawboard.connect("button_release_event", self.draw_item_event)
    self.drawboard.connect("motion_notify_event", self.draw_item_event)
    r = random.randint(0,200) # Prevent the possibility of white
    g = random.randint(0,255)
    b = random.randint(0,255)

    # colorpicker
    self.colorpicker = gtk.ColorButton(gtk.gdk.color_parse(self.tohex(r, g, b)))

    x = gcompris.BOARD_WIDTH - 270
    y = gcompris.BOARD_HEIGHT - 270.0
    w = 50
    h = 50

    goocanvas.Widget(
      parent = self.rootitem,
      widget = self.colorpicker,
      x = x,
      y = y,
      width = w,
      height = h,
      anchor = gtk.ANCHOR_NW)


    self.colorpicker.show()
    self.colorpicker.set_tooltip_text(_("color"))
    # line and draw radiobuttons
    self.buttonline = gtk.RadioButton()
    self.buttondraw = gtk.RadioButton(group=self.buttonline)

    x = gcompris.BOARD_WIDTH - 270
    y = gcompris.BOARD_HEIGHT - 220.0
    w = 70
    h = 50

    goocanvas.Widget(
      parent = self.rootitem,
      widget = self.buttonline,
      x = x,
      y = y,
      width = w,
      height = h,
      anchor = gtk.ANCHOR_NW)

    goocanvas.Widget(
      parent = self.rootitem,
      widget = self.buttondraw,
      x = x,
      y = y + 50,
      width = w,
      height = h,
      anchor = gtk.ANCHOR_NW)

    image_line = gtk.Image()
    image_draw = gtk.Image()

    pixbuf = gcompris.utils.load_pixmap("chat/tool-line.png")
    image_line.set_from_pixbuf(pixbuf)
    pixbuf = gcompris.utils.load_pixmap("chat/tool-draw.png")
    image_draw.set_from_pixbuf(pixbuf)

    self.buttonline.set_image(image_line)
    self.buttondraw.set_image(image_draw)

    # erase all button
    self.delAll = gtk.Button()
    x = gcompris.BOARD_WIDTH - 270
    y = gcompris.BOARD_HEIGHT - 100.0
    w = 50
    h = 30


    goocanvas.Widget(
      parent = self.rootitem,
      widget = self.delAll,
      x = x,
      y = y,
      width = w,
      height = h,
      anchor = gtk.ANCHOR_NW)
    self.delAll.show()
    # don't delete this, it's used to change font...
    self.delAll.set_label("")

    if self.delAll.get_use_stock():
      label = self.delAll.child.get_children()[1]
    elif isinstance(self.delAll.child, gtk.Label):
      label = self.delAll.child

    label.set_markup("<span foreground='red' weight='ultrabold' size='x-large'>X</span>")
    self.delAll.connect("button_press_event", self.delAllEvent)
    try:
      # Start the server
      self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
      self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
      self.sock.bind(('', self.port))
      mreq = struct.pack('4sl', socket.inet_aton(self.mcast_adress), socket.INADDR_ANY)

      self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
      self.sock.setblocking(0)
      self.timer_interval = 10
      self.mcast_timer = gobject.timeout_add(self.timer_interval, self.mcast_read)
    except:
      self.display_message("GCompris",
                           _("ERROR: Failed to initialize the network interface. You cannot communicate."))
Ejemplo n.º 53
0
    def start(self):
        self.gcomprisBoard.level = 1
        self.gcomprisBoard.maxlevel = 3

        # Just a tick counter
        self.tick = 0

        self.boat_is_arrived = False
        self.reset_state = True
        self.gamewon = False
        # The basic duration factor for object animations
        # Higher is longer animation (slower)
        self.timerinc = 20
        self.step_time = 100

        # Need to manage the timers to quit properly
        self.waterlevel_timer = 0

        gcompris.sound.play_ogg("sounds/Harbor1.wav", "sounds/Harbor3.wav")

        # 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.svghandle = gcompris.utils.load_svg(
            "hydroelectric/hydroelectric.svgz")
        goocanvas.Svg(parent=self.rootitem,
                      svg_handle=self.svghandle,
                      svg_id="#BACKGROUND",
                      pointer_events=goocanvas.EVENTS_NONE)

        # Take care, the items are stacked on each other in the order you add them.
        # If you need, you can reorder them later with raise and lower functions.

        # The River
        self.riveritem = goocanvas.Svg(parent=self.rootitem,
                                       svg_handle=self.svghandle,
                                       svg_id="#RIVERWATER",
                                       pointer_events=goocanvas.EVENTS_NONE,
                                       visibility=goocanvas.ITEM_INVISIBLE)

        # The Sun
        self.sunitem = goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = self.svghandle,
          svg_id = "#SUN",
          tooltip = "\n\n\n" + \
            _("The sun heats the water and creates water vapor. "
              "Water vapor combines into small water droplets which "
              "becomes clouds.")
          )
        self.sunitem.connect("button_press_event", self.sun_item_event)
        # This item is clickeable and it must be seen
        gcompris.utils.item_focus_init(self.sunitem, None)
        self.sun_on = 0
        self.sunitem_orig_y1 = self.sunitem.get_bounds().y1
        self.sunitem_bounds = self.sunitem.get_bounds()
        self.sunitem_target_y1 = 10
        self.sun_connect_handler = 0

        # The Snow
        self.snowitem = goocanvas.Svg(parent=self.rootitem,
                                      svg_handle=self.svghandle,
                                      svg_id="#SNOW",
                                      pointer_events=goocanvas.EVENTS_NONE,
                                      visibility=goocanvas.ITEM_INVISIBLE)

        # The rain
        self.rainitem = goocanvas.Svg(parent=self.rootitem,
                                      svg_handle=self.svghandle,
                                      svg_id="#RAIN",
                                      pointer_events=goocanvas.EVENTS_NONE,
                                      visibility=goocanvas.ITEM_INVISIBLE)

        # The cloud
        self.clouditem = goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = self.svghandle,
          svg_id = "#CLOUD",
          visibility = goocanvas.ITEM_INVISIBLE,
          tooltip = "\n\n\n" + \
            _("As a cloud matures, the dense water droplets may combine "
              "to produce larger droplets, which may combine to form "
              "droplets large enough to fall as rain")
          )
        self.clouditem.props.visibility = goocanvas.ITEM_INVISIBLE
        self.clouditem.connect("animation-finished", self.cloud_arrived)
        self.cloud_on = False
        self.cloud_is_arrived = False
        self.clouditem_bounds = self.clouditem.get_bounds()
        self.its_raining = False

        # The vapor
        self.vaporitem = goocanvas.Svg(parent=self.rootitem,
                                       svg_handle=self.svghandle,
                                       svg_id="#VAPOR",
                                       pointer_events=goocanvas.EVENTS_NONE,
                                       visibility=goocanvas.ITEM_INVISIBLE)
        self.vaporitem.connect("animation-finished", self.vapor_arrived)
        self.vaporitem_bounds = self.vaporitem.get_bounds()

        # The reservoir level
        self.reservoirlevel = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=self.svghandle,
            svg_id="#RESERVOIR1",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)

        # The Dam
        goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=self.svghandle,
            svg_id="#DAM",
            pointer_events=goocanvas.EVENTS_NONE,
        )

        # The DAM'S TURBINE
        self.dam_turbine = \
          Producer(self.rootitem, self.svghandle,
                   Counter( self.rootitem, self.svghandle,
                            "#DAM_PROD_COUNT",
                            #Translator : "meter" here means a measuring device
                            _("This is the meter for electricity produced by the turbine. ") + \
                            _("The electricity power is measured in watts (W)."),
                            303, 224 ),
                   self.update_prod_count,
                   None,
                   [ "#TURBINE" ],
                   _("Flowing water is directed on to the blades of a turbine runner, "
                     "creating a force on the blades. In this way, energy is transferred "
                     "from the water flow to the turbine"),
                   "#TURBINE_CABLE_ON",
                   "#TRANSFORMER_DAM",
                   "#TRANSFORMER_DAM_TO_USERS",
                   1000)

        # The Wind
        self.winditem_off = goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = self.svghandle,
          svg_id = "#WIND_OFF",
          tooltip = "\n\n\n" + \
            _("This cloud simulates the wind, click on it to have wind.")
          )
        self.winditem_off.connect("button_press_event", self.wind_item_event)
        # This item is clickable and it must be seen
        gcompris.utils.item_focus_init(self.winditem_off, None)

        self.winditem_on = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=self.svghandle,
            svg_id="#WIND_ON",
            visibility=goocanvas.ITEM_INVISIBLE,
            pointer_events=goocanvas.EVENTS_NONE,
        )
        self.wind = False

        # The Cable from transformer 2 to Town
        self.cable_to_town_on = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=self.svghandle,
            svg_id="#CABLE_TO_TOWN_ON",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)
        # The Cable from transformer 2 to Tux
        self.cable_to_tux_on = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=self.svghandle,
            svg_id="#CABLE_TO_TUX_ON",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)

        # TRANSFORMER2
        self.transformer2item = goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = self.svghandle,
          svg_id = "#TRANSFORMER2",
          tooltip = "\n\n\n" + \
            _("This is a step down transformer. Electricity is transformed "
              "in low voltage, ready to be used by the customers.")
          )
        self.transformer2item.connect("button_press_event",
                                      self.transformer2_item_event)
        # This item is clickeable and it must be seen
        gcompris.utils.item_focus_init(self.transformer2item, None)
        self.transformer2_on = 0

        # The tuxboat
        self.boatitem = goocanvas.Svg(parent=self.rootitem,
                                      svg_handle=self.svghandle,
                                      svg_id="#BOAT",
                                      pointer_events=goocanvas.EVENTS_NONE)
        self.boatitem.translate(-100, 0)
        self.boatitem_bounds = self.boatitem.get_bounds()
        self.boatitem.connect("animation-finished", self.boat_arrived)
        self.boatitem_parked = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=self.svghandle,
            svg_id="#BOAT_PARKED",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)

        # Tux in his saloon
        self.tuxsaloonitem = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=self.svghandle,
            svg_id="#SALOON",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)

        goocanvas.Svg(parent=self.rootitem,
                      svg_handle=self.svghandle,
                      svg_id="#FOREGROUND",
                      pointer_events=goocanvas.EVENTS_NONE)

        # The level of water in the reservoir
        self.waterlevel_max = 5
        self.waterlevel_min = 1
        self.waterlevel = 0
        self.waterlevel_timer = gobject.timeout_add(1000, self.update)

        # We have 2 counters, the production one and the consumption
        # The children have to make sure there is no more consumption
        # than production.
        self.prod_count = 0
        self.conso_count = 0

        self.production_counter = \
            Counter( self.rootitem, self.svghandle,
                     "#PROD_COUNT",
                     #Translator : "meter" here means a measuring device
                     _("This is the meter for all the electricity produced. ") + \
                     _("The electricity power is measured in watts (W)."),
                     525, 226 )

        self.consumers_counter = \
            Counter( self.rootitem, self.svghandle,
                     "#CONSO_COUNT",
                     #Translator : "meter" here means a measuring device
                     _("This is the meter for electricity consumed by the users. ") + \
                     _("The electricity power is measured in watts (W)."),
                     590, 203 )

        self.consumers = []
        self.conso_tux = Consumer(self.rootitem, self.svghandle,
                                  self.update_conso_count, "#LIGHT_BUTTON_ON",
                                  "#LIGHT_BUTTON_OFF", "#TUX_ON", "#TUX_OFF",
                                  100)
        self.conso_house = Consumer(self.rootitem, self.svghandle,
                                    self.update_conso_count, "#LIGHT_HOUSE_ON",
                                    "#LIGHT_HOUSE_OFF", "#HOUSE_LIGHTS_ON",
                                    None, 400)
        self.conso_building = Consumer(self.rootitem, self.svghandle,
                                       self.update_conso_count,
                                       "#LIGHT_BUILDING_ON",
                                       "#LIGHT_BUILDING_OFF",
                                       "#BUILDING_LIGHTS_ON", None, 800)

        # The solar panel
        self.solar_array = \
          Producer(self.rootitem, self.svghandle,
                   Counter( self.rootitem, self.svghandle,
                            "#SOLAR_PANEL_COUNT",
                            #Translator : "meter" here means a measuring device
                            _("This is the meter for electricity produced by the solar panels. ") + \
                            _("The electricity power is measured in watts (W)."),
                            697, 177 ),
                   self.update_prod_count,
                   "#SOLAR_PANEL_BG",
                   [ "#SOLAR_PANEL_OFF", "#SOLAR_PANEL_ON" ],
                   _("Solar panels use light energy (photons) from the sun to "
                     "generate electricity through the photovoltaic effect."),
                   "#SOLAR_PANEL_CABLE_ON",
                   "#TRANSFORMER_SOLAR_PANEL",
                   "#TRANSFORMER_SOLAR_PANEL_TO_USERS",
                   400)

        # The Wind farm
        self.windfarmitems = []
        for i in range(1, 4):
            self.windfarmitems.append("#WIND_FARM_" + str(i))

        self.wind_farm = \
          Producer(self.rootitem, self.svghandle,
                   Counter( self.rootitem, self.svghandle,
                            "#WIND_FARM_COUNT",
                            #Translator : "meter" here means a measuring device
                            _("This is the meter for electricity produced by the wind turbines. ") + \
                            _("The electricity power is measured in watts (W)."),
                            650, 137 ),
                   self.update_prod_count,
                   "#WIND_FARM_BG",
                   self.windfarmitems,
                   _("A wind turbine is a device that converts wind motion energy "
                     "into electricity generation. It is called a wind generator or "
                     "wind charger. "),
                   "#WINDFARM_CABLE_ON",
                   "#TRANSFORMER_WINDFARM",
                   "#TRANSFORMER_WINDFARM_TO_USERS",
                   600)

        # Some item ordering
        self.rainitem.raise_(None)
        self.clouditem.raise_(None)
        self.vaporitem.raise_(None)

        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_location(5, -1, 0.6)
        gcompris.bar_set_level(self.gcomprisBoard)
        self.next_level()
Ejemplo n.º 54
0
    def start(self):
        self.gcomprisBoard.level = 1
        self.gcomprisBoard.maxlevel = 1
        self.gcomprisBoard.sublevel = 1
        self.gcomprisBoard.number_of_sublevel = 1

        # The basic duration factor for object animations
        # Higher is longer animation (slower)
        self.timerinc = 20
        self.step_time = 100

        # Need to manage the timers to quit properly
        self.waterlevel_timer = 0

        # Used to display the bonus a single time
        self.you_won = False

        gcompris.sound.play_ogg("sounds/Harbor1.wav", "sounds/Harbor3.wav")

        # 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())

        svghandle = gcompris.utils.load_svg("watercycle/watercycle.svgz")
        goocanvas.Svg(parent=self.rootitem,
                      svg_handle=svghandle,
                      svg_id="#BACKGROUND",
                      pointer_events=goocanvas.EVENTS_NONE)

        # Take care, the items are stacked on each other in the order you add them.
        # If you need, you can reorder them later with raise and lower functions.

        # The River
        self.riveritem = goocanvas.Svg(parent=self.rootitem,
                                       svg_handle=svghandle,
                                       svg_id="#RIVERWATER",
                                       pointer_events=goocanvas.EVENTS_NONE,
                                       visibility=goocanvas.ITEM_INVISIBLE)
        self.riverfull = False

        # The dirty water
        self.dirtywater = goocanvas.Svg(parent=self.rootitem,
                                        svg_handle=svghandle,
                                        svg_id="#DIRTYWATER",
                                        pointer_events=goocanvas.EVENTS_NONE,
                                        visibility=goocanvas.ITEM_INVISIBLE)

        # The clean water
        self.cleanwateritem = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=svghandle,
            svg_id="#CLEANWATER",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)

        # The Sun
        self.sunitem = goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = svghandle,
          svg_id = "#SUN",
          tooltip = "\n\n\n" + \
            _("The sun heats the water and creates water vapor. "
              "Water vapor combines into small water droplets which "
              "becomes clouds.")
          )
        self.sunitem.connect("button_press_event", self.sun_item_event)
        # This item is clickeable and it must be seen
        gcompris.utils.item_focus_init(self.sunitem, None)
        self.sun_on = 0
        self.sunitem_orig_y1 = self.sunitem.get_bounds().y1
        self.sunitem_target_y1 = 10
        self.sun_connect_handler = 0

        # The Snow
        self.snowitem = goocanvas.Svg(parent=self.rootitem,
                                      svg_handle=svghandle,
                                      svg_id="#SNOW",
                                      pointer_events=goocanvas.EVENTS_NONE,
                                      visibility=goocanvas.ITEM_INVISIBLE)

        # The rain
        self.rainitem = goocanvas.Svg(parent=self.rootitem,
                                      svg_handle=svghandle,
                                      svg_id="#RAIN",
                                      pointer_events=goocanvas.EVENTS_NONE,
                                      visibility=goocanvas.ITEM_INVISIBLE)

        # The cloud
        self.clouditem = goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = svghandle,
          svg_id = "#CLOUD",
          visibility = goocanvas.ITEM_INVISIBLE,
          tooltip = "\n\n\n" + \
            _("As a cloud matures, the dense water droplets may combine "
              "to produce larger droplets, which may combine to form "
              "droplets large enough to fall as rain")
          )
        self.clouditem.props.visibility = goocanvas.ITEM_INVISIBLE
        self.clouditem.connect("animation-finished", self.cloud_arrived)
        self.cloud_on = False
        self.cloud_is_arrived = False
        self.clouditem_bounds = self.clouditem.get_bounds()

        # The vapor
        self.vaporitem = goocanvas.Svg(parent=self.rootitem,
                                       svg_handle=svghandle,
                                       svg_id="#VAPOR",
                                       pointer_events=goocanvas.EVENTS_NONE,
                                       visibility=goocanvas.ITEM_INVISIBLE)
        self.vaporitem.connect("animation-finished", self.vapor_arrived)

        # The Waterpump
        self.waterpumpitem = goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = svghandle,
          svg_id = "#PUMPSTATION",
          tooltip = "\n\n\n" + \
            _("This is a water pump station.")
          )
        self.waterpumpitem.connect("button_press_event",
                                   self.waterpump_item_event)
        # This item is clickeable and it must be seen
        gcompris.utils.item_focus_init(self.waterpumpitem, None)
        self.waterpump_on = 0

        # The WaterCleaning
        self.watercleaningitem = goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = svghandle,
          svg_id = "#CLEANSTATION",
          tooltip = "\n\n\n" + \
            _("This is a water cleanup station.")
          )
        self.watercleaningitem.connect("button_press_event",
                                       self.watercleaning_item_event)
        # This item is clickeable and it must be seen
        gcompris.utils.item_focus_init(self.watercleaningitem, None)
        self.watercleaning_on = 0

        # The tuxboat
        self.boatitem = goocanvas.Svg(parent=self.rootitem,
                                      svg_handle=svghandle,
                                      svg_id="#BOAT",
                                      pointer_events=goocanvas.EVENTS_NONE)
        self.boatitem.translate(-100, 0)
        self.boatitem_parked = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=svghandle,
            svg_id="#BOAT_PARKED",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)

        # Tux in the shower (without water)
        self.tuxshoweritem = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=svghandle,
            svg_id="#SHOWER",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)

        self.shower_tux = goocanvas.Svg(parent=self.rootitem,
                                        svg_handle=svghandle,
                                        svg_id="#SHOWER_TUX",
                                        pointer_events=goocanvas.EVENTS_NONE,
                                        visibility=goocanvas.ITEM_INVISIBLE)

        # Tux in the shower with the water
        self.tuxshowerwateritem = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=svghandle,
            svg_id="#SHOWER_ON",
            pointer_events=goocanvas.EVENTS_NONE,
            visibility=goocanvas.ITEM_INVISIBLE)

        # The shower on/off button (I need to get the 2 buttons to manage the focus)
        self.showerbuttonitem_on = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=svghandle,
            svg_id="#SHOWER_BUTTON_ON",
            visibility=goocanvas.ITEM_INVISIBLE)
        self.showerbuttonitem_on.connect("button_press_event",
                                         self.showerbutton_item_event, True)
        # This item is clickeable and it must be seen
        gcompris.utils.item_focus_init(self.showerbuttonitem_on, None)
        self.showerbutton = False

        self.showerbuttonitem_off = goocanvas.Svg(
            parent=self.rootitem,
            svg_handle=svghandle,
            svg_id="#SHOWER_BUTTON_OFF",
            visibility=goocanvas.ITEM_INVISIBLE)
        self.showerbuttonitem_off.connect("button_press_event",
                                          self.showerbutton_item_event, False)
        # This item is clickeable and it must be seen
        gcompris.utils.item_focus_init(self.showerbuttonitem_off, None)

        goocanvas.Svg(parent=self.rootitem,
                      svg_handle=svghandle,
                      svg_id="#FOREGROUND",
                      pointer_events=goocanvas.EVENTS_NONE)

        goocanvas.Svg(
          parent = self.rootitem,
          svg_handle = svghandle,
          svg_id = "#WATER_TOWER",
          tooltip = "\n\n\n" + \
            _("A water tower or elevated water tower is a large elevated water storage container constructed to hold a water supply at a height sufficient to pressurize a water distribution system.")
          )

        # The level of water in the tower
        self.waterlevel_max = 12
        self.waterlevel_min = 1
        self.waterlevel_x_ratio = 1.3
        self.waterlevel = 1
        self.waterlevel_item = goocanvas.Ellipse(parent=self.rootitem,
                                                 center_x=635,
                                                 center_y=142,
                                                 radius_x=1,
                                                 radius_y=1,
                                                 fill_color_rgba=0x0033FFC0L,
                                                 line_width=0)
        self.waterlevel_timer = gobject.timeout_add(1000,
                                                    self.update_waterlevel)

        # Some item ordering
        self.rainitem.raise_(None)
        self.clouditem.raise_(None)
        self.vaporitem.raise_(None)

        # Ready GO
        target_x = 700
        trip_x = int(target_x - self.boatitem.get_bounds().x1)
        self.boatitem.connect("animation-finished", self.boat_arrived)
        self.boatitem.animate(target_x, 0, 1, 1, True, self.timerinc * trip_x,
                              self.step_time, goocanvas.ANIMATE_FREEZE)

        gcompris.bar_set(0)
        gcompris.bar_location(5, -1, 0.6)
        gcompris.bar_set_level(self.gcomprisBoard)
Ejemplo n.º 55
0
    def start(self):

        # Find the list of modules in admin/
        # that means all files, but __init__.py and module.py
        list_modules = []

        import glob
        m_list = glob.glob('admin/module_*.py')
        if m_list == []:
            m_list = glob.glob(gcompris.PYTHON_PLUGIN_DIR +
                               '/admin/module_*.py')
        for file in m_list:
            m_name = file.split('/')[-1].split('.')[0].split('_')[1]
            list_modules.append(m_name)

        # Now import modules,
        # and get the list of string 'name.Name' for initialisation below.
        modules_init = []

        for module in list_modules:
            exec('from admin import module_' + module + ' as ' + module)
            modules_init.append(module + '.' + module[0].upper() + module[1:])

        del list_modules

        self.gcomprisBoard.level = 1
        self.gcomprisBoard.maxlevel = 1
        self.gcomprisBoard.sublevel = 1
        self.gcomprisBoard.number_of_sublevel = 1
        gcompris.bar_set(0)
        gcompris.set_default_background(
            self.gcomprisBoard.canvas.get_root_item())
        gcompris.bar_set_level(self.gcomprisBoard)
        gcompris.bar_location(25, -1, 0.6)

        goocanvas.Rect(parent=self.rootitem,
                       x=self.select_area[0],
                       y=self.select_area[1],
                       width=self.select_area[2] - self.select_area[0],
                       height=self.select_area[3] - self.select_area[1],
                       fill_color="white",
                       stroke_color_rgba=0x111199FFL,
                       line_width=1.0)

        # A White background in the panel area

        goocanvas.Rect(parent=self.rootitem,
                       x=self.panel_area[0],
                       y=self.panel_area[1],
                       width=self.panel_area[2] - self.panel_area[0],
                       height=self.panel_area[3] - self.panel_area[1],
                       fill_color="white",
                       stroke_color_rgba=0x111199FFL,
                       line_width=1.0)

        # Get the menu position for each module
        # The list of modules
        modules_ordered = []
        for module in modules_init:
            p = eval(module + '(self.rootitem).position()')
            modules_ordered.append((p, module))

        # Display the menu in the selection area
        # The list of modules
        i = 0
        modules_ordered.sort()
        for tmodule in modules_ordered:
            module = tmodule[1]
            eval(
                module +
                '(self.rootitem).init(i, self.select_area, self.select_event)')
            i += 1
Ejemplo n.º 56
0
    def start(self):
        self.board.level = 1
        self.board.maxlevel = self.levelset.numlevels
        self.board.sublevel = 1
        self.board.number_of_sublevel = self.levelset.num_sublevels
        self.trog_wait = 1900

        gcompris.set_default_background(self.board.canvas.get_root_item())
        gcompris.bar_set_level(self.board)

        gcompris.bar_set(gcompris.BAR_LEVEL | gcompris.BAR_REPEAT)

        # create our rootitem. We put each canvas item here so at the end we only
        # need to remove the rootitem
        self.rootitem = goocanvas.Group(
            parent=self.board.canvas.get_root_item())

        # draw the board on top of the background
        for i in range(0, self.width + 1):
            goocanvas.Polyline(parent=self.rootitem,
                               points=goocanvas.Points([
                                   (i * self.sw + self.left, self.top),
                                   (i * self.sw + self.left, self.scrh)
                               ]),
                               fill_color_rgba=0x000000FFL,
                               line_width=3.0)
        for i in range(0, self.height + 1):
            goocanvas.Polyline(parent=self.rootitem,
                               points=goocanvas.Points([
                                   (self.left, self.top + i * self.sh),
                                   (self.scrw, self.top + i * self.sh)
                               ]),
                               fill_color_rgba=0x000000FFL,
                               line_width=3.0)

        # munchers and troggles
        self.players = []
        self.muncher = Muncher()
        self.troggles = [Troggle(), Troggle(), Troggle()]

        self.players[:] = self.troggles
        self.players.append(self.muncher)

        # create the squares
        self.squares = []
        for i in range(0, self.width):
            tmp = []
            for j in range(0, self.height):
                s = Square(self.left + self.sw * i + self.sw / 2,
                           self.top + self.sh * j + self.sh / 2)
                s.pic.raise_(None)
                tmp.append(s)
            self.squares.append(tmp)

        # so that the troggles get clipped to the board area
        goocanvas.Rect(parent=self.rootitem,
                       x=0,
                       y=0,
                       width=self.scrw,
                       height=self.top,
                       fill_color_rgba=0xFFFFFFFFL)
        goocanvas.Rect(parent=self.rootitem,
                       x=0,
                       y=0,
                       width=self.left,
                       height=self.scrh,
                       fill_color_rgba=0xFFFFFFFFL)

        # the board title
        self.title = goocanvas.Text(
            parent=self.rootitem,
            text="",
            font=gcompris.skin.get_font("gcompris/board/title bold"),
            x=self.sw + 10,
            y=self.top / 2)

        # the message
        self.message_back = goocanvas.Rect(parent=self.rootitem,
                                           x=0,
                                           y=0,
                                           width=1,
                                           height=1,
                                           fill_color_rgba=0x60F060F0L)
        self.message = goocanvas.Text(
            parent=self.rootitem,
            text="",
            anchor=gtk.ANCHOR_CENTER,
            font=gcompris.skin.get_font("gcompris/board/big bold"),
            x=self.scrw / 2,
            y=self.scrh / 2)
        self.hide_message()

        # the trogwarning
        self.trogwarning = goocanvas.Text(
            parent=self.rootitem,
            text=_("T\nR\nO\nG\nG\nL\nE"),
            anchor=gtk.ANCHOR_CENTER,
            font=gcompris.skin.get_font("gcompris/board/title bold"),
            x=self.left / 2,
            y=self.scrh / 2)
        self.trogwarning.props.visibility = goocanvas.ITEM_INVISIBLE
        self.trogwarning_num = 0

        # the spare life
        self.muncher.spare.goocanvas.raise_(None)

        gcompris.bar_set(0)
        gcompris.bar_location(10, -1, 0.6)

        self.startGame()
Ejemplo n.º 57
0
  def start(self):
    self.gcomprisBoard.level=1
    self.gcomprisBoard.maxlevel=len(self.data)
    self.gcomprisBoard.sublevel=1
    self.gcomprisBoard.number_of_sublevel=1

    # 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.backroot = goocanvas.Group(parent = \
                                      self.gcomprisBoard.canvas.get_root_item())

    # A color changing background
    self.background = goocanvas.Rect(
      parent = self.backroot,
      x = 0,
      y = 0,
      width = gcompris.BOARD_WIDTH,
      height = 200,
      fill_color_rgba = 0xFFFFFFFFL
      )

    svghandle = gcompris.utils.load_svg("lightsoff/back.svgz")
    goocanvas.Svg(
      parent = self.backroot,
      svg_handle = svghandle,
      svg_id = "#BACKGROUND",
      pointer_events = goocanvas.EVENTS_NONE
      )

    # The Sun
    self.sunitem = goocanvas.Svg(
      parent = self.backroot,
      svg_handle = svghandle,
      svg_id = "#SUN",
      )
    self.sunitem_offset = 0

    # TUX
    self.tuxitem = goocanvas.Svg(
      parent = self.backroot,
      svg_handle = svghandle,
      svg_id = "#TUX",
      )
    self.tuxitem.connect("button_press_event", self.solve_event)
    gcompris.utils.item_focus_init(self.tuxitem, None)

    # The Buble
    self.bubbleitem = goocanvas.Svg(
      parent = self.backroot,
      svg_handle = svghandle,
      svg_id = "#BUBBLE1",
      )

    self.textitem = goocanvas.Text(
      parent = self.backroot,
      x = gcompris.BOARD_WIDTH/2 + 80,
      y = gcompris.BOARD_HEIGHT - 80,
      width = 400,
      font = gcompris.skin.get_font("gcompris/content"),
      text = _("Switch off all the lights, I have to go to sleep.\n"
               "If you need help, click on me."),
      fill_color = "black",
      anchor = gtk.ANCHOR_CENTER
      )

    # The Tipi
    self.tipiitem = goocanvas.Svg(
      parent = self.backroot,
      svg_handle = svghandle,
      svg_id = "#TIPI",
      )

    # The image foreground
    goocanvas.Svg(
      parent = self.backroot,
      svg_handle = svghandle,
      svg_id = "#FOREGROUND",
      pointer_events = goocanvas.EVENTS_NONE
      )

    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_REPEAT)
    gcompris.bar_location(gcompris.BOARD_WIDTH/2 - 90, -1, 0.6)
    gcompris.bar_set_level(self.gcomprisBoard)

    self.display_game()