示例#1
0
    def display_game(self):
        self.rootitem = \
          goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())

        self.create_components(self.gcomprisBoard.level)

        # Display the tools
        x = 12
        y = 10

        for i in range(0, len(self.tools)):
            item = goocanvas.Image(parent=self.rootitem,
                                   pixbuf=gcompris.utils.load_pixmap(
                                       self.tools[i][1]),
                                   x=x,
                                   y=y)
            x += 45
            item.connect("button_press_event", self.tool_item_event, i)

            if (self.tools[i][0] == "SELECT"):
                self.select_tool = item
                self.select_tool_number = i
                # Always select the SELECT item by default
                self.current_tool = i
                self.old_tool_item = item
                self.old_tool_item.props.pixbuf = gcompris.utils.load_pixmap(
                    self.tools[i][2])
                gcompris.set_cursor(self.tools[i][3])

            # Add the item in self.tools for later use
            self.tools[i].append(item)
示例#2
0
文件: anim.py 项目: laya/gcompris-1
  def draw_tools(self):

    self.root_toolitem = \
      goocanvas.Group(
        parent = self.rootitem,
      )

    goocanvas.Image(
      parent = self.root_toolitem,
      pixbuf = gcompris.utils.load_pixmap("anim/tool-selector.png"),
      x = 5,
      y = 5.0,
      width = 107.0,
      height = 517.0,
      )

    x1 = 11.0
    x2 = 56.0
    y = 11.0
    stepy = 45
    start_tool = 0

    if gcompris.sugar_detected():
        start_tool = 2

    # Display the tools
    for i in range(start_tool,len(self.tools)):

      # Exclude the anim specific buttons
      if self.gcomprisBoard.mode == 'draw':
        if self.tools[i][0]=="MOVIE" or self.tools[i][0]=="PICTURE":
          continue

      if(i%2):
        theX = x2
      else:
        theX = x1

      item = \
        goocanvas.Image(
          parent = self.root_toolitem,
          pixbuf = gcompris.utils.load_pixmap(self.tools[i][1]),
          tooltip = self.tools[i][4],
          x=theX,
          y=y
        )
      gcompris.utils.item_focus_init(item, None)
      item.connect("button_press_event", self.tool_item_event, i)
      if i%2:
        y += stepy

      if(self.tools[i][0]=="SELECT"):
        self.select_tool = item
        self.select_tool_number = i
        # Always select the SELECT item by default
        self.current_tool = i
        self.old_tool_item = item
        self.old_tool_item.props.pixbuf = \
            gcompris.utils.load_pixmap(self.tools[i][2])
        gcompris.set_cursor(self.tools[i][3]);
示例#3
0
  def display_game(self):
    self.rootitem = \
      goocanvas.Group(parent = self.gcomprisBoard.canvas.get_root_item())

    self.create_components(self.gcomprisBoard.level)

    # Display the tools
    x = 12
    y = 10

    for i in range(0, len(self.tools)):
      item = goocanvas.Image(
               parent = self.rootitem,
               pixbuf = gcompris.utils.load_pixmap(self.tools[i][1]),
               x = x,
               y = y
               )
      x += 45
      item.connect("button_press_event", self.tool_item_event, i)

      if (self.tools[i][0] == "SELECT"):
        self.select_tool = item
        self.select_tool_number = i
        # Always select the SELECT item by default
        self.current_tool = i
        self.old_tool_item = item
        self.old_tool_item.props.pixbuf = gcompris.utils.load_pixmap(self.tools[i][2])
        gcompris.set_cursor(self.tools[i][3]);

      # Add the item in self.tools for later use
      self.tools[i].append(item)
示例#4
0
  def assign_tool(self, newtool):
    #Deactivate old button
    item = self.tools[self.current_tool][4]
    item.set_properties(pixbuf = gcompris.utils.load_pixmap(self.tools[self.current_tool][1]))

    # Activate new button
    self.current_tool = newtool
    item = self.tools[newtool][4]
    item.set_properties(pixbuf = gcompris.utils.load_pixmap(self.tools[self.current_tool][2]))
    gcompris.set_cursor(self.tools[self.current_tool][3]);
示例#5
0
    def assign_tool(self, newtool):
        # Deactivate old button
        item = self.tools[self.current_tool][4]
        item.set_properties(pixbuf=gcompris.utils.load_pixmap(self.tools[
            self.current_tool][1]))

        # Activate new button
        self.current_tool = newtool
        item = self.tools[newtool][4]
        item.set_properties(pixbuf=gcompris.utils.load_pixmap(self.tools[
            self.current_tool][2]))
        gcompris.set_cursor(self.tools[self.current_tool][3])
示例#6
0
    def tool_item_event(self, item, target, event, tool):

        if event.type == gtk.gdk.BUTTON_PRESS:
            if event.button == 1:
                gcompris.sound.play_ogg("sounds/bleep.wav")
                # Some button have instant effects
                if (self.tools[tool][0] == "SAVE"):
                    gcompris.file_selector_save(self.gcomprisBoard,
                                                self.selector_section,
                                                self.file_type, general_save,
                                                self)
                    return False

                elif (self.tools[tool][0] == "LOAD"):
                    gcompris.file_selector_load(self.gcomprisBoard,
                                                self.selector_section,
                                                self.file_type,
                                                general_restore, self)
                    return False

                elif (self.tools[tool][0] == "IMAGE"):
                    self.pos_x = gcompris.BOARD_WIDTH / 2
                    self.pos_y = gcompris.BOARD_HEIGHT / 2

                    gcompris.images_selector_start(self.gcomprisBoard,
                                                   "dataset", image_selected,
                                                   self)
                    return False

                elif (self.tools[tool][0] == "MOVIE"):
                    if not self.running:
                        self.deselect()

                        self.playing_start()
                        return False

                elif (self.tools[tool][0] != "SELECT"):
                    self.deselect()

                #
                # Normal case, tool button switch
                # -------------------------------

                # Deactivate old button
                self.old_tool_item.props.pixbuf = \
                    gcompris.utils.load_pixmap(self.tools[self.current_tool][1])

                # Activate new button
                self.current_tool = tool
                self.old_tool_item = item
                self.old_tool_item.props.pixbuf = \
                    gcompris.utils.load_pixmap(self.tools[self.current_tool][2])
                gcompris.set_cursor(self.tools[self.current_tool][3])
示例#7
0
文件: anim.py 项目: GNOME/gcompris
  def tool_item_event(self, item, target, event, tool):

    if event.type == gtk.gdk.BUTTON_PRESS:
      if event.button == 1:
        gcompris.sound.play_ogg("sounds/bleep.wav")
        # Some button have instant effects
        if (self.tools[tool][0] == "SAVE"):
          gcompris.file_selector_save( self.gcomprisBoard,
                                       self.selector_section, self.file_type,
                                       general_save, self)
          return False

        elif (self.tools[tool][0] == "LOAD"):
          gcompris.file_selector_load( self.gcomprisBoard,
                                       self.selector_section, self.file_type,
                                       general_restore, self)
          return False

        elif (self.tools[tool][0] == "IMAGE"):
          self.pos_x = gcompris.BOARD_WIDTH/2
          self.pos_y = gcompris.BOARD_HEIGHT/2

          gcompris.images_selector_start(self.gcomprisBoard,
                                         "dataset",
                                         image_selected,
                                         self);
          return False

        elif (self.tools[tool][0] == "MOVIE"):
          if not self.running:
            self.deselect()

            self.playing_start()
            return False

        elif (self.tools[tool][0] != "SELECT"):
          self.deselect()

        #
        # Normal case, tool button switch
        # -------------------------------

        # Deactivate old button
        self.old_tool_item.props.pixbuf = \
            gcompris.utils.load_pixmap(self.tools[self.current_tool][1])

        # Activate new button
        self.current_tool = tool
        self.old_tool_item = item
        self.old_tool_item.props.pixbuf = \
            gcompris.utils.load_pixmap(self.tools[self.current_tool][2])
        gcompris.set_cursor(self.tools[self.current_tool][3]);
示例#8
0
    def end(self):
        # stop the animation
        if self.running:
            self.playing_stop()

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

        # Remove the root item removes all the others inside it
        gcompris.set_cursor(gcompris.CURSOR_DEFAULT)
        self.rootitem.remove()
        self.color_rootitem.remove()

        del self.doc
示例#9
0
  def end(self):
    # stop the animation
    if self.running:
      self.playing_stop()

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

    # Remove the root item removes all the others inside it
    gcompris.set_cursor(gcompris.CURSOR_DEFAULT);
    self.rootitem.remove()
    self.color_rootitem.remove()

    del self.doc
示例#10
0
文件: anim.py 项目: laya/gcompris-1
  def end(self):
    # stop the animation
    if self.running:
      self.playing_stop()

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

    if gcompris.sugar_detected():
      fd, tmp_file = tempfile.mkstemp(dir='/tmp')
      os.close(fd)
      os.chmod(tmp_file, 0644)
      fles.doc.anim_to_file(tmp_file)
      gcompris.sugar_save(tmp_file)

    # Remove the root item removes all the others inside it
    gcompris.set_cursor(gcompris.CURSOR_DEFAULT);
    self.rootitem.remove()
    self.color_rootitem.remove()

    del self.doc
  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)