def __init__(self, x, y, w, h, font, text='', fontSize='medium', resizable=True, startActiveText=False, characterLimit=1000, inputType=None): if getattr(sys, 'frozen', False): # In a bundle self.exeDir = os.path.dirname(sys.executable) else: # In normal python self.exeDir = "" Font.__init__(self, directory=os.path.join(self.exeDir, "..", "fonts")) self.colour_inactive = pygame.Color('lightskyblue3') self.colour_active = pygame.Color('dodgerblue2') self.x = x self.y = y self.width = w self.height = h self.font = font self.rect = pygame.Rect(x, y, w, h) self.rectOld = self.rect.copy() self.color = self.colour_inactive self.text = text self.resizable = resizable self.characterLimit = characterLimit self.inputType = inputType if fontSize == None: self.font = self.font.tinyFont elif fontSize == 'tiny': self.font = self.font.tinyFont elif fontSize == 'small': self.font = self.font.smallFont elif fontSize == 'medium': self.font = self.font.mediumFont elif fontSize == 'large': self.font = self.font.largeFont if startActiveText: self.txt_surface = self.font.render(text, True, self.colour_active) else: self.txt_surface = self.font.render(text, True, self.color) self.active = False self.updated = True self.characterWidth = self.font.size("W")[0] self.text_width = self.txt_surface.get_width()
def __init__(self): Font.__init__(self)