def __init__(self, color=None, image=None, elements=None, normal_params=None, mode="scale to screen"): """Mode: None : if an image is passed, its original size is kept. Otherwise, a <color> (white by default) rect of the size of the screen is used as background image. 'scale to screen' : if an image is passed, it is scaled to fit screen. Otherwise, see behaviour for None. 'cut to screen' : if an image is passed, it is shrinked to fit screen. Otherwise, see behaviour for None. """ super(Background, self).__init__("", elements, normal_params) W, H = functions.get_screen_size() if image: painter = ImageFrame(image, mode=mode) else: if color: painter = BasicFrame((W, H), color) else: painter = BasicFrame((W, H), (255, 255, 255)) self.set_painter(painter)
def __init__(self, color=None, image=None, elements=None, normal_params=None, mode="scale to screen", finish=True): """Background element for another element or menu. <color>: if not None, define the color for the background. <image>: if not None, define the image of the background. <Mode>: None : if an image is passed, its original size is kept. Otherwise, a <color> (white by default) rect of the size of the screen is used as background image. 'scale to screen' : if an image is passed, it is scaled to fit screen. Otherwise, see behaviour for None. 'cut to screen' : if an image is passed, it is shrinked to fit the screen. Otherwise, use behaviour for None. """ super(Background, self).__init__("", elements, normal_params, finish=False) W, H = functions.get_screen_size() if image: painter = ImageFrame(image, mode=mode) else: if color: painter = BasicFrame((W, H), color) else: painter = BasicFrame((W, H), (255, 255, 255)) self.set_painter(painter) if finish: self.finish()
def __init__(self, path=None, color=None, elements=None, normal_params=None): """Image element. <path>: the path to the image. <color>: if path is None, use this color instead of image. """ super(Image, self).__init__("", elements, normal_params) if path: painter = ImageFrame(path, mode=None) else: if color: painter = BasicFrame(style.SIZE, color) else: raise Exception("You must specify either a path or a color") self.set_painter(painter)
def _get_shadow_painter(self): shadow = self._get_raw_shadow() return ImageFrame(shadow, alpha=-1)