示例#1
0
 def start(self):
   gcompris.bar_set(gcompris.BAR_ABOUT)	#temporary, until it does not support levels
   gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
   self.rootitem = goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())		
   
   self.ball_radius=20
   #if number of tries is exceeded, then a game goes over - temporary unused
   self.tries=4
   #Select a random color. The chosen one is the darkest shade.
   #Depending on its priority, the ball will be lighter or equal shade as choosen one
   self.starting_color = [ randint(60, 255) for i in range(3) ]
   
   #a message below destroys aesthetics of activity
   '''self.instruction = goocanvas.Text(
     parent = self.rootitem,
     x = 600.0,
     y = 300.0,
     width = 250,
     text = _("Type the numbers of balls,"
              " begin from the lightest."),
     fill_color = "black",
     anchor = gtk.ANCHOR_CENTER,
     alignment = pango.ALIGN_CENTER
     )
   '''
   self.draw_all_balls()
示例#2
0
    def start(self):
        # Create our rootitem. We put each canvas item in it so at the end we
        # only have to kill it. The canvas deletes all the items it contains automaticaly.
        self.backitem = goocanvas.Group(parent=self.gcomprisBoard.canvas.get_root_item())

        svghandle = gcompris.utils.load_svg("hangman/back.svgz")
        goocanvas.Svg(parent=self.backitem, svg_handle=svghandle, pointer_events=goocanvas.EVENTS_NONE)

        # Create our rootitem. We put each canvas item in it so at the end we
        # only have to kill it. The canvas deletes all the items it contains automaticaly.
        self.rootitem = goocanvas.Group(parent=self.backitem)

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

        if not self.wordlist:
            gcompris.utils.dialog(_("Could not find the list of words."), stop_board)
            return

        self.gcomprisBoard.level = 1
        self.gcomprisBoard.maxlevel = self.wordlist.number_of_level * 3
        self.gcomprisBoard.sublevel = 1
        self.gcomprisBoard.number_of_sublevel = 10

        # Set the buttons we want in the bar
        gcompris.bar_set(gcompris.BAR_LEVEL)
        gcompris.bar_location(gcompris.BOARD_WIDTH - 160, -1, 0.6)

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

        self.display_level()
示例#3
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
      )
  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)
示例#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)
示例#6
0
  def start(self):

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

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

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains automaticaly.
    self.rootitem = goocanvas.Group(
      parent =  self.gcomprisBoard.canvas.get_root_item())

    self.doc = Document(self)

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

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

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

    self.draw_drawing_area()
    self.draw_playing_area()

    gcompris.bar_set(0)
    gcompris.bar_location(10, -1, 0.6)
  def start(self):
    # Set a background image
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

    #Boolean variable declaration
    self.mapActive = False

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

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

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains
    # automaticaly.
    self.root = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    self.lotto_board()
  def start(self):

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

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains
    # automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

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

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

    #Display title of activity
    goocanvas.Text(parent = self.rootitem,
                   x=400.0,
                   y=100.0,
                   text="Dicey - Dicey",
                   fill_color="black",
                   anchor = gtk.ANCHOR_CENTER,
                   alignment = pango.ALIGN_CENTER,
                   font = 'SANS 20'
                   )
    goocanvas.Text(parent = self.rootitem,
                   x=280.0,
                   y=200.0,
                   text="___",
                   anchor = gtk.ANCHOR_CENTER,
                   font='SANS 25')
    goocanvas.Text(parent = self.rootitem,
                   x=520.0,y=200.0,
                   text="=",
                   anchor = gtk.ANCHOR_CENTER,
                   font='SANS 25')
    goocanvas.Text(parent = self.rootitem,
                   x=650.0,y=300.0,
                   text="___",
                   anchor = gtk.ANCHOR_CENTER,
                   font='SANS 25')
    goocanvas.Text(parent = self.rootitem,
                   x=350.0,y=352.0,
                   text="Choose an operator to begin",
                   anchor = gtk.ANCHOR_CENTER,
                   font='SANS 15')
    self.display_function(self.gcomprisBoard.level)
示例#9
0
 def start(self):
   self.gcomprisBoard.level=1
   self.gcomprisBoard.maxlevel=9
   self.gcomprisBoard.sublevel=1
   self.gcomprisBoard.number_of_sublevel=1
   gcompris.bar_set(gcompris.BAR_LEVEL)
   gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
   gcompris.bar_set_level(self.gcomprisBoard)
   gcompris.bar_location(-1, -1, 0.8)
   self.set_level(1)
   self.game_start()
示例#10
0
 def repeat(self):
     if(self.mapActive):
         self.end()
         self.start()
         self.mapActive = False
     else :
         self.rootitem.props.visibility = goocanvas.ITEM_INVISIBLE
         self.rootitem = goocanvas.Group(parent=
                                  self.gcomprisBoard.canvas.get_root_item())
         gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
         map_obj = BrailleMap(self.rootitem, COLOR_ON, COLOR_OFF, CIRCLE_FILL, CIRCLE_STROKE)
         self.mapActive = True
  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)
示例#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)
示例#13
0
  def start(self):
    print "lang start"
    self.saved_policy = gcompris.sound.policy_get()
    gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)

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

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

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

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

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

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

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

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains
    # automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    self.langLib = LangLib(gcompris.DATA_DIR + "/lang/lang.xml")
    self.chapters = self.langLib.getChapters()
    # FIXME Do not manage Chapter yet
    self.currentChapterId = 0

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

    self.currentExercise = None
    self.currentLesson = self.langLib.getLesson(self.currentChapterId,
                                                self.gcomprisBoard.level - 1)
    self.displayLesson( self.currentLesson )
示例#14
0
 def repeat(self):
   if(self.mapActive):
         self.rootitem.props.visibility = goocanvas.ITEM_INVISIBLE
         gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                           "braille_fun/hillside.svg")
         self.root.props.visibility = goocanvas.ITEM_VISIBLE
         self.horizontalTextRoot.props.visibility = goocanvas.ITEM_VISIBLE
         self.verticalTextRoot.props.visibility = goocanvas.ITEM_VISIBLE
         self.mapActive = False
   else :
         self.root.props.visibility = goocanvas.ITEM_INVISIBLE
         self.horizontalTextRoot.props.visibility = goocanvas.ITEM_INVISIBLE
         self.verticalTextRoot.props.visibility = goocanvas.ITEM_INVISIBLE
         self.rootitem = goocanvas.Group(parent=
                                  self.gcomprisBoard.canvas.get_root_item())
         gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
         map_obj = BrailleMap(self.rootitem, COLOR_ON, COLOR_OFF, CIRCLE_FILL, CIRCLE_STROKE)
         self.mapActive = True
示例#15
0
  def start(self):
    self.gcomprisBoard.level=1
    self.gcomprisBoard.maxlevel=4
    self.gcomprisBoard.sublevel=1
    self.gcomprisBoard.number_of_sublevel=1

    self.board_paused = False

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains automaticaly.
    self.rootitem = goocanvas.Group(parent =  self.gcomprisBoard.canvas.get_root_item())

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

    self.display_sea_area()

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

    # Display the weather now
    self.display_weather()

    # And finaly the players boats
    self.init_boats()

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


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

    gcompris.bar_set_level(self.gcomprisBoard)
    gcompris.bar_location(gcompris.BOARD_WIDTH/2 - 90, -1, 0.6)
示例#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, 1)

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

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

        # Create our rootitem. We put each canvas item in it so at the end we
        # only have to kill it. The canvas deletes all the items it contains
        # automaticaly.
        self.rootitem = goocanvas.Group(parent=
                                        self.gcomprisBoard.canvas.get_root_item())

        self.display_level(self.gcomprisBoard.level)
示例#17
0
  def start(self):
    print "computer_simulation start"

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

    gcompris.bar_set_level(self.gcomprisBoard)

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

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

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains
    # automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    self.display_game()
示例#18
0
文件: explore.py 项目: GNOME/gcompris
    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)
  def repeat(self):
      if(self.mapActive):
          self.end()
          self.start()
          self.mapActive = False
      else :
          self.rootitem.props.visibility = goocanvas.ITEM_INVISIBLE
          self.rootitem = goocanvas.Group(parent=
                                   self.gcomprisBoard.canvas.get_root_item())
          gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

          #Place alphabets & numbers in array format
          for i, letter in enumerate(string.ascii_uppercase[:10]):
              tile = BrailleChar(self.rootitem, i*(cell_width+30)+60,
                              60, 50, letter ,on,off,circle_fill,
                              circle_stroke,True ,False,True,None)
          for i, letter in enumerate(string.ascii_uppercase[10:20]):
              tile = BrailleChar(self.rootitem, i*(cell_width+30)+60,
                              150, 50, letter ,on, off, circle_fill,
                              circle_stroke, True ,False,True,None)
          for i, letter in enumerate(string.ascii_uppercase[20:25]):
              tile = BrailleChar(self.rootitem, i*(cell_width+30)+60,
                              250, 50, letter ,on ,off ,circle_fill,
                              circle_stroke, True ,False,True, None)
          for letter in range(0,10):
              tile = BrailleChar(self.rootitem,letter *(cell_width+30)+60,
                             350, 50, letter ,on ,off ,circle_fill,
                             circle_stroke, True ,False ,True, None)
          #Move back item
          self.backitem = goocanvas.Image(parent = self.rootitem,
                    pixbuf = gcompris.utils.load_pixmap("back.png"),
                    x = 600,
                    y = 450,
                    tooltip = "Move Back"
                    )
          self.backitem.connect("button_press_event", self.move_back)
          gcompris.utils.item_focus_init(self.backitem, None)

          self.mapActive = True
  def start(self):
    # Set the buttons we want in the bar
    gcompris.bar_set(gcompris.BAR_LEVEL)
    gcompris.bar_location(300,-1,0.6)
    gcompris.bar_set_level(self.gcomprisBoard)

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

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

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains
    # automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    self.display_game(self.gcomprisBoard.level)
  def repeat(self):
      if(self.mapActive):
          self.end()
          self.start()
          self.mapActive = False
      else :
          self.rootitem.props.visibility = goocanvas.ITEM_INVISIBLE
          self.rootitem = goocanvas.Group(parent=
                                   self.gcomprisBoard.canvas.get_root_item())
          gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())

          map_obj = BrailleMap(self.rootitem, COLOR_ON, COLOR_OFF,MAP_FILL, MAP_STROKE)
          # Move back item
          self.backitem = goocanvas.Image(parent = self.rootitem,
                    pixbuf = gcompris.utils.load_pixmap("braille_alphabets/back.svg"),
                    x = 600,
                    y = 450,
                    tooltip = _("Back to the activity")
                    )
          self.backitem.connect("button_press_event", self.move_back)
          gcompris.utils.item_focus_init(self.backitem, None)

          self.mapActive = True
示例#22
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)
示例#23
0
  def start(self):
    print "mayya 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())
    
    self.titleText=goocanvas.Text(
      parent = self.rootitem,
      x=10.0,
      y=10.0,
      text=_("The Three Little Pigs"),
      fill_color="black",
      anchor = gtk.ANCHOR_NW,
      alignment = pango.ALIGN_CENTER
      )
    
    storyRect=goocanvas.Rect(parent = self.rootitem,
      x = 8,
      y = 48,
      height = 200,
      width = 404,
      stroke_color = "red",
      fill_color = "yellow",
      radius_x = 3, radius_y = 3,
      line_width = 1.0)

    storyText=goocanvas.Text(
      parent = self.rootitem,
      x=10.0,
      y=50.0,
      text=_("Once upon a time there were three little pigs" 
	" and the time came for them to leave home and seek their fortunes."
	" Before they left, their mother told them 'Whatever you do,"
	" do it the best that you can because that's the way to get along in the world.'......."),
      fill_color="black",
      anchor = gtk.ANCHOR_NW,
      alignment = pango.ALIGN_LEFT,
      width=400
      )
    storyText.raise_(storyRect)
    p_points = goocanvas.Points([(418.0,6), (418.0, 460.0)])
    polyline = goocanvas.Polyline(
      parent = self.rootitem,
      points=p_points, 
      stroke_color="red", 
      line_width=1)

    questionNText=goocanvas.Text(
      parent = self.rootitem,
      x=430.0,
      y=10.0,
      text=_("Question 1"),
      fill_color="black",
      anchor = gtk.ANCHOR_NW,
      alignment = pango.ALIGN_LEFT
      )

    questionText=goocanvas.Text(
      parent = self.rootitem,
      x=430.0,
      y=35.0,
      text=_("How many pigs were in the story?"),
      fill_color="black",
      anchor = gtk.ANCHOR_NW,
      alignment = pango.ALIGN_LEFT
      )

    ansText1=goocanvas.Text(
      parent = self.rootitem,
      x=560.0,
      y=80,
      text=_("2"),
      fill_color="red",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_LEFT
      )
    ansEllipse1 = goocanvas.Ellipse(parent=self.rootitem,
      center_x=560,
      center_y=80,
      radius_x=26,
      radius_y=14,
      stroke_color="red",
      fill_color="yellow",
      line_width=1.0)
    ansText1.raise_(ansEllipse1)
    ansEllipse1.connect("button_press_event",self.wrongAnswer_event, None)
    
    ansText2=goocanvas.Text(
      parent = self.rootitem,
      x=560.0,
      y=120,
      text=_("3"),
      fill_color="red",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_LEFT
      )
    ansEllipse2 = goocanvas.Ellipse(parent=self.rootitem,
      center_x=560,
      center_y=120,
      radius_x=26,
      radius_y=14,
      stroke_color="red",
      fill_color="yellow",
      line_width=1.0)
    ansText2.raise_(ansEllipse2)
    ansEllipse2.connect("button_press_event",self.rightAnswer_event, None)
    ansText3=goocanvas.Text(
      parent = self.rootitem,
      x=560.0,
      y=160,
      text=_("4"),
      fill_color="red",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_LEFT
      )
    ansEllipse3 = goocanvas.Ellipse(parent=self.rootitem,
      center_x=560,
      center_y=160,
      radius_x=26,
      radius_y=14,
      stroke_color="red",
      fill_color="yellow",
      line_width=1.0)
    ansText3.raise_(ansEllipse3)
    ansEllipse3.connect("button_press_event",self.wrongAnswer_event, None)
    self.wrongAnsTxt=goocanvas.Text(
      parent = self.rootitem,
      x=550.0,
      y=205,
      text=_("Wrong answer! Try again!"),
      fill_color="red",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )
    self.wrongAnsImg = goocanvas.Image(
        parent = self.rootitem,
        x = 540,
        y = 219,
        height = 48,
        width = 48,
        pixbuf = gcompris.utils.load_pixmap('mayya-activity/weather-rain.png')
    )

    self.rightAnsTxt=goocanvas.Text(
      parent = self.rootitem,
      x=550.0,
      y=205,
      text=_("Great job! Way to go!"),
      fill_color="red",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )
    self.rightAnsImg = goocanvas.Image(
    	parent = self.rootitem,
        x = 540,
        y = 219,
        height = 48,
        width = 48,
        pixbuf = gcompris.utils.load_pixmap('mayya-activity/weather-sun.png')
    )
    self.wrongAnsTxt.props.visibility=goocanvas.ITEM_INVISIBLE
    self.wrongAnsImg.props.visibility=goocanvas.ITEM_INVISIBLE
    self.rightAnsTxt.props.visibility=goocanvas.ITEM_INVISIBLE
    self.rightAnsImg.props.visibility=goocanvas.ITEM_INVISIBLE
示例#24
0
    def start(self):
        self.board.level = 1
        self.board.maxlevel = self.levelset.numlevels
        self.board.sublevel = 1
        self.board.number_of_sublevel = self.levelset.num_sublevels
        self.trog_wait = 1900

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.startGame()
示例#25
0
  def start(self):
    logged = gcompris.admin.get_current_user()

    # API Test, return the absolute path to this file
    print gcompris.utils.find_file_absolute("sounds/bleep.wav")
#    wordlist = gcompris.get_wordlist('wordslevel_max_pt_BR')
#    print wordlist
#    print wordlist.filename
#    print wordlist.level
#    print wordlist.locale
#    print wordlist.description
#    print wordlist.words


    if logged:
      print "User Logged in:"
      print "   ", logged.login, logged.firstname, logged.lastname

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

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

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

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

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

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

    # self.colors['line'] s set in init.
    # I put here the configuration use

    color_name = self.config_dict['color_line']
    self.colors['line'] = self.config_colors[color_name]

    gcompris.bar_set(gcompris.BAR_CONFIG)
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
    gcompris.bar_set_level(self.gcomprisBoard)

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

    # distance is used to demo of gcompris.spin_int
    distance = eval(self.config_dict['distance_circle'])

    # pattern is for gcompris.radio_buttons
    pattern = self.config_dict['pattern']

    patterns = { 'circle': goocanvas.Ellipse,
                 'rectangle': goocanvas.Rect
                 }

    #error check
    if not patterns.has_key(pattern):
      pattern = 'circle'

    self.canvasitems[1] = patterns[pattern](
      parent = self.rootitem,
      fill_color_rgba= self.colors['circle_in'],
      stroke_color_rgba= self.colors['circle_out'],
      line_width=1.0
      )
    self.canvasitems[1].connect("button_press_event", self.circle_item_event)
    self.canvasitems[1].connect("button_release_event", self.circle_item_event)
    self.canvasitems[1].connect("motion_notify_event", self.circle_item_event)

    if(pattern == 'circle'):
      self.canvasitems[1].set_properties(
        center_x = 400.0 - distance,
        center_y = 200.0,
        radius_x = 20,
        radius_y = 20)
    else:
      self.canvasitems[1].set_properties(
        x = 400.0 - distance,
        y = 200.0,
        width = 20,
        height = 20)

    self.canvasitems[2] = patterns[pattern](
      parent = self.rootitem,
      fill_color_rgba= self.colors['circle_in'],
      stroke_color_rgba= self.colors['circle_out'],
      line_width=1.0
      )
    self.canvasitems[2].connect("button_press_event", self.circle_item_event)
    self.canvasitems[2].connect("button_release_event", self.circle_item_event)
    self.canvasitems[2].connect("motion_notify_event", self.circle_item_event)

    if(pattern == 'circle'):
      self.canvasitems[2].set_properties(
        center_x = 400.0 + distance,
        center_y = 200.0,
        radius_x = 20,
        radius_y = 20)
    else:
      self.canvasitems[2].set_properties(
        x = 400.0 + distance,
        y = 200.0,
        width = 20,
        height = 20)

    self.canvasitems[3] = goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=100.0,
      text=_("This is the first plugin in GCompris coded in the Python\nProgramming language."),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    self.canvasitems[4] = goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=140.0,
      text=_("It is now possible to develop GCompris activities in C or in Python.\nThanks to Olivier Samys who makes this possible."),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    self.canvasitems[5] = goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=250.0,
      text=_("This activity is not playable, just a test"),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    #----------------------------------------
    # A simple game.
    # Try to hit left shift and right shift together. The peed increases
    goocanvas.Rect(
      parent = self.rootitem,
      x = 20,
      y = gcompris.BOARD_HEIGHT-220,
      width = gcompris.BOARD_WIDTH-40,
      height = 150,
      fill_color_rgba=0xFF663333L,
      stroke_color_rgba=0xFF33CCAAL,
      line_width=2.0)

    # For the game status WIN/LOOSE
    self.canvasitems[6] = goocanvas.Text(
      parent = self.rootitem,
      x=gcompris.BOARD_WIDTH / 2,
      y=gcompris.BOARD_HEIGHT - 100,
      font=gcompris.skin.get_font("gcompris/content"),
      fill_color_rgba=0x102010FFL,
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    goocanvas.Text(
      parent = self.rootitem,
      x=400.0,
      y=360.0,
      text=("Test your reflex with the counter. Hit the 2 shifts key together.\nHit space to reset the counter and increase the speed.\nBackspace to reset the speed"),
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    # The basic tick for object moves
    self.timerinc = 1000

    self.timer_inc  = gobject.timeout_add(self.timerinc, self.timer_inc_display)

    self.counter_left  = 0
    self.counter_right = 0

    self.canvasitems[7] =goocanvas.Text(
      parent = self.rootitem,
      x=gcompris.BOARD_WIDTH / 2,
      y=gcompris.BOARD_HEIGHT - 120,
      font=gcompris.skin.get_font("gcompris/content"),
      text="Speed="+str(self.timerinc)+" ms",
      fill_color="black",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )

    self.textitem_left = goocanvas.Text(
      parent = self.rootitem,
      font=gcompris.skin.get_font("gcompris/content"),
      x=gcompris.BOARD_WIDTH / 3,
      y=gcompris.BOARD_HEIGHT - 100,
      fill_color_rgba=0xFF000FFFL
      )

    self.textitem_right =goocanvas.Text(
      parent = self.rootitem,
      font=gcompris.skin.get_font("gcompris/content"),
      x=gcompris.BOARD_WIDTH / 1.5,
      y=gcompris.BOARD_HEIGHT - 100,
      fill_color_rgba=0xFF000FFFL
      )

    self.left_continue  = True
    self.right_continue = True

    print("Gcompris_pythontest start.")
示例#26
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"),
      )
示例#27
0
    def start(self, x=None, y=None, z=None):
        '''
        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.
        '''
        # Set the buttons we want in the bar
        gcompris.bar_set(0) # just quit and help buttons
        gcompris.bar_location(20, -1, 0.6) # small, bottom left corner

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

        # are these the correct commands to suspend sound?
        self.saved_policy = gcompris.sound.policy_get()
        gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)
        gcompris.sound.pause()

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

        # -------------------------------------------------------------
        # Draw home page
        # -------------------------------------------------------------

        self.map = goocanvas.Image(
            parent=self.rootitem,
            x=20, y=20,
            width=760,
            height=450,
            pixbuf=gcompris.utils.load_pixmap('/general/world.png')
            )

        if RECORD_LOCATIONS:
            self.map.connect("button_press_event", self.record_location)
            gcompris.utils.item_focus_init(self.map, None)
        else:
            self.read_data() # read in the data from content.txt file
            self.drawLocations() # draw the locations on teh map

        txt = _('Explore the world! Click on the dots.')
        goocanvas.Text(
          parent=self.rootitem,
          x=100,
          y=230,
          width=150,
          text='<span font_family="URW Gothic L" size="medium" \
          weight="bold" style="italic">' + txt + '</span>',
          anchor=gtk.ANCHOR_CENTER,
          alignment=pango.ALIGN_CENTER,
          use_markup=True
          )

        txt2 = _('Travel Bar:')
        goocanvas.Text(
          parent=self.rootitem,
          x=180,
          y=490,
          text='<span font_family="URW Gothic L" size="medium" \
          weight="bold" style="italic">' + txt2 + '</span>',
          anchor=gtk.ANCHOR_CENTER,
          alignment=pango.ALIGN_CENTER,
          use_markup=True
          )

        goocanvas.Image(
            parent=self.rootitem,
            x=30,
            y=280,
            pixbuf=gcompris.utils.load_pixmap('/general/travel.png')
            )

        # check to see if student has won game
        if self.score == (len(self.data.sections()) - 1) and self.score != 0:
            # show congratulations image!
            goocanvas.Image(
            parent=self.rootitem,
            x=100, y= -30,
            pixbuf=gcompris.utils.load_pixmap('/general/winner.png')
            )
            # reset the game
            self.score = 0
            self.sectionsAnsweredCorrectly = []
            self.timers = []
            self.timers.append(gobject.timeout_add(3000, self.start))

        x = 240 # starting x position of progress bar
        self.progressBar = goocanvas.Rect(parent=self.rootitem,
                x=x, y=480, width=500, height=25,
                stroke_color="black",
                line_width=3.0)

        # display the correct progress in the progress bar, according to the 
        # number of locations the student has correclty answered the question for
        for num in range(0, self.score):
            goocanvas.Rect(parent=self.rootitem,
            x=x, y=480, width=500.0 / len(self.data.sections()), height=25,
            stroke_color="black",
            fill_color="#32CD32",
            line_width=3.0)
            x += 500.0 / len(self.data.sections())
示例#28
0
文件: chat.py 项目: laya/gcompris-1
  def start(self):
    gcompris.bar_set (0)
    gcompris.bar_location(gcompris.BOARD_WIDTH - 160, -1, 0.6)
    gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
    self.rootitem = goocanvas.Group(parent =  self.gcomprisBoard.canvas.get_root_item())

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

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

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

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

    self.global_area_tv.set_wrap_mode(gtk.WRAP_CHAR)

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

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

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

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

    self.friend_area_tb.set_text("")

    self.friend_area_tv.set_wrap_mode(gtk.WRAP_CHAR)

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

    # A label for the friend area

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

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


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

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


    # A label for the channel area

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

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


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

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

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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

      self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
      self.sock.setblocking(0)
      self.timer_interval = 10
      self.mcast_timer = gobject.timeout_add(self.timer_interval, self.mcast_read)
    except:
      self.display_message("GCompris",
                           _("ERROR: Failed to initialize the network interface. You cannot communicate."))
示例#29
0
    def start(self):
        self.board.level = 1
        self.board.maxlevel = self.levelset.numlevels
        self.board.sublevel = 1
        self.board.number_of_sublevel = self.levelset.num_sublevels
        self.trog_wait = 1900

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.startGame()
示例#30
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("hangman/default-$LOCALE.xml")
    except:
      pass
    # Fallback to wordsgame list
    if not self.wordlist:
        try:
            self.language = gcompris.gcompris_gettext( gcompris.get_locale_name(gcompris.get_locale()) )
            self.wordlist = gcompris.get_wordlist("wordsgame/default-$LOCALE.xml")
        except:
            pass
    # Fallback to english
    if not self.wordlist:
        try:
            self.wordlist = gcompris.get_wordlist("hangman/default-en.xml")
            self.language = _("English")
        except:
            pass
    # Fallback to English wordsgame list
    if not self.wordlist:
        self.wordlist = gcompris.get_wordlist("wordsgame/default-en.xml")
        self.language = _("English")

    if not self.wordlist:
      gcompris.utils.dialog(_("Could not find the list of words."),
                            stop_board)
      return;

    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()
示例#31
0
  def start(self):

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

    import glob
    m_list = glob.glob('admin/module_*.py')
    if m_list == []:
      m_list = glob.glob(gcompris.PYTHON_PLUGIN_DIR+'/admin/module_*.py')
    for file in m_list:
      m_name = file.split('/')[-1].split('.')[0].split('_')[1]
      if gcompris.sugar_detected():
        if (m_name == 'profiles' or m_name == 'boards'):
          continue
      else:
        if (m_name == 'logins' or m_name == 'activities'):
          continue
      list_modules.append(m_name)

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

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

    del list_modules

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

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

    # A White background in the panel area

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

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

    # Display the menu in the selection area
    # The list of modules
    i = 0
    modules_ordered.sort()
    for tmodule in modules_ordered:
      module = tmodule[1]
      eval(module +'(self.rootitem).init(i, self.select_area, self.select_event)')
      i+=1
示例#32
0
    def start(self):
        logged = gcompris.admin.get_current_user()

        # API Test, return the absolute path to this file
        print gcompris.utils.find_file_absolute("sounds/bleep.wav")
        #    wordlist = gcompris.get_wordlist('wordslevel_max_pt_BR')
        #    print wordlist
        #    print wordlist.filename
        #    print wordlist.level
        #    print wordlist.locale
        #    print wordlist.description
        #    print wordlist.words

        if logged:
            print "User Logged in:"
            print "   ", logged.login, logged.firstname, logged.lastname

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

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

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

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

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

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

        # self.colors['line'] s set in init.
        # I put here the configuration use

        color_name = self.config_dict['color_line']
        self.colors['line'] = self.config_colors[color_name]

        gcompris.bar_set(gcompris.BAR_CONFIG)
        gcompris.set_default_background(
            self.gcomprisBoard.canvas.get_root_item())
        gcompris.bar_set_level(self.gcomprisBoard)

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

        # distance is used to demo of gcompris.spin_int
        distance = eval(self.config_dict['distance_circle'])

        # pattern is for gcompris.radio_buttons
        pattern = self.config_dict['pattern']

        patterns = {'circle': goocanvas.Ellipse, 'rectangle': goocanvas.Rect}

        #error check
        if not patterns.has_key(pattern):
            pattern = 'circle'

        self.canvasitems[1] = patterns[pattern](
            parent=self.rootitem,
            fill_color_rgba=self.colors['circle_in'],
            stroke_color_rgba=self.colors['circle_out'],
            line_width=1.0)
        self.canvasitems[1].connect("button_press_event",
                                    self.circle_item_event)
        self.canvasitems[1].connect("button_release_event",
                                    self.circle_item_event)
        self.canvasitems[1].connect("motion_notify_event",
                                    self.circle_item_event)

        if (pattern == 'circle'):
            self.canvasitems[1].set_properties(center_x=400.0 - distance,
                                               center_y=200.0,
                                               radius_x=20,
                                               radius_y=20)
        else:
            self.canvasitems[1].set_properties(x=400.0 - distance,
                                               y=200.0,
                                               width=20,
                                               height=20)

        self.canvasitems[2] = patterns[pattern](
            parent=self.rootitem,
            fill_color_rgba=self.colors['circle_in'],
            stroke_color_rgba=self.colors['circle_out'],
            line_width=1.0)
        self.canvasitems[2].connect("button_press_event",
                                    self.circle_item_event)
        self.canvasitems[2].connect("button_release_event",
                                    self.circle_item_event)
        self.canvasitems[2].connect("motion_notify_event",
                                    self.circle_item_event)

        if (pattern == 'circle'):
            self.canvasitems[2].set_properties(center_x=400.0 + distance,
                                               center_y=200.0,
                                               radius_x=20,
                                               radius_y=20)
        else:
            self.canvasitems[2].set_properties(x=400.0 + distance,
                                               y=200.0,
                                               width=20,
                                               height=20)

        self.canvasitems[3] = goocanvas.Text(
            parent=self.rootitem,
            x=400.0,
            y=100.0,
            text=
            _("This is the first plugin in GCompris coded in the Python\nProgramming language."
              ),
            fill_color="black",
            anchor=gtk.ANCHOR_CENTER,
            alignment=pango.ALIGN_CENTER)

        self.canvasitems[4] = goocanvas.Text(
            parent=self.rootitem,
            x=400.0,
            y=140.0,
            text=
            _("It is now possible to develop GCompris activities in C or in Python.\nThanks to Olivier Samys who makes this possible."
              ),
            fill_color="black",
            anchor=gtk.ANCHOR_CENTER,
            alignment=pango.ALIGN_CENTER)

        self.canvasitems[5] = goocanvas.Text(
            parent=self.rootitem,
            x=400.0,
            y=250.0,
            text=_("This activity is not playable, just a test"),
            fill_color="black",
            anchor=gtk.ANCHOR_CENTER,
            alignment=pango.ALIGN_CENTER)

        #----------------------------------------
        # A simple game.
        # Try to hit left shift and right shift together. The peed increases
        goocanvas.Rect(parent=self.rootitem,
                       x=20,
                       y=gcompris.BOARD_HEIGHT - 220,
                       width=gcompris.BOARD_WIDTH - 40,
                       height=150,
                       fill_color_rgba=0xFF663333L,
                       stroke_color_rgba=0xFF33CCAAL,
                       line_width=2.0)

        # For the game status WIN/LOOSE
        self.canvasitems[6] = goocanvas.Text(
            parent=self.rootitem,
            x=gcompris.BOARD_WIDTH / 2,
            y=gcompris.BOARD_HEIGHT - 100,
            font=gcompris.skin.get_font("gcompris/content"),
            fill_color_rgba=0x102010FFL,
            anchor=gtk.ANCHOR_CENTER,
            alignment=pango.ALIGN_CENTER)

        goocanvas.Text(
            parent=self.rootitem,
            x=400.0,
            y=360.0,
            text=
            ("Test your reflex with the counter. Hit the 2 shifts key together.\nHit space to reset the counter and increase the speed.\nBackspace to reset the speed"
             ),
            fill_color="black",
            anchor=gtk.ANCHOR_CENTER,
            alignment=pango.ALIGN_CENTER)

        # The basic tick for object moves
        self.timerinc = 1000

        self.timer_inc = gobject.timeout_add(self.timerinc,
                                             self.timer_inc_display)

        self.counter_left = 0
        self.counter_right = 0

        self.canvasitems[7] = goocanvas.Text(
            parent=self.rootitem,
            x=gcompris.BOARD_WIDTH / 2,
            y=gcompris.BOARD_HEIGHT - 120,
            font=gcompris.skin.get_font("gcompris/content"),
            text="Speed=" + str(self.timerinc) + " ms",
            fill_color="black",
            anchor=gtk.ANCHOR_CENTER,
            alignment=pango.ALIGN_CENTER)

        self.textitem_left = goocanvas.Text(
            parent=self.rootitem,
            font=gcompris.skin.get_font("gcompris/content"),
            x=gcompris.BOARD_WIDTH / 3,
            y=gcompris.BOARD_HEIGHT - 100,
            fill_color_rgba=0xFF000FFFL)

        self.textitem_right = goocanvas.Text(
            parent=self.rootitem,
            font=gcompris.skin.get_font("gcompris/content"),
            x=gcompris.BOARD_WIDTH / 1.5,
            y=gcompris.BOARD_HEIGHT - 100,
            fill_color_rgba=0xFF000FFFL)

        self.left_continue = True
        self.right_continue = True

        print("Gcompris_pythontest start.")
示例#33
0
  def start(self):
    self.saved_policy = gcompris.sound.policy_get()
    gcompris.sound.policy_set(gcompris.sound.PLAY_AND_INTERRUPT)
    gcompris.sound.pause()

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

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

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

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

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

    # Create our rootitem. We put each canvas item in it so at the end we
    # only have to kill it. The canvas deletes all the items it contains
    # automaticaly.
    self.rootitem = goocanvas.Group(parent =
                                    self.gcomprisBoard.canvas.get_root_item())

    self.langLib = LangLib(gcompris.DATA_DIR + "/lang/words.xml")
    self.chapters = self.langLib.getChapters()

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

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

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

    gcompris.bar_set_level(self.gcomprisBoard)

    self.currentExerciseModes = []
    self.currentExercise = None
    self.currentLesson = self.langLib.getLesson(self.currentChapterName,
                                                self.gcomprisBoard.level - 1)
    self.displayLesson( self.currentLesson )
    self.pause(0);
示例#34
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"),
        )
示例#35
0
    def start(self):

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

        import glob
        m_list = glob.glob('admin/module_*.py')
        if m_list == []:
            m_list = glob.glob(gcompris.PYTHON_PLUGIN_DIR +
                               '/admin/module_*.py')
        for file in m_list:
            m_name = file.split('/')[-1].split('.')[0].split('_')[1]
            if gcompris.sugar_detected():
                if (m_name == 'profiles' or m_name == 'boards'):
                    continue
            else:
                if (m_name == 'logins' or m_name == 'activities'):
                    continue
            list_modules.append(m_name)

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

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

        del list_modules

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

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

        # A White background in the panel area

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

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

        # Display the menu in the selection area
        # The list of modules
        i = 0
        modules_ordered.sort()
        for tmodule in modules_ordered:
            module = tmodule[1]
            eval(
                module +
                '(self.rootitem).init(i, self.select_area, self.select_event)')
            i += 1