Example #1
0
  def __init__(self, db_connect, db_cursor, profile):

    self.cur = db_cursor
    self.con = db_connect
    self.active_profile = profile

    files = glob.glob('wordlist_*.xml')

    self.main_vbox = gcompris.configuration_window ( \
      _('<b>{config}</b> configuration\n for profile <b>{profile}</b>').format( \
                        config='Wordlist',
                        # This is the name of the Default user profile
                        profile=profile.name if profile else _("Default")),
      self.wordlist_callback
      )

    self.prop = gcompris.get_properties()

    self.wordlist_dir = self.prop.shared_dir +'/wordlist'

    gcompris.textview('Words list',
                      'wordlist',
                      'Enter the words, comma, space, return separated. Then click on th check button.',
                      '',
                      self.wordlist_validate)
Example #2
0
    def start(self):

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

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

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

        readyButton = TextButton(400, 455,
                                 ' ' * 20 + _('I am Ready') + ' ' * 20,
                                 self.rootitem, 0x11AA11FFL)
        readyButton.getBackground().connect("button_press_event",
                                            self.ready_event, readyButton)
    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)
Example #4
0
  def start(self):
    self.saved_policy = gcompris.sound.policy_get()
    gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)

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

    # pause the bg music
    #print "pause sound"
    gcompris.sound.pause()

    self.timers = []
    self.solution = []
    self.kidstry = []
    self.in_repeat = 0
    self.theme = 0

    #
    # This list contains the 'theme' for each melody level.
    #
    self.melodylist = \
                      [
      # xylophon
      [
      {'theme': "xylofon", 'background': "melody/xylofon_background.svg", 'hittool': "melody/xylofon_cursor.png", 'hitofset_x': 50, 'hitofset_y': 50},
      [ {'x': 150.0, 'y': 101.0,  'image': "melody/xylofon_son1.svg", 'sound': "melody/xylofon_son1.ogg"},
        {'x': 284.0, 'y': 118.0,  'image': "melody/xylofon_son2.svg", 'sound': "melody/xylofon_son2.ogg"},
        {'x': 412.0, 'y': 140.0, 'image': "melody/xylofon_son3.svg", 'sound': "melody/xylofon_son3.ogg"},
        {'x': 546.0, 'y': 157.0, 'image': "melody/xylofon_son4.svg", 'sound': "melody/xylofon_son4.ogg"} ] ],

      # guitar
      [
      {'theme': "guitar", 'background': "melody/guitar_background.svg", 'hittool': "melody/guitar_cursor.svg", 'hitofset_x': 400, 'hitofset_y': -5},
      [ {'x': 0, 'y': 170.0,  'image': "melody/guitar_son1.png", 'sound': "melody/guitar_son1.ogg"},
        {'x': 0, 'y': 230.0,  'image': "melody/guitar_son2.png", 'sound': "melody/guitar_son2.ogg"},
        {'x': 0, 'y': 290.0, 'image': "melody/guitar_son3.png", 'sound': "melody/guitar_son3.ogg"},
        {'x': 0, 'y': 350.0, 'image': "melody/guitar_son4.png", 'sound': "melody/guitar_son4.ogg"} ] ],

      # Kitchen
      [
      {'theme': "tachos", 'background': "melody/tachos_background.jpg", 'hittool': "melody/tachos_cursor.png", 'hitofset_x': 50, 'hitofset_y': 50},
      [ {'x': 150.0, 'y': 50.0,  'image': "melody/tachos_son1.png", 'sound': "melody/tachos_son1.ogg"},
        {'x': 550.0, 'y': 50.0,  'image': "melody/tachos_son2.png", 'sound': "melody/tachos_son2.ogg"},
        {'x': 150.0, 'y': 250.0, 'image': "melody/tachos_son3.png", 'sound': "melody/tachos_son3.ogg"},
        {'x': 550.0, 'y': 250.0, 'image': "melody/tachos_son4.png", 'sound': "melody/tachos_son4.ogg"} ] ] ]

    self.maxtheme = len(self.melodylist)-1
    self.gcomprisBoard.maxlevel = 9

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


    self.pause(1);
    self.display_current_level()

    Prop = gcompris.get_properties()

    if(not Prop.fx):
      gcompris.utils.dialog(_("Error: this activity cannot be played with the\nsound effects disabled.\nGo to the configuration dialogue to\nenable the sound"), stop_board)
Example #5
0
    def start(self):
        self.recordedHits = []
        self.saved_policy = gcompris.sound.policy_get()
        gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)
        gcompris.sound.pause()

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

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

        readyButton = TextButton(400, 455, ' ' * 20 + _('I am Ready') + ' ' * 20,
                                 self.rootitem, 0x11AA11FFL)
        readyButton.getBackground().connect("button_press_event",
                                            self.ready_event, readyButton)
Example #6
0
  def read_data(self):
    '''Load the activity data'''
    config = ConfigParser.RawConfigParser()
    p = gcompris.get_properties()
    filename = gcompris.DATA_DIR + '/' + self.gcomprisBoard.name + '/activity.desktop'
    try:
      gotit = config.read(filename)
      if not gotit:
        gcompris.utils.dialog(_("Cannot find the file '{filename}'").format(filename=filename), None)
        return False

    except ConfigParser.Error, error:
      gcompris.utils.dialog(_("Failed to parse data set '{filename}' with error:\n{error}").
        format(filename=filename, error=error), None)
      return False
Example #7
0
  def cleanup(self):
    #tell the others to remove me from the friend-lists of the other clients:
    prop = gcompris.get_properties()
    self.send_message("GCOMPRIS:LEAVE:%s:%s:%s" % (self.channel.get_text(),
                                                   prop.logged_user.login,
                                                   self.get_selectedcolor() ))
    if self.mcast_timer :
      gobject.source_remove(self.mcast_timer)
      self.mcast_timer = 0

    if self.sock:
      self.sock.close()

    # Remove the root item removes all the others inside it
    if self.rootitem != None:
     self.rootitem.remove()
     self.rootitem = None
Example #8
0
  def send_drawboard_content(self, x, y, linex=None, liney=None, color=""):
    """send either line or point depending the given attributes."""

    Prop = gcompris.get_properties()
    type = ""
    if linex == None:
        type = "point"
        linex = ""
        liney = ""
    else:
        type = "line"


    message = ("GCOMPRIS:DRAW:" + self.channel.get_text() + ":" +
               Prop.logged_user.login + ":" + color + ":" +
               self.uuid + ":" +
               type + ":" + repr(x) + ":" + repr(y) +
               ":" +str(linex) + ":"+ str(liney))
    self.send_message(message)
Example #9
0
  def enter_callback(self, widget, entry):
    gcompris.sound.play_ogg("sounds/bleep.wav")

    if(not self.channel.get_text()):
      self.display_message(
        "GCompris",
        _("You must set a channel in your channel entry box first.\n") +
        _("Your friends must set the same channel in order to communicate with you") )
      return
    Prop = gcompris.get_properties()
    entry_text = entry.get_text()

    # format the message
    entry_text = ("GCOMPRIS:CHAT:" +
                  self.channel.get_text() + ":" +
                  Prop.logged_user.login + ":" + self.get_selectedcolor() +
                  ":" + entry_text)
    self.send_message(entry_text)
    entry.set_text("")
Example #10
0
 def read_data(self):
     '''Load the activity data, return True if OK'''
     config = ConfigParser.RawConfigParser()
     p = gcompris.get_properties()
     filename = gcompris.DATA_DIR + '/' + self.gcomprisBoard.name + \
         '/activity.desktop'
     try:
         gotit = config.read(filename)
         if not gotit:
             gcompris.utils.dialog(_("Cannot find the file '{filename}'").\
                                     format(filename=filename),
                                   None)
             return False
     except ConfigParser.Error, error:
         gcompris.utils.dialog(_("Failed to parse data set '{filename}'"
                                 " with error:\n{error}").\
                                 format(filename=filename, error=error),
                               None)
         return False
Example #11
0
    def read_data(self):
        """Load the activity data, return True if OK"""
        config = ConfigParser.RawConfigParser()
        p = gcompris.get_properties()
        filename = gcompris.DATA_DIR + "/" + self.gcomprisBoard.name + "/activity.desktop"
        try:
            gotit = config.read(filename)
            if not gotit:
                gcompris.utils.dialog(_("Cannot find the file '{filename}'").format(filename=filename), None)
                return False
        except ConfigParser.Error as error:
            gcompris.utils.dialog(
                _("Failed to parse data set '{filename}'" " with error:\n{error}").format(
                    filename=filename, error=error
                ),
                None,
            )
            return False

        self.dataset = finditDataSet(config)
        return True
Example #12
0
    def start(self):
        '''
        method called to create 'home-page', the world map with all the locations.
        This method is re-called whenever 'Go Back To Map' button is pressed
        by any of the location pages.
        '''

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

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

        self.display_level(self.gcomprisBoard.level)

        if self.gcomprisBoard.mode == "audio" \
                and 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)
Example #13
0
    def __init__(self, db_connect, db_cursor, profile):

        self.cur = db_cursor
        self.con = db_connect
        self.active_profile = profile

        files = glob.glob('wordlist_*.xml')

        self.main_vbox = gcompris.configuration_window ( \
          _('<b>{config}</b> configuration\n for profile <b>{profile}</b>').format(config='Wordlist',
                                                                                   profile=self.active_profile.name),
          self.wordlist_callback
          )

        self.prop = gcompris.get_properties()

        self.wordlist_dir = self.prop.shared_dir + '/wordlist'

        gcompris.textview(
            'Words list', 'wordlist',
            'Enter the words, comma, space, return separated. Then click on th check button.',
            '', self.wordlist_validate)
Example #14
0
  def start(self):
    self.gcomprisBoard.level=1
    self.gcomprisBoard.maxlevel=1
    self.gcomprisBoard.sublevel=1
    self.gcomprisBoard.number_of_sublevel=1
    gcompris.bar_set(gcompris.BAR_REPEAT|gcompris.BAR_CONFIG)

    gcompris.bar_set_level(self.gcomprisBoard)

    gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                            backgrounds[self.gcomprisBoard.level-1])

    # Get the default profile
    self.Prop = gcompris.get_properties()

    if not self.Prop:
      return

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

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

    # Create and Initialize the rootitem.
    self.init_rootitem(self.Prop)

    # Get the user list
    users = []
    if self.Prop.profile:
      for group_id in self.Prop.profile.group_ids:
        users.extend( gcompris.admin.get_users_from_group(group_id))

    self.users = self.check_unique_id(users)

    if eval(self.config_dict['entry_text']):
      self.entry_text()
    else:
      self.display_user_by_letter(self.users, "")
Example #15
0
    def start(self):
        '''
        method called to create 'home-page', the world map with all the locations.
        This method is re-called whenever 'Go Back To Map' button is pressed
        by any of the location pages.
        '''

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

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

        self.display_level(self.gcomprisBoard.level)

        if self.gcomprisBoard.mode == "audio" \
                and 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)
Example #16
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)
Example #17
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)

    # 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()
    self.currentExercise = None
    self.currentExerciseModes = []

    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

    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)

    gcompris.bar_set_level(self.gcomprisBoard)

    readyButton = TextButton(400, 255, ' ' * 20 + _('I am Ready') + ' ' * 20,
                             self.rootitem, 0x11AA11FFL)
    readyButton.getBackground().connect("button_press_event",
                                        self.ready_event, readyButton)

    self.pause(1);
Example #18
0
  def start(self):
    progname='tuxpaint'
    tuxpaint_dir = None
    flags = gobject.SPAWN_DO_NOT_REAP_CHILD | gobject.SPAWN_SEARCH_PATH

    print platform.platform(), platform.platform().split('-')[0]
    if (platform.platform().split('-')[0] == 'Windows'):
      progname = 'tuxpaint.exe'

      try:
         import _winreg

         tuxpaint_key = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE,
                                         "Software\\TuxPaint" )
         tuxpaint_dir, type = _winreg.QueryValueEx(tuxpaint_key, "Install_Dir")
         flags = gobject.SPAWN_DO_NOT_REAP_CHILD
         # escape mandatory in Win pygtk2.6
         tuxpaint_dir = '"' + tuxpaint_dir + '"'

      except:
	   pass

    self.window = self.gcomprisBoard.canvas.get_toplevel()

    Prop = gcompris.get_properties()

    #get default values
    self.config_dict = self.init_config()

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

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



    # first run: find version
    options = [progname]
    options.append('--version')
    global pid
    try:
       # bug in working_directory=None ?
       if (tuxpaint_dir):
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags,
            working_directory=tuxpaint_dir,
            standard_output=True
            )

       else:
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags,
            standard_output=True
            )

    except:
       gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board)
       return

    gobject.child_watch_add(pid, child_callback, data=self, priority=gobject.PRIORITY_HIGH)

    output=os.read(stdout, 255)

    parsenext = False
    oldfullscreensyntax = False
    for i in output.split():
      if ( parsenext):
        tpversion = i.split(".")
        major, minor, sub = tpversion
        if (int(major) < 1 and int(minor) < 10 and int(sub) < 22):
          oldfullscreensyntax=True
        break

      if (i == "Version"):
        # next is the version number
        parsenext = True


    # second run: adapt the parms to the version and run
    options = [progname]

    if (Prop.fullscreen and eval(self.config_dict['fullscreen'])):
      if (oldfullscreensyntax):
        options.append('--fullscreen')
        options.append('--native')
      else:
        options.append('--fullscreen=native')

    if eval(self.config_dict['disable_shape_rotation']):
      options.append('--simpleshapes')

    if eval(self.config_dict['uppercase_text']):
      options.append('--uppercase')

    if eval(self.config_dict['disable_stamps']):
      options.append('--nostamps')

    if eval(self.config_dict['disable_stamps_control']):
      options.append('--nostampcontrols')

    gcompris.sound.close()

    try:
       # bug in working_directory=None ?
       if (tuxpaint_dir):
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags,
            working_directory=tuxpaint_dir)

       else:
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags)

    except:
       gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board)
       return

    gobject.child_watch_add(pid, child_callback, data=self, priority=gobject.PRIORITY_HIGH)

    gcompris.bar_set(gcompris.BAR_CONFIG)
    gcompris.bar_hide(1)

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

    textItem = goocanvas.Text(
      parent = self.rootitem,
      text = _("Waiting for Tuxpaint to finish"),
      x = gcompris.BOARD_WIDTH/2,
      y = 185,
      fill_color_rgba = 0x000000ffL,
      anchor = gtk.ANCHOR_CENTER,
      font = gcompris.skin.get_font("gcompris/board/title bold"),
      )
Example #19
0
  def start(self):
    progname='tuxpaint'
    tuxpaint_dir = None
    flags = gobject.SPAWN_DO_NOT_REAP_CHILD | gobject.SPAWN_SEARCH_PATH

    print platform.platform(), platform.platform().split('-')[0]
    if (platform.platform().split('-')[0] == 'Windows'):
      progname = 'tuxpaint.exe'

      try:
         import _winreg

         tuxpaint_key = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE,
                                         "Software\\TuxPaint" )
         tuxpaint_dir, type = _winreg.QueryValueEx(tuxpaint_key, "Install_Dir")
         flags = gobject.SPAWN_DO_NOT_REAP_CHILD
         # escape mandatory in Win pygtk2.6
         tuxpaint_dir = '"' + tuxpaint_dir + '"'

      except:
	   pass

    self.window = self.gcomprisBoard.canvas.get_toplevel()

    Prop = gcompris.get_properties()

    #get default values
    self.config_dict = self.init_config()

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

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

    options = [progname]

    if (Prop.fullscreen and eval(self.config_dict['fullscreen'])):
      options.append('--fullscreen')

    if eval(self.config_dict['disable_shape_rotation']):
      options.append('--simpleshapes')

    if eval(self.config_dict['uppercase_text']):
      options.append('--uppercase')

    if eval(self.config_dict['disable_stamps']):
      options.append('--nostamps')

    if eval(self.config_dict['disable_stamps_control']):
      options.append('--nostampcontrols')

    gcompris.sound.close()

    global pid
    try:
       # bug in working_directory=None ?
       if (tuxpaint_dir):
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags,
            working_directory=tuxpaint_dir)

       else:
          pid, stdin, stdout, stderr = gobject.spawn_async(
            argv=options,
            flags=flags)

    except:
       gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board)
       return

    gobject.child_watch_add(pid, child_callback, data=self, priority=gobject.PRIORITY_HIGH)

    gcompris.bar_set(gcompris.BAR_CONFIG)
    gcompris.bar_hide(1)

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

    textItem = goocanvas.Text(
      parent = self.rootitem,
      text = _("Waiting for Tuxpaint to finish"),
      x = gcompris.BOARD_WIDTH/2,
      y = 185,
      fill_color_rgba = 0x000000ffL,
      anchor = gtk.ANCHOR_CENTER,
      font = gcompris.skin.get_font("gcompris/board/title bold"),
      )
Example #20
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)

        # 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()
        self.currentExercise = None
        self.currentExerciseModes = []

        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

        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)

        gcompris.bar_set_level(self.gcomprisBoard)

        readyButton = TextButton(400, 255,
                                 ' ' * 20 + _('I am Ready') + ' ' * 20,
                                 self.rootitem, 0x11AA11FFL)
        readyButton.getBackground().connect("button_press_event",
                                            self.ready_event, readyButton)

        self.pause(1)
Example #21
0
    def display_level(self, level):
        '''
        displays level contents.
        All levels: keyboard, staff, write & erase notes, play composition
        1. treble clef only
        2. bass clef only
        3. note duration choice, treble or bass choice
        4. sharp notes, note duration choice, treble or bass choice
        5. flat notes, note duration choice, treble or bass choice
        6. load and save, only sharp notes, note duration choice, treble or bass choice
        '''
        if self.rootitem:
            self.rootitem.remove()

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

        clefDescription = keyboardDescription = True
        if level == 1:
            clefText = _("This is the Treble clef staff, for high pitched notes")
            keyboardText = _("These are the 8 \"white\" keys in an octave")
        elif level == 2:
            clefText = _("This is the Bass clef staff, for low pitched notes")
            keyboardText = _("These keys form the C Major scale")
        elif level == 3:
            clefText = _("Click on the note symbols to write different length notes")
            keyboardText = _("Notes can be many types, such as quarter notes, half notes, and whole notes")
        elif level == 4:
            clefText = _("Sharp notes have a # sign")
            keyboardText = _("The black keys are sharp and flat keys")
        elif level == 5:
            clefText = _("Flat notes have a b sign")
            keyboardText = _("Each black key has two names, one with a flat and one with a sharp")
        elif level == 6:
            keyboardText = _("Now you can compose music! Click to load or save your work")
            clefDescription = False

        # CLEF DESCRIPTION
        if clefDescription:
            goocanvas.Rect(parent=self.rootitem, x=380, y=90, width=240,
                           height=50,
                stroke_color="purple", line_width=3.0)

            self.clefDesciption = goocanvas.Text(
                parent=self.rootitem, x=500, y=115, width=250,
                text=clefText, anchor=gtk.ANCHOR_CENTER,
                alignment=pango.ALIGN_CENTER
                )

        # OUTLINE FOR NOTE NAME TEXT
        goocanvas.Rect(parent=self.rootitem, x=60, y=40, width=120,
                       height=80,
            stroke_color="purple", line_width=3.0)


        # KEYBOARD DESCRIPTION
        if keyboardDescription:
            goocanvas.Rect(parent=self.rootitem, x=87, y=385, width=230,
                           height=65,
                stroke_color="purple", line_width=3.0)

            self.KeyboardDescription = goocanvas.Text(
                parent=self.rootitem, x=200, y=415, width=225,
                text=keyboardText,
                fill_color="black", anchor=gtk.ANCHOR_CENTER,
                alignment=pango.ALIGN_CENTER
                )

        self.colorCodeNotesButton = goocanvas.Text(
          parent=self.rootitem,
          x=345,
          y=120,
          width=75,
          text=_("Color code notes?"),
          fill_color="black",
          anchor=gtk.ANCHOR_CENTER,
          alignment=pango.ALIGN_CENTER
          )

        self.eraseAllButton = goocanvas.Text(
          parent=self.rootitem,
          x=325.0,
          y=50,
          width=100,
          text=_("Erase All Notes"),
          fill_color="black",
          anchor=gtk.ANCHOR_CENTER,
          alignment=pango.ALIGN_CENTER
          )

        self.eraseNotesButton = goocanvas.Text(
          parent=self.rootitem,
          x=425.0,
          y=50,
          width=100,
          text=_("Erase Last Note"),
          fill_color="black",
          anchor=gtk.ANCHOR_CENTER,
          alignment=pango.ALIGN_CENTER
          )

        self.playCompositionButton = goocanvas.Text(
          parent=self.rootitem,
          x=550,
          y=50,
          width=100,
          text=_("Play Composition"),
          fill_color="black",
          anchor=gtk.ANCHOR_CENTER,
          alignment=pango.ALIGN_CENTER
          )


        if (level > 2):

            self.changeClefButton = goocanvas.Text(
              parent=self.rootitem,
              x=230,
              y=56,
              width=100,
              text=_("Change Staff\nClef"),
              fill_color="black",
              anchor=gtk.ANCHOR_CENTER,
              alignment=pango.ALIGN_CENTER
              )

        if (level >= 3):
            goocanvas.Text(
              parent=self.rootitem,
              x=680,
              y=50,
              width=100,
              text=_("Change Note Type"),
              fill_color="black",
              anchor=gtk.ANCHOR_CENTER,
              alignment=pango.ALIGN_CENTER
              )


            self.quarterNoteSelectedButton = goocanvas.Image(
                parent=self.rootitem,
                pixbuf=gcompris.utils.load_pixmap('piano_player/quarterNote.png'),
                x=630,
                y=80,
                height=45,
                width=20
                )

            self.halfNoteSelected = goocanvas.Image(
                parent=self.rootitem,
                pixbuf=gcompris.utils.load_pixmap('piano_player/halfNote.png'),
                x=660,
                y=80,
                height=45,
                width=20
                )

            self.wholeNoteSelected = goocanvas.Image(
                parent=self.rootitem,
                pixbuf=gcompris.utils.load_pixmap('piano_player/wholeNote.png'),
                x=700,
                y=80,
                height=45,
                width=20
                )

        if (level == 6):
            self.loadButton = goocanvas.Image(
                parent=self.rootitem,
                pixbuf=gcompris.utils.load_pixmap('piano_player/tool-load.png'),
                x=200,
                y=100,
                height=40,
                width=40
                )

            self.saveButton = goocanvas.Image(
                parent=self.rootitem,
                pixbuf=gcompris.utils.load_pixmap('piano_player/tool-save.png'),
                x=260,
                y=100,
                height=40,
                width=40
                )

        '''
        create staff instance to manage music data
        treble clef image loaded by default; click button to switch to bass clef
        '''

        if level == 2:
            self.staff = BassStaff(380, 170, self.rootitem)
            self.staff.drawStaff(text='Click a colored box on the keyboard')
        else:
            self.staff = TrebleStaff(380, 170, self.rootitem)
            self.staff.drawStaff(text='Click a colored box on the keyboard')


        '''
        synchronize buttons with events
        '''
        if level > 2:
            self.changeClefButton.connect("button_press_event", self.change_clef_event)
            gcompris.utils.item_focus_init(self.changeClefButton, None)

        self.colorCodeNotesButton.connect("button_press_event", self.color_code_notes)
        gcompris.utils.item_focus_init(self.colorCodeNotesButton, None)

        self.eraseNotesButton.connect("button_press_event", self.staff.eraseOneNote)
        gcompris.utils.item_focus_init(self.eraseNotesButton, None)

        self.eraseAllButton.connect("button_press_event", self.staff.eraseAllNotes)
        gcompris.utils.item_focus_init(self.eraseAllButton, None)

        self.playCompositionButton.connect("button_press_event", self.staff.playComposition)
        gcompris.utils.item_focus_init(self.playCompositionButton, None)

        if level >= 3:
            self.quarterNoteSelectedButton.connect("button_press_event", self.staff.updateToQuarter)
            gcompris.utils.item_focus_init(self.quarterNoteSelectedButton, None)

            self.halfNoteSelected.connect("button_press_event", self.staff.updateToHalf)
            gcompris.utils.item_focus_init(self.halfNoteSelected, None)

            self.wholeNoteSelected.connect("button_press_event", self.staff.updateToWhole)
            gcompris.utils.item_focus_init(self.wholeNoteSelected, None)

        if level == 6:
            self.saveButton.connect("button_press_event", self.save_file_event)
            gcompris.utils.item_focus_init(self.saveButton, None)

            self.loadButton.connect("button_press_event", self.load_file_event)
            gcompris.utils.item_focus_init(self.loadButton, None)


        '''
        create piano keyboard for use on every level
        optionally specify to display the "black keys"
        '''
        k = PianoKeyboard(50, 160, self.rootitem)
        if level == 5:
            k.sharpNotation = False
            k.blackKeys = True
        elif level == 4 or level == 6:
            k.blackKeys = True
            k.sharpNotation = True

        k.draw(300, 200, self.keyboard_click)




        Prop = gcompris.get_properties()
        if not (Prop.fx):
            gcompris.utils.dialog(_("Error: This activity cannot be \
played with the\nsound effects disabled.\nGo to the configuration \
dialogue to\nenable the sound."), stop_board)
Example #22
0
    def start(self):
        self.saved_policy = gcompris.sound.policy_get()
        gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)

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

        # pause the bg music
        #print "pause sound"
        gcompris.sound.pause()

        self.timers = []
        self.solution = []
        self.kidstry = []
        self.in_repeat = 0
        self.theme = 0

        #
        # This list contains the 'theme' for each melody level.
        #
        self.melodylist = \
                          [
          # xylophon
          [
          {'theme': "xylofon", 'background': "melody/xylofon_background.svg", 'hittool': "melody/xylofon_cursor.png", 'hitofset_x': 50, 'hitofset_y': 50},
          [ {'x': 150.0, 'y': 101.0,  'image': "melody/xylofon_son1.svg", 'sound': "melody/xylofon_son1.ogg"},
            {'x': 284.0, 'y': 118.0,  'image': "melody/xylofon_son2.svg", 'sound': "melody/xylofon_son2.ogg"},
            {'x': 412.0, 'y': 140.0, 'image': "melody/xylofon_son3.svg", 'sound': "melody/xylofon_son3.ogg"},
            {'x': 546.0, 'y': 157.0, 'image': "melody/xylofon_son4.svg", 'sound': "melody/xylofon_son4.ogg"} ] ],

          # guitar
          [
          {'theme': "guitar", 'background': "melody/guitar_background.svg", 'hittool': "melody/guitar_cursor.svg", 'hitofset_x': 400, 'hitofset_y': -5},
          [ {'x': 0, 'y': 170.0,  'image': "melody/guitar_son1.png", 'sound': "melody/guitar_son1.ogg"},
            {'x': 0, 'y': 230.0,  'image': "melody/guitar_son2.png", 'sound': "melody/guitar_son2.ogg"},
            {'x': 0, 'y': 290.0, 'image': "melody/guitar_son3.png", 'sound': "melody/guitar_son3.ogg"},
            {'x': 0, 'y': 350.0, 'image': "melody/guitar_son4.png", 'sound': "melody/guitar_son4.ogg"} ] ],

          # Kitchen
          [
          {'theme': "tachos", 'background': "melody/tachos_background.jpg", 'hittool': "melody/tachos_cursor.png", 'hitofset_x': 50, 'hitofset_y': 50},
          [ {'x': 150.0, 'y': 50.0,  'image': "melody/tachos_son1.png", 'sound': "melody/tachos_son1.ogg"},
            {'x': 550.0, 'y': 50.0,  'image': "melody/tachos_son2.png", 'sound': "melody/tachos_son2.ogg"},
            {'x': 150.0, 'y': 250.0, 'image': "melody/tachos_son3.png", 'sound': "melody/tachos_son3.ogg"},
            {'x': 550.0, 'y': 250.0, 'image': "melody/tachos_son4.png", 'sound': "melody/tachos_son4.ogg"} ] ] ]

        self.maxtheme = len(self.melodylist) - 1
        self.gcomprisBoard.maxlevel = 9

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

        self.pause(1)
        self.display_current_level()

        Prop = gcompris.get_properties()

        if (not Prop.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)