def __init__(self, *args, **kwargs): super(Console, self).__init__(*args, **kwargs) self.x += self.width/2 self.y += self.height/2 self.textbox = text.Text('', size=self.size) self.textbox.background = Game.color('black')
def __init__(self, *args, **kwargs): # set a click handler, if we get one if 'click' in kwargs: self.click = kwargs['click'] # text label # TODO: add more options? self.text = text.Text(kwargs.get('label',''), color=kwargs.get('labelColor',Game.color('black')), ) # graphics self.graphic = kwargs.get('graphic',None) if isinstance(self.graphic, basestring): self.graphic = Image().load(self.graphic) # background self.bgColor = kwargs.get('bgColor', 'gray70') if isinstance(self.bgColor, basestring): self.bgColor = Game.color(self.bgColor) # border self.border = kwargs.get('border',8) # border color self.borderColor = kwargs.get('borderColor', None) # if we don't get a size, figure one out # TODO: if we get a graphic and text, make it the bigger of the two if 'size' not in kwargs: if self.graphic is not None: kwargs['size'] = self.graphic.size elif self.text is not None: kwargs['size'] = self.text.size else: kwargs['size'] = (0,0) kwargs['size'] += (self.border,self.border) super(Button, self).__init__(*args, **kwargs) self.pixels = Game.Surface((self.width,self.height),Game.Constants.SRCALPHA) self.pixels.fill(self.bgColor) self._drawBorder()