Example #1
0
    def __add_columns_group(self, treeview):

        model = treeview.get_model()

        # columns for name
        renderer = gtk.CellRendererText()
        renderer.connect("edited", self.on_cell_group_edited, model)
        renderer.set_data("column", COLUMN_NAME)
        column = gtk.TreeViewColumn(_('Group'), renderer, text=COLUMN_NAME)
        column.set_sort_column_id(COLUMN_NAME)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_GROUPNAME)
        treeview.append_column(column)

        # columns for description
        renderer = gtk.CellRendererText()
        renderer.connect("edited", self.on_cell_group_edited, model)
        renderer.set_data("column", COLUMN_DESCRIPTION)
        column = gtk.TreeViewColumn(_('Description'),
                                    renderer,
                                    text=COLUMN_DESCRIPTION)
        column.set_sort_column_id(COLUMN_DESCRIPTION)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_GROUPDESCRIPTION)
        treeview.append_column(column)
Example #2
0
    def config_start(self, profile):
        # keep profile in mind
        self.configuring_profile = profile

        # init with default values
        self.config_dict = self.init_config()

        # get the configured values for that profile
        self.config_dict.update(gcompris.get_conf(profile, self.gcomprisBoard))

        # Init configuration window:
        # all the configuration functions will use it
        # all the configuration functions returns values for their key in
        # the dict passed to the apply_callback
        # the returned value is the main GtkVBox of the window,
        # we can add what you want in it.

        bconf = gcompris.configuration_window(
            _("<b>%s</b> configuration\n for profile <b>%s</b>") % ("Login", (profile.name if profile else "")),
            self.ok_callback,
        )

        # toggle box
        uppercase = gcompris.boolean_box(
            bconf, _("Uppercase only text"), "uppercase_only", eval(self.config_dict["uppercase_only"])
        )

        # uppercase.set_sensitive(False)

        gcompris.separator(bconf)

        # toggle box
        entry_text = gcompris.boolean_box(
            bconf, _("Enter login to log in"), "entry_text", eval(self.config_dict["entry_text"])
        )
Example #3
0
    def display_question(self, datasetlevel, object_target):
        # The question
        text = datasetlevel.question_text
        if text:
            try:
                # The question can be formatted with {text} and if so this
                # is replaced by the target name
                text = _(text.format(text=_(object_target.text)))
            except:
                pass
        else:
            text = _(object_target.text)

        try:
            # The question can be formatted with {audio} and if so this
            # is replaced by the target name
            text = _(text.format(audio=_(object_target.audio)))
        except:
            pass

        if self.selected:
            self.selected.select(False)

        self.question_text_item.props.text = text
        self.play_audio_question(datasetlevel.question_audio, object_target)
Example #4
0
  def calculate(self, x_center, y_center):
    # Check current speed against required orbital speed
    self.orbital_speed = math.sqrt(abs(self.mass/self.distance))
    difference = abs(self.speed) - self.orbital_speed
    self.distance += difference / 5

    # Give user some hint on our orbital situation
    if difference > 0.25:
      self.game.message.show( _("Satellite goes too fast") )
    elif difference < -0.25:
      self.game.message.show( _("Satellite goes too slow") )
    else:
      self.game.message.hide()

    self.game.distanceIndicator.show( 'Distance: {:.1f}'.format(self.distance) )

    if abs(difference) < 0.5:
      value = self.revolve(x_center, y_center, 0)
      return value
    elif difference < 0:
      value = self.crash(x_center, y_center)
      return value
    else:
      value = self.fly_off(x_center, y_center)
      return value
Example #5
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)
Example #6
0
    def __add_columns(self, treeview):

        model = treeview.get_model()

        # columns for first name
        renderer = gtk.CellRendererText()
        renderer.set_data("column", COLUMN_FIRSTNAME)
        column = gtk.TreeViewColumn(_('First Name'), renderer,
                                    text=COLUMN_FIRSTNAME,
                                    editable=COLUMN_USER_EDITABLE)
        column.set_sort_column_id(COLUMN_FIRSTNAME)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_FIRSTNAME)
        treeview.append_column(column)

        # column for last name
        renderer = gtk.CellRendererText()
        renderer.set_data("column", COLUMN_LASTNAME)
        column = gtk.TreeViewColumn(_('Last Name'), renderer,
                                    text=COLUMN_LASTNAME,
                                    editable=COLUMN_USER_EDITABLE)
        column.set_sort_column_id(COLUMN_LASTNAME)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_LASTNAME)
        treeview.append_column(column)
Example #7
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 #8
0
    def ok(self, button):

        # Tell the user he must provide enough information
        if self.entry_group.get_text() == "":
            dialog = gtk.MessageDialog(
                None,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_INFO,
                gtk.BUTTONS_OK,
                _("You need to provide at least a name for your group"),
            )
            dialog.run()
            dialog.destroy()
            return

        # If the group name as changed, check it does not exists already
        if self.entry_group.get_text() != self.group_name:
            # Check the group does not exist already
            self.cur.execute("SELECT name FROM groups WHERE name=?", (unicode(self.entry_group.get_text()),))
            if self.cur.fetchone():
                dialog = gtk.MessageDialog(
                    None,
                    gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                    gtk.MESSAGE_INFO,
                    gtk.BUTTONS_OK,
                    _("There is already a group with this name"),
                )
                dialog.run()
                dialog.destroy()
                return

        #
        # Now everything is correct, create the group
        #

        group_data = (
            self.group_id,
            unicode(self.entry_group.get_text()),
            self.class_id,
            unicode(self.entry_description.get_text()),
        )

        if self.new_group:
            # Create the new group
            group_id = constants.get_next_group_id(self.con, self.cur)
            self.cur.execute(
                "INSERT INTO groups (group_id, name, class_id, description) " + "VALUES ( ?, ?, ?, ?)", (group_data)
            )
        else:
            # Save the group changes
            self.cur.execute(
                "UPDATE groups SET name=?, description=? where group_id=?",
                (self.entry_group.get_text(), self.entry_description.get_text(), self.group_id),
            )
        self.con.commit()

        # Close the dialog window now
        self.group_user.reload_group()

        self.destroy()
Example #9
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 #10
0
    def __add_columns(self, treeview):

        model = treeview.get_model()

        # columns for class name
        renderer = gtk.CellRendererText()
        renderer.set_data("column", COLUMN_CLASSNAME)
        column = gtk.TreeViewColumn(_('Class'), renderer,
                                    text=COLUMN_CLASSNAME)
        column.set_sort_column_id(COLUMN_CLASSNAME)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_CLASSNAME)
        treeview.append_column(column)

        # columns for group name
        renderer = gtk.CellRendererText()
        renderer.set_data("column", COLUMN_GROUPNAME)
        column = gtk.TreeViewColumn(_('Group'), renderer,
                                    text=COLUMN_GROUPNAME)
        column.set_sort_column_id(COLUMN_GROUPNAME)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_GROUPNAME)
        treeview.append_column(column)

        # column for description
        renderer = gtk.CellRendererText()
        renderer.set_data("column", COLUMN_DESCRIPTION)
        column = gtk.TreeViewColumn(_('Description'), renderer,
                                    text=COLUMN_DESCRIPTION)
        column.set_sort_column_id(COLUMN_DESCRIPTION)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_GROUPDESCRIPTION_EDIT)
        treeview.append_column(column)
Example #11
0
    def clue_left(self, event, target, item):
        self.callout1 = goocanvas.Image(
            parent=self.root,
            pixbuf=gcompris.utils.load_pixmap("braille_lotto/callout1.svg"),
            x=230,
            y=250,
        )
        self.status_one = goocanvas.Text(
            parent=self.root,
            text="",
            x=315,
            y=310,
            width=130,
            font=gcompris.skin.get_font("gcompris/board/small"),
            anchor=gtk.ANCHOR_CENTER,
        )

        if (self.check_random[self.counter] in self.ticket_array[0:6]):
            #Translators : Do not translate the token {column}
            self.status_one.props.text = \
                _("Hey, you have it. It is there in your {column} column").format( column = self.findColumn() )
        else:
            self.status_one.props.text = _(
                "Oops, this number is not in your ticket!")
        self.timerAnim = gobject.timeout_add(1500, self.hideCalloutLeft)
Example #12
0
  def __add_columns_group(self, treeview):

    model = treeview.get_model()

    # columns for name
    renderer = gtk.CellRendererText()
    renderer.connect("edited", self.on_cell_group_edited, model)
    renderer.set_data("column", COLUMN_NAME)
    column = gtk.TreeViewColumn(_('Group'), renderer,
                                text=COLUMN_NAME)
    column.set_sort_column_id(COLUMN_NAME)
    column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
    column.set_fixed_width(constants.COLUMN_WIDTH_GROUPNAME)
    treeview.append_column(column)

    # columns for description
    renderer = gtk.CellRendererText()
    renderer.connect("edited", self.on_cell_group_edited, model)
    renderer.set_data("column", COLUMN_DESCRIPTION)
    column = gtk.TreeViewColumn(_('Description'), renderer,
                                text=COLUMN_DESCRIPTION)
    column.set_sort_column_id(COLUMN_DESCRIPTION)
    column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
    column.set_fixed_width(constants.COLUMN_WIDTH_GROUPDESCRIPTION)
    treeview.append_column(column)
Example #13
0
  def start(self, area):
    # Connect to our database
    self.con = sqlite.connect(gcompris.get_database())
    self.cur = self.con.cursor()

    if Reports.already_loaded:
      self.rootitem.props.visibility = goocanvas.ITEM_VISIBLE
      self.logList.show(self.con, self.cur)
      return

    Reports.already_loaded = True

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

    # Call our parent start
    module.Module.start(self)

    frame = gtk.Frame(_("Users") + " / " + _("Reports") )
    frame.show()

    goocanvas.Widget(
        parent = self.rootitem,
        widget = frame,
        x=area[0]+self.module_panel_ofset,
        y=area[1]+self.module_panel_ofset,
        width=area[2]-area[0]-2*self.module_panel_ofset,
        height=area[3]-area[1]-2*self.module_panel_ofset,
        anchor=gtk.ANCHOR_NW)

    self.logList = log_list.Log_list(frame, self.con, self.cur)
    self.logList.init()
Example #14
0
    def __add_columns(self, treeview):

        model = treeview.get_model()

        # columns for first name
        renderer = gtk.CellRendererText()
        renderer.set_data("column", COLUMN_FIRSTNAME)
        column = gtk.TreeViewColumn(_('First Name'), renderer,
                                    text=COLUMN_FIRSTNAME,
                                    editable=COLUMN_USER_EDITABLE)
        column.set_sort_column_id(COLUMN_FIRSTNAME)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_FIRSTNAME)
        treeview.append_column(column)

        # column for last name
        renderer = gtk.CellRendererText()
        renderer.set_data("column", COLUMN_LASTNAME)
        column = gtk.TreeViewColumn(_('Last Name'), renderer,
                                    text=COLUMN_LASTNAME,
                                    editable=COLUMN_USER_EDITABLE)
        column.set_sort_column_id(COLUMN_LASTNAME)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        column.set_fixed_width(constants.COLUMN_WIDTH_LASTNAME)
        treeview.append_column(column)
Example #15
0
    def config_start(self, profile):
        # keep profile in mind
        self.configuring_profile = profile

        # init with default values
        self.config_dict = self.init_config()

        #get the configured values for that profile
        self.config_dict.update(gcompris.get_conf(profile, self.gcomprisBoard))

        # Init configuration window:
        # all the configuration functions will use it
        # all the configuration functions returns values for their key in
        # the dict passed to the apply_callback
        # the returned value is the main GtkVBox of the window,
        #we can add what you want in it.

        bconf = gcompris.configuration_window ( \
          _('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Login', profile.name ),
          self.ok_callback
          )

        # toggle box
        uppercase = gcompris.boolean_box(
            bconf, _('Uppercase only text'), 'uppercase_only',
            eval(self.config_dict['uppercase_only']))

        #uppercase.set_sensitive(False)

        gcompris.separator(bconf)

        # toggle box
        entry_text = gcompris.boolean_box(bconf, _('Enter login to log in'),
                                          'entry_text',
                                          eval(self.config_dict['entry_text']))
Example #16
0
  def calculate(self, x_center, y_center):
    # Check current speed against required orbital speed
    self.orbital_speed = math.sqrt(abs(self.mass/self.distance))
    difference = abs(self.speed) - self.orbital_speed
    self.distance += difference / 5

    # Give user some hint on our orbital situation
    if difference > 0.25:
      self.game.message.show( _("Satellite goes too fast") )
    elif difference < -0.25:
      self.game.message.show( _("Satellite goes too slow") )
    else:
      self.game.message.hide()

    self.game.distanceIndicator.show( _("Distance: {:.1f}").format(self.distance) )

    if abs(difference) < 0.5:
      value = self.revolve(x_center, y_center, 0)
      return value
    elif difference < 0:
      value = self.crash(x_center, y_center)
      return value
    else:
      value = self.fly_off(x_center, y_center)
      return value
Example #17
0
  def start(self, area):
      # Connect to our database
      self.con = sqlite.connect(gcompris.get_database())
      self.cur = self.con.cursor()

      # 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.canvas,
          )

      # Call our parent start
      module.Module.start(self)

      frame = gtk.Frame(_("Classes") + " / " + _("Users") )
      frame.show()

      goocanvas.Widget(
        parent = self.rootitem,
        widget=frame,
        x=area[0]+self.module_panel_ofset,
        y=area[1]+self.module_panel_ofset,
        width=area[2]-area[0]-2*self.module_panel_ofset,
        height=area[3]-area[1]-2*self.module_panel_ofset,
        anchor=gtk.ANCHOR_NW)


      class_list.Class_list(frame, self.con, self.cur)
Example #18
0
  def display_question(self, datasetlevel, object_target):
    # The question
    text = datasetlevel.question_text
    if text:
      try:
        # The question can be formatted with {text} and if so this
        # is replaced by the target name
        text = _(text.format(text = _(object_target.text)))
      except:
        pass
    else:
      text = _(object_target.text)

    try:
      # The question can be formatted with {audio} and if so this
      # is replaced by the target name
      text = _(text.format(audio = _(object_target.audio)))
    except:
      pass

    if self.selected:
      self.selected.select(False)

    self.question_text_item.props.text = text
    self.play_audio_question(datasetlevel.question_audio, object_target)
Example #19
0
    def start(self, area):
        # Connect to our database
        self.con = sqlite.connect(gcompris.get_database())
        self.cur = self.con.cursor()

        # 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.canvas, )

        # Call our parent start
        module.Module.start(self)

        frame = gtk.Frame(_("Classes") + " / " + _("Users"))
        frame.show()

        goocanvas.Widget(parent=self.rootitem,
                         widget=frame,
                         x=area[0] + self.module_panel_ofset,
                         y=area[1] + self.module_panel_ofset,
                         width=area[2] - area[0] - 2 * self.module_panel_ofset,
                         height=area[3] - area[1] -
                         2 * self.module_panel_ofset,
                         anchor=gtk.ANCHOR_NW)

        class_list.Class_list(frame, self.con, self.cur)
Example #20
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)
Example #21
0
  def __add_columns(self, treeview):

    model = treeview.get_model()

    # Total column lengh must be 400

    # columns for class name
    renderer = gtk.CellRendererText()
    renderer.set_data("column", COLUMN_CLASSNAME)
    column = gtk.TreeViewColumn(_('Class'), renderer,
                                text=COLUMN_CLASSNAME)
    column.set_sort_column_id(COLUMN_CLASSNAME)
    column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
    column.set_fixed_width(constants.COLUMN_WIDTH_CLASSNAME)
    treeview.append_column(column)

    # columns for name
    renderer = gtk.CellRendererText()
    renderer.set_data("column", COLUMN_GROUPNAME)
    column = gtk.TreeViewColumn(_('Group'), renderer,
                                text=COLUMN_GROUPNAME)
    column.set_sort_column_id(COLUMN_GROUPNAME)
    column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
    column.set_fixed_width(constants.COLUMN_WIDTH_GROUPNAME)
    treeview.append_column(column)

    # columns for description
    renderer = gtk.CellRendererText()
    renderer.set_data("column", COLUMN_DESCRIPTION)
    column = gtk.TreeViewColumn(_('Description'), renderer,
                                text=COLUMN_DESCRIPTION)
    column.set_sort_column_id(COLUMN_DESCRIPTION)
    column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
    column.set_fixed_width(constants.COLUMN_WIDTH_GROUPDESCRIPTION)
    treeview.append_column(column)
Example #22
0
    def start(self, area):
        # Connect to our database
        self.con = sqlite.connect(gcompris.get_database())
        self.cur = self.con.cursor()

        if Reports.already_loaded:
            self.rootitem.props.visibility = goocanvas.ITEM_VISIBLE
            self.logList.show(self.con, self.cur)
            return

        Reports.already_loaded = True

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

        # Call our parent start
        module.Module.start(self)

        frame = gtk.Frame(_("Users") + " / " + _("Reports"))
        frame.show()

        goocanvas.Widget(parent=self.rootitem,
                         widget=frame,
                         x=area[0] + self.module_panel_ofset,
                         y=area[1] + self.module_panel_ofset,
                         width=area[2] - area[0] - 2 * self.module_panel_ofset,
                         height=area[3] - area[1] -
                         2 * self.module_panel_ofset,
                         anchor=gtk.ANCHOR_NW)

        self.logList = log_list.Log_list(frame, self.con, self.cur)
        self.logList.init()
Example #23
0
    def enter_callback(self, widget):
        text = widget.get_text()

        # Find a number game
        if str(self.solution) == text:
            self.indicator.props.text = ""
            self.gamewon = True
            gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.TUX)
        else:
            try:
                number = int(text)
            except:
                self.indicator.props.text = \
                    _("Please enter a number between {0} and {1}").format(self.min, self.max)
                widget.set_text('')
                return

            if number > self.max or number <= 0:
                self.indicator.props.text = _("Out of range")
            else:
                max_distance = max(self.max - self.solution, self.solution)
                distance_x = self.target_x - abs(
                    self.solution - number) * float(self.target_x -
                                                    self.orig_x) / max_distance
                distance_y = self.orig_y + float(
                    ((self.solution - number) * 170) / max_distance)
                if (number > self.solution):
                    self.indicator.props.text = _("Too high")
                else:
                    self.indicator.props.text = _("Too low")

                self.move(self.x_old, self.y_old, distance_x, distance_y)

        widget.set_text('')
Example #24
0
  def enter_callback(self, widget):
    text = widget.get_text()

    # Find a number game
    if str(self.solution) == text:
      self.indicator.props.text = ""
      self.gamewon = True
      gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.TUX)
    else:
      try:
        number = int(text)
      except:
        self.indicator.props.text = \
            _("Please enter a number between {0} and {1}").format(self.min, self.max)
        widget.set_text('')
        return

      if number > self.max or number <= 0:
        self.indicator.props.text = _("Out of range")
      else:
        max_distance = max(self.max - self.solution, self.solution)
        distance_x = self.target_x - abs(self.solution - number) * float(self.target_x - self.orig_x) / max_distance
        distance_y = self.orig_y + float(((self.solution - number) * 170) / max_distance)
        if(number > self.solution):
          self.indicator.props.text=_("Too high")
        else:
          self.indicator.props.text = _("Too low")

        self.move(self.x_old, self.y_old,
                  distance_x,
                  distance_y)

    widget.set_text('')
Example #25
0
    def parseData(self):
        '''
        extract the data from the content file
        '''
        self.sectionNames = []
        errors = []
        for section in self.data.sections():
            if section == 'common':
                try:
                    self.credits = self.data.get('common', 'credits')
                except:
                    self.credits = ''
                try:
                    self.background = self.data.get('common', 'background')
                except:
                    errors.append("Missing 'background' key")
                try:
                    self.backSvgId = self.data.get('common', 'backSvgId')
                except:
                    errors.append("Missing 'background' key")
                try:
                    self.author = self.data.get('common', 'author')
                except:
                    self.author = ''
                try:
                    self.generalText = _(
                        self.data.get('common', '_GeneralText'))
                except:
                    errors.append("Missing '_GeneralText' key")
                try:
                    self.SoundMatchingGameText = _(
                        self.data.get('common', '_SoundMatchingGameText'))
                except:
                    pass
                try:
                    self.TextMatchingGameText = _(
                        self.data.get('common', '_TextMatchingGameText'))
                except:
                    pass
                try:
                    self.textBoxX = int(self.data.get('common', 'textBoxX'))
                except:
                    pass
                try:
                    self.textBoxY = int(self.data.get('common', 'textBoxY'))
                except:
                    pass
            else:
                try:
                    self.allSoundClips.append(
                        (self.data.get(section, 'music'), section))
                except:
                    pass
                self.allTextPrompts.append(
                    (_(self.data.get(section, '_shortPrompt')), section))

                self.sectionNames.append(section)

            if len(errors):
                gcompris.utils.dialog("\n".join(errors), None)
Example #26
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)
Example #27
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)
Example #28
0
def makeNumList(nums):
    if len(nums) == 0:
        return ""
    fmt = '%d'
    if len(nums) >= 2:
        for i in range(1, len(nums) - 1):
            fmt += _(', %d')
        fmt += _(' and %d')
    return fmt
Example #29
0
def makeNumList(nums):
    if len(nums) == 0:
        return ""
    fmt = '%d'
    if len(nums) >= 2:
        for i in range(1, len(nums)-1):
            fmt += _(', %d')
        fmt += _(' and %d')
    return fmt
Example #30
0
 def turn_off_pitch_sound(self, widget=None, target=None, event=None):
     '''
     turn on or off pitch sounds on mouse-over
     '''
     if self.pitchSoundEnabled:
         self.pitchSoundEnabled = False
         self.soundToggle.props.text = _("Click here to hear the pitches.")
     else:
         self.pitchSoundEnabled = True
         self.soundToggle.props.text = _("Ready for a challenge? Turn off pitch sound")
Example #31
0
    def end(self):
        '''
        write locations and common template to content.desktop.in
        '''
        if RECORD_LOCATIONS:
            try: self.data.set('common', 'credits', _('enter a list of credits and links to resources you used here'))
            except: pass
            try: self.data.set('common', 'creator', _('enter your name here!'))
            except: pass
            try: self.data.set('common', 'locationpic', _('enter the filename of the picture you would like to use to identify items to click on your background image'))
            except: pass
            try: self.data.set('common', 'gamewonpic', _('enter the filename of the picture to be shown when the player wins the entire game'))
            except: pass
            try: self.data.set('common', 'generalText', _('enter the text to appear on your image for textMatchingGame'))
            except: pass
            try: self.data.set('common', 'SoundMatchingGameText', _('enter the text to appear on your image for SoundMatchingGame'))
            except: pass
            try: self.data.set('common', 'TextMatchingGameText', _('enter the text to appear on your image for TextMatchingGame'))
            except: pass
            try: self.data.set('common', 'textBoxX', _('enter the x location for the text box to appear in the text matching game'))
            except: pass
            try: self.data.set('common', 'textBoxY', _('enter the x location for the text box to appear in the text matching game'))
            except: pass
            with open(gcompris.DATA_DIR + '/' + self.gcomprisBoard.name + '/content.desktop.in', 'wb') as configfile:
                self.data.write(configfile)

        self.rootitem.remove()
        gcompris.sound.policy_set(self.saved_policy)
        gcompris.sound.resume()
Example #32
0
    def help(self, widget, target, event=None):
        if event.type == gtk.gdk.BUTTON_PRESS:
            if self.balloon.need_reset:
                text = _("Click on the balloon to place it again.")
            else:
                text = _("Click twice on the balloon to shoot it.")

            self.help_item.set_properties(text=text)
            self.help_item.props.visibility = goocanvas.ITEM_VISIBLE

        return False
Example #33
0
 def color_button_toggle(self, widget=None, target=None, event=None):
     '''
     update text color of note buttons
     '''
     if self.colorButtons:
         self.colorButtons = False
         self.colorTextToggle.props.text = _("Need a hint? Click here for color-coded note names.")
     else:
         self.colorButtons = True
         self.colorTextToggle.props.text = _("Ready for a challenge? Color all buttons black!")
     self.drawNoteButtons()
Example #34
0
    def ok(self, button):

        # Tell the user he must provide enough information
        if(self.entry_group.get_text() == ""):
            dialog = gtk.MessageDialog(None,
                                       gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                       gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                                       _("You need to provide at least a name for your group"))
            dialog.run()
            dialog.destroy()
            return

        # If the group name as changed, check it does not exists already
        if(self.entry_group.get_text() != self.group_name):
            # Check the group does not exist already
            self.cur.execute('SELECT name FROM groups WHERE name=?',
                             (self.entry_group.get_text(),))
            if(self.cur.fetchone()):
                dialog = gtk.MessageDialog(None,
                                           gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                           gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                                           _("There is already a group with this name"))
                dialog.run()
                dialog.destroy()
                return

        #
        # Now everything is correct, create the group
        #

        group_data = (self.group_id,
                      self.entry_group.get_text(),
                      self.class_id,
                      self.entry_description.get_text()
                      )

        if(self.new_group):
            # Create the new group
            group_id = constants.get_next_group_id(self.con, self.cur)
            self.cur.execute('INSERT INTO groups (group_id, name, class_id, description) ' +
                             'VALUES ( ?, ?, ?, ?)',
                             (group_data));
        else:
            # Save the group changes
            self.cur.execute('UPDATE groups SET name=?, description=? where group_id=?',
                             (self.entry_group.get_text(),
                              self.entry_description.get_text(),
                              self.group_id));
        self.con.commit()

        # Close the dialog window now
        self.group_user.reload_group()

        self.destroy()
Example #35
0
 def munch(self):
     num = game.squares[self.x][self.y].num
     if num == None:
         return
     if num.good:
         self.startMunching()
     else:
         game.show_message( _("You ate a wrong number.\n") +game.levelset.getError(num) +
                            _("\nPress <Return> to continue.") )
         self.die()
     game.setNum(self.x, self.y, None)
Example #36
0
  def help(self, widget, target, event=None):
    if event.type == gtk.gdk.BUTTON_PRESS:
      if self.balloon.need_reset:
        text=_("Click on the ball to place it again.")
      else:
        text=_("Click twice on the ball to shoot it.")

      self.help_item.set_properties(text = text)
      self.help_item.props.visibility = goocanvas.ITEM_VISIBLE

    return False
Example #37
0
 def findColumn(self):
     if self.check_random[self.counter] <= 25:
         column = _("1st")
     elif self.check_random[self.counter] <= 50 \
           and self.check_random[self.counter] > 25:
         column = _("2nd")
     elif self.check_random[self.counter] <= 75 \
           and self.check_random[self.counter] > 50:
         column = _("3rd")
     else :
         column = _("4th")
     return column
Example #38
0
 def findColumn(self):
     if self.check_random[self.counter] <= 25:
         column = _("1st")
     elif self.check_random[self.counter] <= 50 \
           and self.check_random[self.counter] > 25:
         column = _("2nd")
     elif self.check_random[self.counter] <= 75 \
           and self.check_random[self.counter] > 50:
         column = _("3rd")
     else:
         column = _("4th")
     return column
  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)
Example #40
0
    def getError(self, num):
        fmt = _('%d is divisible by %s.')
        n = int(num.text)

        if n == 1:
            return _("1 is not a prime number.")

        factors = []
        for i in range(2, n/2 + 1):
            if n % i == 0:
                factors.append(i)
        s = makeNumList(factors) % tuple(factors)
        return fmt % (n,s)
Example #41
0
    def getError(self, num):
        fmt = _('{0} is divisible by {1}.')
        n = int(num.text)

        if n == 1:
            return _("1 is not a prime number.")

        factors = []
        for i in range(2, n / 2 + 1):
            if n % i == 0:
                factors.append(i)
        s = makeNumList(factors) % tuple(factors)
        return fmt.format(str(n), s)
 def color_button_toggle(self, widget=None, target=None, event=None):
     '''
     update text color of note buttons
     '''
     if self.colorButtons:
         self.colorButtons = False
         self.colorTextToggle.props.text = _(
             "Need a hint? Click here for color-coded note names.")
     else:
         self.colorButtons = True
         self.colorTextToggle.props.text = _(
             "Ready for a challenge? Color all buttons black!")
     self.drawNoteButtons()
Example #43
0
    def locales_sound(self, button):

        conf_locales = self.get_configured(self.active_profile, 'locale_sound',
                                           'NULL')
        bconf = gcompris.configuration_window ( \
          _('<b>Locale sound</b> configuration\n for profile <b>{profile}</b>').\
            format(profile=self.active_profile.name),
          self.ok_callback
          )

        gcompris.combo_locales_asset(bconf, _("Select sound locale"),
                                     conf_locales,
                                     "voices/$LOCALE/colors/red.ogg")
Example #44
0
    def ok(self, button):

        # Tell the user he must provide enough information
        if(self.entry_profile.get_text().strip() == ""):
            dialog = gtk.MessageDialog(None,
                                       gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                       gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                                       _("You need to provide at least a name for your profile"))
            dialog.run()
            dialog.destroy()
            return

        #
        # Now everything is correct, create the profile
        #

        profile_data = (self.profile_id,
                        self.entry_profile.get_text().strip(),
                        self.entry_description.get_text()
                      )

        if(self.new_profile):
            # Check the login do not exist already
            self.cur.execute('SELECT name FROM profiles WHERE name=?',
                             (self.entry_profile.get_text(),))
            if(self.cur.fetchone()):
                dialog = gtk.MessageDialog(None,
                                           gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                           gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                                           _("There is already a profile with this name"))
                dialog.run()
                dialog.destroy()
                return

            # Create the new profile
            profile_id = constants.get_next_profile_id(self.con, self.cur)
            self.cur.execute('INSERT INTO profiles (profile_id, name, description) ' +
                             'VALUES ( ?, ?, ?)',
                             (profile_data));
        else:
            # Save the profile changes
            self.cur.execute('UPDATE profiles SET name=?, description=? where profile_id=?',
                             (self.entry_profile.get_text(),
                              self.entry_description.get_text(),
                              self.profile_id));
        self.con.commit()

        # Close the dialog window now
        self.profile_list.reload_profile()

        self.destroy()
Example #45
0
    def ok(self, button):

        # Tell the user he must provide enough information
        if (self.entry_login.get_text() == ""
                or self.entry_firstname.get_text() == ""
                or self.entry_lastname.get_text() == ""):
            dialog = gtk.MessageDialog(
                None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                _("You need to provide at least a login, first name and last name for your users"
                  ))
            dialog.run()
            dialog.destroy()
            return

        if (self.new_user):
            # Check the login do not exist already
            self.cur.execute('SELECT login FROM users')
        else:
            self.cur.execute('SELECT login FROM users WHERE login != \'%s\'' %
                             self.old_login)
        logins = [x[0].upper() for x in self.cur.fetchall()]
        login = self.entry_login.get_text().decode('utf-8').upper()

        if login in logins:
            dialog = gtk.MessageDialog(
                None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                _("There is already a user with this login"))
            dialog.run()
            dialog.destroy()
            return

        #
        # Now everything is correct, create the user
        #
        user_data = (self.user_id, self.entry_login.get_text(),
                     self.entry_firstname.get_text(),
                     self.entry_lastname.get_text(),
                     self.entry_birthdate.get_text(), self.class_id)
        # Save the changes in the base
        self.cur.execute(
            'insert or replace into users (user_id, login, firstname, lastname, birthdate, class_id) values (?, ?, ?, ?, ?, ?)',
            user_data)
        self.con.commit()

        # Close the dialog window now
        self.list_user.reload(self.class_id)

        self.destroy()
Example #46
0
  def locales_sound(self, button):

    conf_locales = self.get_configured(self.active_profile,
                                       'locale_sound', 'NULL')
    bconf = gcompris.configuration_window ( \
      _('<b>Locale sound</b> configuration\n for profile <b>{profile}</b>').\
        format(profile=self.active_profile.name),
      self.ok_callback
      )

    gcompris.combo_locales_asset( bconf,
                                  _("Select sound locale"),
                                  conf_locales,
                                  "voices/$LOCALE/colors/red.ogg" )
Example #47
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()
Example #48
0
    def updateBoard(self, currentStep):

        if not self.running:
            return

        if self.gcomprisBoard.level in [2, 4, 6, 8, 10, 12
                                        ] and currentStep == 1:
            currentStep = 2
        if currentStep == 1:  # the rhythm is being played
            self.makePlayButtonVisible(False)
            self.makeDrumButtonVisible(False)
            self.makeEraseButtonVisible(False)

        elif currentStep == 2:  # the student should enter the rhythm into the drum
            self.makeDrumButtonVisible(True)
            self.makePlayButtonVisible(True)
            self.makeEraseButtonVisible(False)

        elif currentStep == 3:  # the erase options should appear
            self.makePlayButtonVisible(False)
            if not self.check_and_win():
                self.makeEraseButtonVisible(True)

        if self.gcomprisBoard.level in [2, 4, 6, 8, 10, 12]:
            self.makeMetronomeButtonVisible(True)
        else:
            self.makeMetronomeButtonVisible(False)

        if self.gcomprisBoard.level in [1, 3, 5, 7, 9, 11]:
            if currentStep == 1:
                text = _("Listen to the rhythm and follow the moving line.")
            elif currentStep == 2:
                text = _("Click the drum to the tempo. Watch the vertical line when you start.") \
                    + "\n" + _("You can use the space bar to drum the tempo.")

        else:
            text = _(
                "Now, read the rhythm. It won't be played for you. Then, beat the rhythm on the drum."
            )

        if currentStep == 3:
            text = _("Click erase to try again.")

        if hasattr(self, 'text'):
            self.text.remove()
            self.rect.remove()
        self.text, self.rect = \
            textBox(text, 400, 400, self.rootitem, width=420,
                    fill_color_rgba = 0x666666AAL)
Example #49
0
    def ok(self, button):

        # Tell the user he must provide enough information
        if (self.entry_profile.get_text().strip() == ""):
            dialog = gtk.MessageDialog(
                None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                _("You need to provide at least a name for your profile"))
            dialog.run()
            dialog.destroy()
            return

        #
        # Now everything is correct, create the profile
        #

        profile_data = (self.profile_id, self.entry_profile.get_text().strip(),
                        self.entry_description.get_text())

        if (self.new_profile):
            # Check the login do not exist already
            self.cur.execute('SELECT name FROM profiles WHERE name=?',
                             (self.entry_profile.get_text(), ))
            if (self.cur.fetchone()):
                dialog = gtk.MessageDialog(
                    None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                    gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                    _("There is already a profile with this name"))
                dialog.run()
                dialog.destroy()
                return

            # Create the new profile
            profile_id = constants.get_next_profile_id(self.con, self.cur)
            self.cur.execute(
                'INSERT INTO profiles (profile_id, name, description) ' +
                'VALUES ( ?, ?, ?)', (profile_data))
        else:
            # Save the profile changes
            self.cur.execute(
                'UPDATE profiles SET name=?, description=? where profile_id=?',
                (self.entry_profile.get_text(),
                 self.entry_description.get_text(), self.profile_id))
        self.con.commit()

        # Close the dialog window now
        self.profile_list.reload_profile()

        self.destroy()
Example #50
0
    def ok(self, button):

        # Tell the user he must provide enough information
        if(self.entry_login.get_text() == "" or
           self.entry_firstname.get_text() == "" or
           self.entry_lastname.get_text() == ""):
            dialog = gtk.MessageDialog(None,
                                       gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                       gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                                       _("You need to provide at least a login, first name and last name for your users"))
            dialog.run()
            dialog.destroy()
            return

        if(self.new_user):
            # Check the login do not exist already
            self.cur.execute('SELECT login FROM users')
        else:
            self.cur.execute('SELECT login FROM users WHERE login != \'%s\'' % self.old_login)
        logins = [x[0].upper() for x in self.cur.fetchall()]
        login = self.entry_login.get_text().decode('utf-8').upper()

        if login in logins:
            dialog = gtk.MessageDialog(None,
                                       gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                       gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                                       _("There is already a user with this login"))
            dialog.run()
            dialog.destroy()
            return

        #
        # Now everything is correct, create the user
        #
        user_data = (self.user_id,
                     unicode(self.entry_login.get_text()),
                     unicode(self.entry_firstname.get_text()),
                     unicode(self.entry_lastname.get_text()),
                     self.entry_birthdate.get_text(),
                     self.class_id
                     )
        # Save the changes in the base
        self.cur.execute('insert or replace into users (user_id, login, firstname, lastname, birthdate, class_id) values (?, ?, ?, ?, ?, ?)', user_data)
        self.con.commit()

        # Close the dialog window now
        self.list_user.reload(self.class_id)

        self.destroy()
Example #51
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 #52
0
  def start(self):
    print "pythontemplate start"

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

    goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=100.0,
      text=_("This is the first plugin in GCompris coded in the Python\n"
             "Programming language."),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )
Example #53
0
    def parse(self, elem, translations):
        for e in elem.childNodes:
            if isNode(e, "image"):
                if e.firstChild:
                    self.image = e.firstChild.nodeValue
                else:
                    self.valid = False
            elif isNode(e, "description"):
                self.description = e.firstChild.nodeValue if e.firstChild else None
            elif isNode(e, "voice"):
                if e.firstChild:
                    self.voice = e.firstChild.nodeValue
                else:
                    self.valid = False
            elif isNode(e, "type"):
                self.type = e.firstChild.nodeValue if e.firstChild else None

        if self.valid:
            if not gcompris.utils.find_file_absolute(self.image):
                self.valid = False
            elif not gcompris.utils.find_file_absolute(self.voice):
                self.valid = False

        # Get the translation
        if self.valid:
            try:
                # The file name
                fileName = self.voice.rsplit("/", 1)[1]
                self.descriptionTranslated = translations[fileName]
            except:
                self.descriptionTranslated = \
                    _("Missing translation for '{word}'".format(word = self.description))
Example #54
0
    def playRandomText(self):

        if self.textPromptsRemaining:
            self.currentTextSelection = \
            self.textPromptsRemaining[randint(0, len(self.textPromptsRemaining) - 1)]

        self.text = goocanvas.Text(
            parent=self.rootitem, x=self.textBoxX, y=self.textBoxY, width=200,
            text=_(self.currentTextSelection[0]),
            fill_color='black', anchor=gtk.ANCHOR_CENTER,
            alignment=pango.ALIGN_CENTER,

            )
        TG = 10
        bounds = self.text.get_bounds()

        rect = goocanvas.Rect(parent=self.rootitem,
                              x=bounds.x1 - TG,
                              y=bounds.y1 - TG,
                              width=bounds.x2 - bounds.x1 + TG * 2,
                              height=bounds.y2 - bounds.y1 + TG * 2,
                              line_width=3.0)
        rect.props.fill_color = 'gray'
        rect.props.stroke_color = 'blach'
        self.text.raise_(rect)
  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)
Example #56
0
    def __init__(self, rootitem, x, y, width, height, number_of_sections):
        '''
        display an empty progress bar
        '''
        self.rootitem = rootitem
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.number_of_sections = number_of_sections

        txt2 = _('Explore Status:')
        item = goocanvas.Text(
            parent=self.rootitem,
            x=self.x,
            y=self.y,
            text='<span font_family="URW Gothic L" size="medium" \
          weight="bold" style="italic">' + txt2 + '</span>',
            use_markup=True)

        bounds = item.get_bounds()
        # This is the start of the bar
        self.x += bounds.x2 - bounds.x1 + 20
        self.progressBar = goocanvas.Rect(parent=self.rootitem,
                                          x=self.x,
                                          y=self.y,
                                          width=self.width,
                                          height=self.height,
                                          stroke_color="black",
                                          fill_color_rgba=0x666666AAL,
                                          line_width=2.0,
                                          radius_x=3,
                                          radius_y=3)
Example #57
0
  def add_log_in_model(self, model, alog):
    iter = model.append()

    status = "Lost"
    if  alog[COLUMN_STATUS] == gcompris.bonus.WIN:
        status = "Win"
    elif  alog[COLUMN_STATUS] == gcompris.bonus.DRAW:
        status = "Draw"
    elif  alog[COLUMN_STATUS] == gcompris.bonus.COMPLETED:
        status = "Compl."

    # This is the name of the Default user profile
    login = _("Default")
    self.cur.execute('SELECT login FROM users WHERE user_id=?', (alog[COLUMN_USER],))
    result = self.cur.fetchall()
    if(result):
        login = result[0][0]

    board = ""
    self.cur.execute('SELECT name FROM boards WHERE board_id=?', (alog[COLUMN_BOARD],))
    result = self.cur.fetchall()
    if(result):
        board = result[0][0]

    model.set (iter,
               COLUMN_DATE,     alog[COLUMN_DATE],
               COLUMN_USER,     login,
               COLUMN_BOARD,    board,
               COLUMN_LEVEL,    alog[COLUMN_LEVEL],
               COLUMN_SUBLEVEL, alog[COLUMN_SUBLEVEL],
               COLUMN_DURATION, alog[COLUMN_DURATION],
               COLUMN_STATUS,   status,
               )
Example #58
0
    def ok(self, entry_profile, entry_description):
        #
        # Now everything is correct, create the profile
        #

        profile_data = (self.profile_id, entry_profile, entry_description)

        if (self.new_profile):
            # Check the login do not exist already
            self.cur.execute('SELECT name FROM profiles WHERE name=?',
                             (unicode(entry_profile), ))
            if (self.cur.fetchone()):
                dialog = gtk.MessageDialog(
                    None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                    gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
                    _("There is already a profile with this name"))
                dialog.run()
                dialog.destroy()
                return

            # Create the new profile
            profile_id = constants.get_next_profile_id(self.con, self.cur)
            self.cur.execute(
                'INSERT INTO profiles (profile_id, name, description) ' +
                'VALUES ( ?, ?, ?)', (profile_data))
        else:
            # Save the profile changes
            self.cur.execute(
                'UPDATE profiles SET name=?, description=? where profile_id=?',
                (entry_profile, entry_description, self.profile_id))

        self.con.commit()