示例#1
0
def setup_canvas(canvas, units, units_name):
    data = [[100, 100, 200, 20, 10, 200, 310, 24],
            [100, 100, 200, 20, 10, 200, 310, 24],
            [1, 1, 3, 0.5, 0.16, 3, 4, 0.3], [30, 30, 100, 10, 5, 80, 60, 10]]

    d = data[units]

    root = canvas.get_root_item()

    item = goocanvas.Rect(parent=root, x=d[0], y=d[1], width=d[2], height=d[3])

    item.connect("motion_notify_event", on_motion_notify)

    buffer = "This box is %gx%g %s" % (d[2], d[3], units_name)
    font_desc = "Sans %gpx" % d[4]

    item = goocanvas.Text(parent=root,
                          text=buffer,
                          x=d[0] + d[2] / 2,
                          y=d[1] + d[3] / 2,
                          width=-1,
                          anchor=gtk.ANCHOR_CENTER,
                          font=font_desc)

    buffer = "This font is %g %s high" % (d[7], units_name)
    font_desc = "Sans %gpx" % d[7]

    item = goocanvas.Text(parent=root,
                          text=buffer,
                          x=d[5],
                          y=d[6],
                          width=-1,
                          anchor=gtk.ANCHOR_CENTER,
                          font=font_desc)
示例#2
0
    def setup_texts(self, root):
        pattern = self.create_stipple("blue")
        par = self.make_anchor(root, 420.0, 20.0)
        item = goocanvas.Text(parent=par,
                              text="Anchor NW",
                              x=0,
                              y=0,
                              width=-1,
                              anchor=gtk.ANCHOR_NW,
                              font="Sans Bold 24",
                              fill_pattern=pattern)
        self.setup_item_signals(item)

        par = self.make_anchor(root, 470, 75)
        item = goocanvas.Text(
            parent=par,
            text="Anchor center\nJustify center\nMultiline text\nb8bit text",
            x=0,
            y=0,
            width=-1,
            anchor=gtk.ANCHOR_CENTER,
            font="monospace bold 14",
            alignment=pango.ALIGN_CENTER,
            fill_color="firebrick")
        self.setup_item_signals(item)

        par = self.make_anchor(root, 420, 240)
        textitem = goocanvas.Text(
            parent=par,
            text=
            "This is a very long paragraph that will need to be wrapped over several lines so we can see what happens to line-breaking as the view is zoomed in and out.",
            x=0,
            y=0,
            width=180,
            anchor=gtk.ANCHOR_W,
            font="Sans 12",
            fill_color="goldenrod")
        self.setup_item_signals(textitem)

        textitem = goocanvas.Text(parent=root,
                                  text="Ellipsized text.",
                                  x=20,
                                  y=420,
                                  width=115,
                                  anchor=gtk.ANCHOR_W,
                                  font="Sans 12",
                                  fill_color="blue",
                                  ellipsize=pango.ELLIPSIZE_END)
        self.setup_item_signals(textitem)
示例#3
0
    def __init__(self, hangman, parent, x, y,
                 letter, letters, fill_color, stroke_color):
      self.hangman = hangman
      self.letter = letter
      self.letters = letters
      self.disabled = False

      w = 30
      h = 30

      self.rect = goocanvas.Rect(
        parent = parent,
        x = x,
        y = y,
        width = w,
        height = h,
        fill_color_rgba = fill_color,
        stroke_color_rgba = stroke_color,
        line_width = 1.0)

      self.letterItem = goocanvas.Text(
        parent = parent,
        x = x + w/2,
        y = y + h/2,
        text = letter,
        fill_color = "black",
        anchor = gtk.ANCHOR_CENTER,
        alignment = pango.ALIGN_CENTER
        )

      self.letterItem.connect("button_press_event",
                              self.letter_event, letter)
      self.rect.connect("button_press_event",
                        self.letter_event, letter)
示例#4
0
    def __init__(self, hangman, x, y,
                 letter, letters):
      self.found = False
      parent = hangman.rootitem

      fill_color = 0xFF3366AAL
      stroke_color = 0xFF33CCAAL
      w = 30
      h = 30

      self.letters = letters

      self.rect = goocanvas.Rect(
        parent = parent,
        x = x,
        y = y,
        width = w,
        height = h,
        fill_color_rgba = fill_color,
        stroke_color_rgba = stroke_color,
        line_width = 1.0)

      self.letterItem = goocanvas.Text(
        parent = parent,
        x = x + w/2,
        y = y + h/2,
        text = letter,
        fill_color = "black",
        anchor = gtk.ANCHOR_CENTER,
        alignment = pango.ALIGN_CENTER
        )

      self.hide(True)
示例#5
0
def main(argv):
    window = gtk.Window()
    window.set_default_size(640, 600)
    window.show()
    window.connect("destroy", lambda w: gtk.main_quit())
    
    scrolled_win = gtk.ScrolledWindow()
    scrolled_win.set_shadow_type(gtk.SHADOW_IN)
    scrolled_win.show()
    window.add(scrolled_win)
    
    canvas = goocanvas.Canvas()
    canvas.set_size_request(600, 450)
    canvas.set_bounds(0, 0, 1000, 1000)

    root = canvas.get_root_item()

    CustomRectItem(x=100, y=100, width=400, height=400,
                   line_width=10, stroke_color="grey", parent=root)

    goocanvas.Text(text="Hello World",
                   x=300, y=300,
                   anchor=gtk.ANCHOR_CENTER,
                   font="Sans 24", parent=root).rotate(45, 300, 300)
    
    canvas.show()
    scrolled_win.add(canvas)
    

    gtk.main()
示例#6
0
文件: anim.py 项目: laya/gcompris-1
  def draw_playing_area(self):

    x1=self.playing_area[0]
    y1=self.playing_area[1]
    x2=self.playing_area[2]
    y2=self.playing_area[3]


    # The CanvasGroup for the playing area.
    self.root_playingitem = \
      goocanvas.Group(
        parent = self.rootitem,
      )
    self.root_playingitem.props.visibility = goocanvas.ITEM_INVISIBLE

    # intervall = 1000 / anim_speed
    self.anim_speed=5

    run = \
      goocanvas.Image(
        parent = self.root_playingitem,
      pixbuf = gcompris.utils.load_pixmap("anim/down.png"),
      x = 15,
      y = 410,
      width = 20,
      height = 20,
      )
    run.connect("button_press_event", self.speed_event,False)

    self.speed_item = \
      goocanvas.Text(
        parent = self.root_playingitem,
      text=self.anim_speed,
      font = gcompris.skin.get_font("gcompris/board/medium"),
      x=52,
      y=420,
      anchor=gtk.ANCHOR_CENTER,
      )


    run = \
      goocanvas.Image(
        parent = self.root_playingitem,
      pixbuf = gcompris.utils.load_pixmap("anim/up.png"),
      x = 70,
      y = 410,
      width = 20,
      height = 20,
      )
    run.connect("button_press_event", self.speed_event,True)

    # And finaly a STOP icon
    run = \
      goocanvas.Image(
        parent = self.root_playingitem,
      pixbuf = gcompris.utils.load_pixmap("anim/draw.svg"),
      x = 16,
      y = 110,
      )
    run.connect("button_press_event", self.stop_event, True)
示例#7
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
      )
示例#8
0
  def speed_button(self, x, y, size, text, move):
    button = goocanvas.Rect(
      parent = self.rootitem,
      x = x - size / 2.0,
      y = y - size / 2.0,
      width = size,
      height =  size,
      line_width = 1.0,
      stroke_color_rgba= 0xCECECEFFL,
      fill_color_rgba = 0x333333FFL,
      radius_x = 15.0,
      radius_y = 5.0,
      )
    gcompris.utils.item_focus_init(button, None)

    text = goocanvas.Text(
      parent = self.rootitem,
      x = x,
      y = y,
      text = text,
      font = gcompris.skin.get_font("gcompris/subtitle"),
      fill_color = "white",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_CENTER
      )
    gcompris.utils.item_focus_init(text, button)

    button.connect("button_press_event", self.move_bar, move)
    text.connect("button_press_event", self.move_bar, move)
示例#9
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=txt2,
            font=gcompris.skin.get_font("gcompris/board/medium"),
            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)
示例#10
0
    def display_condition(self, condition):

        #print condition
        # Calc the center
        cx = condition[0][0] + (condition[0][2] - condition[0][0]) / 2
        cy = condition[0][1] + (condition[0][3] - condition[0][1]) / 2

        pixmap = gcompris.utils.load_pixmap("searace/arrow.png")
        item = goocanvas.Image(
            parent=self.root_weather_item,
            pixbuf=pixmap,
            x=cx - pixmap.get_width() / 2,
            y=cy - pixmap.get_height() / 2,
        )
        gcompris.utils.item_rotate_relative(item, condition[1][0])
        item.connect("button_press_event", self.ruler_item_event)
        item.connect("button_release_event", self.ruler_item_event)
        item.connect("motion_notify_event", self.ruler_item_event)

        # Text number
        item = goocanvas.Text(parent=self.root_weather_item,
                              text=condition[1][1],
                              font=gcompris.skin.get_font("gcompris/content"),
                              x=cx,
                              y=cy,
                              fill_color_rgba=0xFFFFFFFFL,
                              anchor=gtk.ANCHOR_CENTER)
        item.connect("button_press_event", self.ruler_item_event)
        item.connect("button_release_event", self.ruler_item_event)
        item.connect("motion_notify_event", self.ruler_item_event)

        return
示例#11
0
    def draw(self):

        self.selected_color = 0x3030AAFFL
        self.default_color = 0xFFFFFFFFL
        self.default_stroke = 0x101080FFL
        self.marked_stroke = 0xC01010FFL

        # Timeline coord
        x1 = self.drawing_area[0]
        x2 = self.drawing_area[2]
        y = self.drawing_area[3] + 5

        # Our timeline repesentation respects the drawing area ratio
        # If we could display a thumbnail of the current frame in each
        # time zone, and we could scroll the time zone.
        #self.zoom = (( self.drawing_area[2] - self.drawing_area[0] ) /
        #             ( self.drawing_area[3] - self.drawing_area[1] ))
        # w = h * self.zoom
        w = 14
        h = 27

        i = x1
        t = 0
        while i + w < x2:

            item = goocanvas.Rect(parent=self.rootitem,
                                  x=i,
                                  y=y,
                                  width=w,
                                  height=h,
                                  fill_color_rgba=self.default_color,
                                  stroke_color_rgba=self.default_stroke,
                                  line_width=1.0,
                                  radius_x=3.0,
                                  radius_y=3.0)
            item.set_data("time", t)

            if not self.selected:
                self.selected = item

            self.timelinelist.append(item)
            item.connect("button_press_event", self.timeline_item_event)

            i += w + 1
            t += 1

        # Frame Number
        self.frame_counter = \
            goocanvas.Text(
            parent = self.anim.rootitem,
            text = 0,
            x = 43,
            y = 460,
            font = gcompris.skin.get_font("gcompris/board/medium"),
            fill_color = "black")

        # Select the first item in the timeline
        self.current_time = 0
        self.select_it(self.selected)
        self.lastmark_it(self.timelinelist[t - 1])
 def __init__(self, next_link, base_node, link_node, base_route_table,
              mterp, msecp, parent_canvas_item, color, path, viz):
     self.base_node = base_node
     self.link_node = link_node
     self.base_route_table = base_route_table
     self.mterp = mterp
     self.msecp = msecp
     self.canvas_item = goocanvas.Group(parent=parent_canvas_item)
     # self.line = goocanvas.Polyline(parent=self.canvas_item, line_width=1.0, stroke_color_rgba=0xC00000FF, start_arrow=True, arrow_length=10,arrow_width=8)
     self.line = goocanvas.Polyline(parent=self.canvas_item,
                                    line_width=2.0,
                                    stroke_color_rgba=color,
                                    start_arrow=True,
                                    close_path=False,
                                    end_arrow=False,
                                    arrow_length=15,
                                    arrow_width=15)
     self.line.raise_(None)
     self.label = goocanvas.Text()  #, fill_color_rgba=0x00C000C0)
     self.label.props.pointer_events = 0
     self.label.set_property("parent", self.canvas_item)
     self.label.raise_(None)
     self.canvas_item.set_data("pyviz-object", self)
     self.canvas_item.lower(None)
     self.way_index = 0
     self.next_link = next_link
     self.path = path
     self.viz = viz
示例#13
0
    def __init__(self, element, composition, timeline):
        goocanvas.Group.__init__(self)
        View.__init__(self)
        Zoomable.__init__(self)

        self.element = element
        self.comp = composition
        self.timeline = timeline

        self.bg = goocanvas.Rect(height=self.__HEIGHT__,
                                 fill_color_rgba=self.__NORMAL__,
                                 line_width=0)

        self.content = Preview(self.element)
        self.name = goocanvas.Text(x=10,
                                   text=os.path.basename(
                                       unquote(element.factory.name)),
                                   font="Sans 9",
                                   fill_color_rgba=0x000000FF,
                                   alignment=pango.ALIGN_LEFT)

        self.start_handle = StartHandle(element,
                                        timeline,
                                        height=self.__HEIGHT__)
        self.end_handle = EndHandle(element, timeline, height=self.__HEIGHT__)

        for thing in (self.bg, self.content, self.start_handle,
                      self.end_handle, self.name):
            self.add_child(thing)

        if element:
            self.zoomChanged()
        self.normal()
示例#14
0
    def writeText(self, txt, x=100, y=250, width=150):
        '''
        write text box with background rectangle to game
        the text is returned and must be removed by the caller
        '''

        # A group that will hold the text description and the background
        textrootitem = goocanvas.Group(parent=self.rootitem)

        t = goocanvas.Text(
            parent=textrootitem,
            x=x,
            y=y,
            width=width,
            font=gcompris.skin.get_font("gcompris/board/medium"),
            text=txt,
            anchor=gtk.ANCHOR_CENTER,
            alignment=pango.ALIGN_CENTER,
            use_markup=True)

        TG = 10
        bounds = t.get_bounds()

        rect = goocanvas.Rect(parent=textrootitem,
                              x=bounds.x1 - TG,
                              y=bounds.y1 - TG,
                              width=bounds.x2 - bounds.x1 + TG * 2,
                              height=bounds.y2 - bounds.y1 + TG * 2,
                              line_width=2.0,
                              radius_x=3.0,
                              radius_y=3.0,
                              fill_color_rgba=TEXT_BG_COLOR,
                              stroke_color="black")
        t.raise_(rect)
        return textrootitem
示例#15
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)
示例#16
0
  def instructions(self, message):
    # Instructions button to begin activity
    self.text = goocanvas.Text(
      parent = self.rootitem,
      x = 400,
      y = 103,
      fill_color = "white",
      anchor = gtk.ANCHOR_CENTER,
      alignment = pango.ALIGN_LEFT,
      width = 500,
      font = gcompris.skin.get_font("gcompris/board/small"),
      text = message )
    self.text.connect('button_press_event', self.ready_event)
    bounds = self.text.get_bounds()
    gap = 20

    self.text_back = goocanvas.Rect(
      parent = self.rootitem,
      radius_x = 6,
      radius_y = 6,
      x = bounds.x1 - gap,
      y = bounds.y1 - gap,
      width = bounds.x2 - bounds.x1 + gap * 2,
      height = bounds.y2 - bounds.y1 + gap * 2,
      stroke_color_rgba = 0xFFFFFFFFL,
      fill_color_rgba = 0xCCCCCC44L)
    gcompris.utils.item_focus_init(self.text_back, None)
    gcompris.utils.item_focus_init(self.text, self.text_back)
    self.text_back.connect('button_press_event', self.ready_event)
        def drawNoteButton(x, y, numID, play_sound_on_click):
            '''
            local method to draw one button
            '''
            if self.colorButtons:
                color = NOTE_COLOR_SCHEME[numID]
            else:
                color = 'white'
            text = getKeyNameFromID(numID, self.sharpNotation)
            vars(self)[str(numID)] = goocanvas.Text(
                parent=self.rootitem,
                x=x,
                y=y,
                text=text,
                fill_color='black',
                anchor=gtk.ANCHOR_CENTER,
                alignment=pango.ALIGN_CENTER,
                pointer_events="GOO_CANVAS_EVENTS_NONE")

            rect = goocanvas.Rect(parent=self.rootitem,
                                  x=x - 12.5,
                                  y=y - 10,
                                  width=25,
                                  height=20,
                                  line_width=.5,
                                  fill_color=color)
            vars(self)[str(numID)].raise_(None)
            vars(self)[str(numID)].scale(2.0, 2.0)
            vars(self)[str(numID)].translate(-250, -150)
            rect.scale(2, 2)
            rect.translate(-250, -150)
            rect.connect("button_press_event", play_sound_on_click, numID)
            rect.set_data('numID', numID)
            gcompris.utils.item_focus_init(rect, None)
            gcompris.utils.item_focus_init(vars(self)[str(numID)], None)
示例#18
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)
示例#19
0
    def __init__(self, element, selection):
        goocanvas.Group.__init__(self)
        selectable.Selectable.__init__(self, selection)
        self.register_instance(self)
        self.element = element
        self.bg = goocanvas.Rect(
            parent = self,
            fill_color = "grey",
            radius_x = 5,
            radius_y = 5)

        self.text = goocanvas.Text(
            parent = self,
            font = "Sans 8 Bold",
            text = element.get_name())

        self.__sourcePads = {}
        self.__sinkPads = {}
        self.__links = {}

        for pad in element.get_pad_template_list():
            if pad.presence != gst.PAD_ALWAYS:
                self.__addPad(pad)

        for pad in element.pads():
            self.__addPad(pad)
示例#20
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)
示例#21
0
 def display_letter(self,letter):
     goocanvas.Text(parent=self.rootitem,
                                x=690,
                                y=330,
                                fill_color="black",
                                font="Sans 78",
                                anchor=gtk.ANCHOR_CENTER,
                                text=str(letter))
示例#22
0
 def paint_qm(self):
     self.qm = goocanvas.Text(
         parent=self.rootitem,
         text="?",
         x=self.place * self.distance + 30 + self.leftx,
         y=165,
         fill_color_rgba=0x000000ffL,
         font=gcompris.skin.get_font("gcompris/board/huge bold"))
示例#23
0
 def display_letter(self, letter):
     goocanvas.Text(parent=self.rootitem,
                    x=690,
                    y=330,
                    fill_color="black",
                    font=gcompris.skin.get_font("gcompris/board/gigantic"),
                    anchor=gtk.ANCHOR_CENTER,
                    text=str(letter))
示例#24
0
 def __init__(self, x, y):
     self.num = None
     self.pic = goocanvas.Text(
         parent=game.rootitem,
         text="",
         font=gcompris.skin.get_font("gcompris/content"),
         x=x,
         y=y)
示例#25
0
    def __init__(self, board, root, x, y, index,
                 board_size,
                 scale):
      self.board = board

      self.itemgroup = goocanvas.Group(parent = root)
      self.itemgroup.translate(x, y)
      self.scale = scale

      if (index == (board_size-1)):
        pixbuf_case = self.board.pixmap_case_last
        pixbuf_mask = self.board.pixmap_mask_last
      else:
        pixbuf_case = self.board.pixmap_case
        pixbuf_mask = self.board.pixmap_mask


      item = goocanvas.Image(
        parent = self.itemgroup,
        pixbuf = pixbuf_case,
        x=0,
        y=0)
      bounds = item.get_bounds()
      # Add a little zoom offset to make sure items stick well
      item.scale(scale + 0.01, scale)

      self.ombre = goocanvas.Image(
        parent = self.itemgroup,
        pixbuf = self.board.pixmap_ombre,
        x=0,
        y=0)
      self.ombre.props.visibility = goocanvas.ITEM_INVISIBLE
      bounds = self.ombre.get_bounds()
      self.ombre.scale(scale, scale)

      self.ball = goocanvas.Image(
        parent = self.itemgroup,
        x=0,
        y=0)
      self.ball.props.visibility = goocanvas.ITEM_INVISIBLE

      item = goocanvas.Image(
        parent = self.itemgroup,
        pixbuf = pixbuf_mask,
        x=0,
        y=0)
      bounds = item.get_bounds()
      item.scale(scale, scale)

      if ((index+1)%5 == 0):
        goocanvas.Text(
          parent = self.itemgroup,
          x = (bounds.x2-bounds.x1)/2,
          y = -10,
          fill_color_rgba = 0x000000ffL,
          font=gcompris.skin.get_font("gcompris/board/small bold"),
          anchor = gtk.ANCHOR_CENTER,
          text = index + 1)
示例#26
0
 def restore(self, anim_):
     AnimItem.restore(self, anim_)
     self.item = \
         goocanvas.Text(
             parent = self.rootitem,
             font = "Sans " + str(self.text_size),
             )
     AnimItem.init_item(self)
     self.last_commit = None
示例#27
0
 def restore(self, anim_):
     AnimItem.restore(self, anim_)
     self.item = \
         goocanvas.Text(
             parent = self.rootitem,
             font = gcompris.skin.get_font("gcompris/fontface") + " " + str(self.text_size),
             )
     AnimItem.init_item(self)
     self.last_commit = None
示例#28
0
  def display_user_list(self, users, start_filter):

    y_start = 80
    y = y_start
    x = gcompris.BOARD_WIDTH/4
    i = 0
    step_y = 90

    for user in users:
      if eval(self.config_dict['uppercase_only']):
        login = user.login.decode('utf8').upper().encode('utf8')
      else:
        login = user.login

      if not login.startswith(start_filter):
        continue

      # The text
      item = goocanvas.Text(
        parent = self.rootitem,
        x= x,
        y= y,
        text= login,
        fill_color="white",
        font=gcompris.skin.get_font("gcompris/board/huge"),
        anchor = gtk.ANCHOR_CENTER,
        )
      item.connect("button_press_event", self.name_click_event, user)

      gap = 10
      bounds = item.get_bounds()
      item_bg = \
          goocanvas.Rect(
          parent = self.rootitem,
          x = bounds.x1 - gap,
          y = bounds.y1 - gap,
          width = bounds.x2 - bounds.x1 + gap*2,
          height = bounds.y2 - bounds.y1 + gap*2,
          line_width=2.0,
          fill_color_rgba=0x555555CAL,
          stroke_color_rgba=0xFFFFFFFFL,
          radius_x=5.0,
          radius_y=5.0)
      item_bg.connect("button_press_event", self.name_click_event, user)
      item.raise_(item_bg)
      # This item is clickeable and it must be seen
      gcompris.utils.item_focus_init(item, item_bg)
      gcompris.utils.item_focus_init(item_bg, None)

      y += step_y
      i += 1

      # Perform the column switch
      if(i==5):
        y = y_start
        x = 3*gcompris.BOARD_WIDTH/4
示例#29
0
 def get_label():
     try:
         label = unused_labels.pop(0)
     except IndexError:
         label = goocanvas.Text(parent=self.viz.canvas.get_root_item(), stroke_color_rgba=self.color)
     else:
         label.set_property("visibility", goocanvas.ITEM_VISIBLE)
         label.lower(None)
     self.labels.append(label)
     return label
示例#30
0
    def init(self, index, select_area, callback):
        height = 90
        x   = select_area[0] + (select_area[2] - select_area[0]) / 2
        y1  = select_area[1] + height * index + 2
        y2  = select_area[1] + height * (index + 1) + 1

        # Create our rootitem. We put each canvas item in it so at the end we
        # only have to kill it. The canvas deletes all the items it contains automaticaly.

        self.root_select_item = goocanvas.Group(
            parent = self.canvas,
            )

        self.select_item = goocanvas.Rect(
            parent = self.root_select_item,
            x = select_area[0]+2,
            y = y1,
            width = select_area[2] - select_area[0] - 4,
            height = y2 - y1,
            fill_color="white",
            stroke_color="white",
            line_width = 1.0
            )
        self.select_item.connect("button_press_event", callback, self)

        y1 += 5

        itemimg = goocanvas.Svg(
            parent = self.root_select_item,
            svg_handle = gcompris.utils.load_svg("administration/config_" +
                                                self.module_name +
                                                 ".svgz")
            )

        bounds = itemimg.get_bounds()
        centered_x = x - (bounds.x2 - bounds.x1)/2
        itemimg.translate(centered_x, y1);
        itemimg.connect("button_press_event", callback, self)
        gcompris.utils.item_focus_init(itemimg, None)

        y1 += bounds.y2 - bounds.y1 + 3

        item = goocanvas.Text(
            parent = self.root_select_item,
            text=_(self.module_label),
            font = "Sans 8",
            x = centered_x,
            y = y1,
            fill_color="black"
            )
        bounds = item.get_bounds()
        centered_x = x - (bounds.x2 - bounds.x1)/2
        item.props.x = centered_x
        item.connect("button_press_event", callback, self)
        gcompris.utils.item_focus_init(item, itemimg)