def update(self): self.background = loaders.image( os.path.join( CONFIG.system_path, "gui", CONFIG.general.THEME,"keyboard.png"), scale=(self.width, self.height))[0] self.background_hover = loaders.image( os.path.join( CONFIG.system_path, "gui", CONFIG.general.THEME, "keyboard_hover.png"), scale=(self.width, self.height))[0] text = loaders.text(self.letter, self.font) if text.get_width() > self.width: text = pygame.transform.smoothscale( text, ( self.width, self.width * text.get_height() / text.get_width())) posx = self.width/2 - text.get_width()/2 posy = self.height/2 - text.get_height()/2 self.surface = loaders.image_layer(self.background_hover, text, (posx, posy)) self.surface_hover = loaders.image_layer(self.background, text, (posx, posy)) self.screen = pygame.display.get_surface()
def draw(self): if self.state: surf = loaders.image_layer(self.background, self.center_hover, (self.value, 0)) else: surf = loaders.image_layer(self.background, self.center, (self.value, 0)) self.screen.blit( surf, (self.parentpos[0] + self.x, self.parentpos[1] + self.y))
def draw(self): if self.state: surf = loaders.image_layer( self.background, self.center_hover, (self.value, 0)) else: surf = loaders.image_layer( self.background, self.center, (self.value, 0)) self.screen.blit(surf, ( self.parentpos[0] + self.x, self.parentpos[1] + self.y))
def set_text(self, text): """ update the text surface """ self.text = text self.surface_text = loaders.text(self.text, fonts['sans']['normal']) if self.dynamic_size[0]: if 'size_request' in self.properties: self.height = max( self.properties['size_request'][1], self.surface_text.get_height() + self.txtmargin * 2) else: self.height = ( self.surface_text.get_height() + self.txtmargin * 2) if self.dynamic_size[1]: if 'size_request' in self.properties: self.width = max( self.properties['size_request'][0], self.surface_text.get_width() + self.txtmargin * 2) else: self.width = self.surface_text.get_width() + self.txtmargin * 2 if self.align == "center": self.indent = self.width / 2 - self.surface_text.get_width() / 2 else: self.indent = 0 self.horizontal_indent = ( self.height / 2 - self.surface_text.get_height() / 2) try: if self.background_expand: self.background = loaders.image( join( CONFIG.system_path, self.background_path), expand=(self.width, self.height, 10))[0] else: self.background = loaders.image( join( CONFIG.system_path, self.background_path), scale=(self.width, self.height))[0] self.surface = loaders.image_layer( self.background, self.surface_text, (self.txtmargin + self.indent, self.horizontal_indent)) except AttributeError: self.surface = self.surface_text self.screen = pygame.display.get_surface()
def set_text(self, text): """ update the text surface """ self.text = text self.surface_text = loaders.text(self.text, fonts['sans']['normal']) if self.dynamic_size[0]: if 'size_request' in self.properties: self.height = max( self.properties['size_request'][1], self.surface_text.get_height() + self.txtmargin * 2) else: self.height = (self.surface_text.get_height() + self.txtmargin * 2) if self.dynamic_size[1]: if 'size_request' in self.properties: self.width = max( self.properties['size_request'][0], self.surface_text.get_width() + self.txtmargin * 2) else: self.width = self.surface_text.get_width() + self.txtmargin * 2 if self.align == "center": self.indent = self.width / 2 - self.surface_text.get_width() / 2 else: self.indent = 0 self.horizontal_indent = (self.height / 2 - self.surface_text.get_height() / 2) try: if self.background_expand: self.background = loaders.image(join(CONFIG.system_path, self.background_path), expand=(self.width, self.height, 10))[0] else: self.background = loaders.image(join(CONFIG.system_path, self.background_path), scale=(self.width, self.height))[0] self.surface = loaders.image_layer( self.background, self.surface_text, (self.txtmargin + self.indent, self.horizontal_indent)) except AttributeError: self.surface = self.surface_text self.screen = pygame.display.get_surface()
def update(self): self.background = loaders.image(os.path.join(CONFIG.system_path, "gui", CONFIG.general.THEME, "keyboard.png"), scale=(self.width, self.height))[0] self.background_hover = loaders.image( os.path.join(CONFIG.system_path, "gui", CONFIG.general.THEME, "keyboard_hover.png"), scale=(self.width, self.height))[0] text = loaders.text(self.letter, self.font) if text.get_width() > self.width: text = pygame.transform.smoothscale( text, (self.width, self.width * text.get_height() / text.get_width())) posx = self.width / 2 - text.get_width() / 2 posy = self.height / 2 - text.get_height() / 2 self.surface = loaders.image_layer(self.background_hover, text, (posx, posy)) self.surface_hover = loaders.image_layer(self.background, text, (posx, posy)) self.screen = pygame.display.get_surface()