Exemplo n.º 1
0
 def writeQuestion(self):
     questionFont = pygame.font.Font("ubuntu-font-family-0.83/Ubuntu-R.ttf", 30)
     question=str("Select the cards with the %s: %s"%(self.stageModel.tagType,self.stageModel.correctTag))
     #questionRender = questionFont.render(question, True, color.BLACK)
     #self.display.blit(questionRender, [self.posX + 50, self.posY + 50])
     TextWrap.drawText(self.display,
                       question,
                       color.BLACK,
                       pygame.Rect(self.posX + 50, self.posY + 10,1000,150),
                       questionFont,
                       True)
Exemplo n.º 2
0
    def scroll_text(self, text, speed, reformat=True):

        if reformat:
            text_list = TextWrap.wrap(text, 16)
        else:
            text_list = text
        for i in range(len(text_list)):
            if i < len(text_list) - 1:
                self.flash_text(text_list[i], text_list[i+1], speed)
            if i == len(text_list) - 1:
                self.flash_text(text_list[i], duration=speed)
Exemplo n.º 3
0
    def write_text(self, line0=None, line1=None):
        """write_text(line0 : string, line1 : string)
        Write text to the display.  Only update the lines you want.
        If you want to display more 16 chars, only use line0."""
        if line1:
            if len(line1) > 16:
                raise ValueError
        if line0 is None:
            line0 = self.text[0]
        if line1 is None:
            if self.text[1] == self.BLANK_LINE:
                if len(line0) > 16:
                    lines = TextWrap.wrap(line0, 16)
                    line0, line1 = lines
                else:
                    line1 = self.text[1]

        self.text_update(line0=line0, line1=line1)
        self.move_to_pos(0, 0)
        self.ser.write(self.text[0] + self.text[1])
Exemplo n.º 4
0
    def draw(self, display):
        """
        Pure
        Draws the card to the display at pos (self.x,self.y)
        :param display: PyGame display object
        :return: None
        """
        if self.imageType != "":
            display.blit(self.thumbnail, (self.x + 20, self.y + 20, 160, 160))
        font = pygame.font.Font("ubuntu-font-family-0.83/Ubuntu-R.ttf", 18)
        scoreFont = pygame.font.Font("ubuntu-font-family-0.83/Ubuntu-B.ttf",
                                     32)
        if os.name != "nt":
            symbolFont = pygame.font.Font("/System/Library/Fonts/Menlo.ttc",
                                          32)
        else:
            symbolFont = pygame.font.SysFont("Segoe UI Symbol", 32)

        # titleDisplay = font.render(
        #    self.title.format(**self.individual.hrTags),
        #    True,
        #    color.BLACK)
        # display.blit(titleDisplay, (self.cardRect.x+20,self.cardRect.y+210))
        try:
            TextWrap.drawText(
                display, self.title.format(**self.individual.hrTags),
                color.BLACK,
                pygame.Rect(self.cardRect.x + 20, self.cardRect.y + 185, 160,
                            65), font, True)
        except KeyError as e:
            print("Unable to generate title: KeyError\n", e)

        pygtools.drawGoodRect(display, self.borderColor, self.cardRect,
                              self.borderThickness)
        if self.fade:
            surf = pygame.Surface((self.cardRect.w - self.borderThickness,
                                   self.cardRect.h - self.borderThickness),
                                  pygame.SRCALPHA)
            surf.fill((255, 255, 255, 200))
            display.blit(surf, (self.cardRect.x + self.borderThickness / 2,
                                self.cardRect.y + self.borderThickness / 2))

        if self.overlayCaption is not "" and self.overlayCaption is not None:
            surf = pygame.Surface((self.cardRect.w - self.borderThickness,
                                   50 - self.borderThickness), pygame.SRCALPHA)
            surf.fill((255, 255, 255, 170))
            display.blit(surf, (self.cardRect.x + self.borderThickness / 2 + 1,
                                self.cardRect.y + self.borderThickness / 2))

            TextWrap.drawText(
                display, self.overlayCaption,
                (color.BLACK, color.BLUE, color.NICEGREEN,
                 color.RED)[self.symbol],
                pygame.Rect(self.cardRect.x + 15, self.cardRect.y + 5, 160,
                            65), scoreFont, True)

        symbolDisplay = symbolFont.render(["", "", "✔", "✘"][self.symbol],
                                          True, (color.BLACK, color.BLUE,
                                                 color.NICEGREEN,
                                                 color.RED)[self.symbol])
        display.blit(symbolDisplay, (self.cardRect.x + self.cardRect.w - 35,
                                     self.cardRect.y + self.cardRect.h - 52))