示例#1
0
    def transition_slide(self, old_screen, old_surface, new_screen,
            new_surface):
        text = get_text_transparent(old_screen.name)

        for i in range(0, 10):
            time.sleep(1.00 / float(CONFIG.general.MAX_FPS))
            self.skin.get_background()
            text.set_alpha((i * -1 + 10) * 250 / 10)
            self.screen.blit(text,
                (old_screen.indent_title, 10))
            self.screen.blit(old_surface,
                (optimize_size((i * 8 * 10, 0))[0], old_screen.widget.y))

            pygame.display.update()

        text = get_text_transparent(new_screen.name)

        for i in range(0, 10):
            time.sleep(1.00 / float(CONFIG.general.MAX_FPS))
            self.skin.get_background()
            text.set_alpha(i * 250 / 10)
            self.screen.blit(text,
                    (self.screens[self.current_screen].indent_title, 10))
            self.screen.blit(new_surface,
                (optimize_size((i * 8 * 10 - 800, 0))[0],
                self.screens[self.current_screen].widget.y))

            pygame.display.update()
示例#2
0
    def __init__(self, text):
        super(Slider, self).__init__()
        self.focusable = False
        self.text = text
        self.keyboard = False
        self.space = 0
        self.parentpos = (0, 0)
        self.extend = False
        self.value = 0
        self.orientation = False

        self.screen = pygame.display.get_surface()
        self.index = 0
        self.state = False
        self.height = optimize_size((250, 25))[1]
        self.width = (optimize_size((25, 25))[0] + optimize_size(
            (25, 25))[0] + optimize_size((100, 25))[0])

        self.background = loaders.image(join(CONFIG.system_path, 'gui',
                                             CONFIG.general.THEME,
                                             'slider_background.png'),
                                        scale=(self.width, self.height))[0]

        self.center = loaders.image(join(CONFIG.system_path, 'gui',
                                         CONFIG.general.THEME,
                                         'slider_center.png'),
                                    scale=(self.height, self.height))[0]

        self.center_hover = loaders.image(join(CONFIG.system_path, 'gui',
                                               CONFIG.general.THEME,
                                               'slider_center_hover.png'),
                                          scale=(self.height, self.height))[0]
    def __init__(self, text):
        super(Slider, self).__init__()
        self.focusable = False
        self.text = text
        self.keyboard = False
        self.space = 0
        self.parentpos = (0, 0)
        self.extend = False
        self.value = 0
        self.orientation = False

        self.screen = pygame.display.get_surface()
        self.index = 0
        self.state = False
        self.height = optimize_size((250, 25))[1]
        self.width = (
                optimize_size((25, 25))[0] +
                optimize_size((25, 25))[0] +
                optimize_size((100, 25))[0])

        self.background = loaders.image(
                join(CONFIG.system_path, 'gui',
                    CONFIG.general.THEME, 'slider_background.png'),
                scale=(self.width, self.height))[0]

        self.center = loaders.image(
                join(CONFIG.system_path, 'gui',
                    CONFIG.general.THEME, 'slider_center.png'),
                scale=(self.height, self.height))[0]

        self.center_hover = loaders.image(
                join(CONFIG.system_path, 'gui',
                    CONFIG.general.THEME, 'slider_center_hover.png'),
                scale=(self.height, self.height))[0]
示例#4
0
    def transition_slide(self, old_screen, old_surface, new_screen,
                         new_surface):
        text = get_text_transparent(old_screen.name)

        for i in range(0, 10):
            time.sleep(1.00 / float(CONFIG.general.MAX_FPS))
            self.skin.get_background()
            text.set_alpha((i * -1 + 10) * 250 / 10)
            self.screen.blit(text, (old_screen.indent_title, 10))
            self.screen.blit(old_surface, (optimize_size(
                (i * 8 * 10, 0))[0], old_screen.widget.y))

            pygame.display.update()

        text = get_text_transparent(new_screen.name)

        for i in range(0, 10):
            time.sleep(1.00 / float(CONFIG.general.MAX_FPS))
            self.skin.get_background()
            text.set_alpha(i * 250 / 10)
            self.screen.blit(
                text, (self.screens[self.current_screen].indent_title, 10))
            self.screen.blit(new_surface,
                             (optimize_size((i * 8 * 10 - 800, 0))[0],
                              self.screens[self.current_screen].widget.y))

            pygame.display.update()
示例#5
0
 def add(self, widget, **kwargs):
     """
     This function is used to add a widget in the container
     """
     self.current_focus = -1
     self.widgets.append(widget)
     if 'size' in kwargs or type(widget) is Button:
         if 'size' in kwargs:
             size = kwargs['size']
         else:
             size = widget.properties["size_request"]
         widget.set_size((size[0], size[1]))
     if 'margin' in kwargs:
         margin = kwargs['margin']
     else:
         margin = optimize_size((0, 10))[1]
     if self.orientation:
         widget.margin = margin*CONFIG.general.WIDTH/800
     else:
         widget.margin = margin*CONFIG.general.HEIGHT/480
     if 'margin_left' in kwargs:
         widget.margin_left = kwargs['margin_left']
     if 'align' in kwargs:
         if not self.orientation and kwargs['align'] == "center":
             widget.margin_left = self.width/2 - widget.width/2
         #widget.set_align(kwargs['align'])
     self.update_size()
     self.update_pos()
示例#6
0
 def add(self, widget, **kwargs):
     """
     This function is used to add a widget in the container
     """
     self.current_focus = -1
     self.widgets.append(widget)
     if 'size' in kwargs or type(widget) is Button:
         if 'size' in kwargs:
             size = kwargs['size']
         else:
             size = widget.properties["size_request"]
         widget.set_size((size[0], size[1]))
     if 'margin' in kwargs:
         margin = kwargs['margin']
     else:
         margin = optimize_size((0, 10))[1]
     if self.orientation:
         widget.margin = margin * CONFIG.general.WIDTH / 800
     else:
         widget.margin = margin * CONFIG.general.HEIGHT / 480
     if 'margin_left' in kwargs:
         widget.margin_left = kwargs['margin_left']
     if 'align' in kwargs:
         if not self.orientation and kwargs['align'] == "center":
             widget.margin_left = self.width / 2 - widget.width / 2
         #widget.set_align(kwargs['align'])
     self.update_size()
     self.update_pos()
示例#7
0
    def __init__(self, values, width=100):
        """
        values is an array of string. Each string is an option.
        """
        super(Spinner, self).__init__()
        self.focusable = False
        self.parentpos = (0, 0)
        self.extend = False
        self.values = values
        self.orientation = True
        self.center_width = width
        self.surface = pygame.Surface((self.width, self.height))
        self.widgets = []
        self.left_arrow = ImageButton(
                join("gui", CONFIG.general.THEME, "spinner_left.png"),
                join("gui", CONFIG.general.THEME, "spinner_left_hover.png"))

        self.left_arrow.set_size((37, 45))
        self.add(self.left_arrow, margin = 0)
        self.center = Label('',
            background=join(
                "gui",
                CONFIG.general.THEME,
                "spinner_center.png"),
            align="center",
            width=100,
            height=35)

        self.add(self.center, margin = 0, size=(self.center_width, 45))
        self.right_arrow = ImageButton(
                join("gui", CONFIG.general.THEME, "spinner_right.png"),
                join("gui", CONFIG.general.THEME, "spinner_right_hover.png"))
        self.right_arrow.set_size((37, 45))
        self.add(self.right_arrow, margin = 0)
        self.update_pos()
        self.update_size()

        self.text = values[0]
        self.state = False
        self.height = optimize_size((250, 30))[1]
        self.width = (
                optimize_size((25, 30))[0] * 2 +
                optimize_size((self.center_width, 30))[0])
        self.set_index(0)
示例#8
0
    def __init__(self, value):
        super(KeyboardWidget, self).__init__()
        self.value = value
        try:
            self.letter = pygame.key.name(pygame.__dict__[self.value]).upper()
        except KeyError:
            self.letter = str(self.value)

        self.font = fonts['mono']['25']
        self.set_size(optimize_size((35, 35)))
        self.state = False
        self.focus = False
    def __init__(self, value):
        super(KeyboardWidget, self).__init__()
        self.value = value
        try:
            self.letter = pygame.key.name(pygame.__dict__[self.value]).upper()
        except KeyError:
            self.letter = str(self.value)

        self.font = fonts['mono']['25']
        self.set_size(optimize_size((35, 35)))
        self.state = False
        self.focus = False