Exemple #1
0
    def __init__(self, path):
        super(Paragraph, self).__init__()
        self.defil = 0
        self.state = False
        self.slider_y = 0
        self.hover = False
        self.auto_scroll = True

        text = open(join(CONFIG.system_path, path), 'r').readlines()
        text_height = loaders.text("", fonts['mono']['normal']).get_height()

        #the slider (at left)
        self.width_slider = 34
        self.height_slider = 125
        self.pos_slider = self.width / 20 * 19

        #the main surface
        self.width = 500  #XXX hardcoded values
        self.height = 125  #XXX hardcoded values
        self.surface = pygame.surface.Surface((self.width, self.height))

        #create the surface whiwh will contain _all_ the text
        width = self.width - self.width_slider * 2
        if width < 0:
            width = 0
        self.surface_text = pygame.surface.Surface(
            (width, len(text) * text_height))

        #draw all the text into the surface
        for i, t in enumerate(text):
            self.surface_text.blit(
                loaders.text(t.replace('\n', ""), fonts['mono']['normal']),
                (0, text_height * i))

        self.slider = SubPixelSurface(loaders.image(
            join(CONFIG.system_path, "gui", CONFIG.general.THEME,
                 "sliderh_center.png"),
            scale=(self.width_slider, self.height_slider))[0],
                                      x_level=4)