def __init__ (self, sfc, size = None): if size is None: self.sfc = sfc else: self.sfc = blank_sfc(size) position_sfc(sfc, self.sfc) Widget.__init__(self, sfc.get_size())
def __init__ (self, size, text, font, just = 1): text = game.render_text(font, text, conf.TEXT_COLOUR, width = size[0], just = just)[0] ts = text.get_size() size = [ts[i] if size[i] is None else size[i] for i in (0, 1)] sfc = blank_sfc(size) position_sfc(text, sfc) Img.__init__(self, sfc)
def __init__ (self, width, text): # text is string or surface data = conf.LIST_ITEM if isinstance(text, basestring): sfc = game.render_text('normal', text, conf.TEXT_COLOUR, width = width, bg = data['bg colour'], pad = data['padding'])[0] else: sfc = pg.Surface((width, text.get_height() + 2 * data['padding'][1])) sfc = sfc.convert_alpha() sfc.fill(data['bg colour']) position_sfc(text, sfc) Img.__init__(self, sfc)