Ejemplo n.º 1
0
    def __init__(self,
                 rect: Rect,
                 on_value_changed: Callable[[float], None] = None,
                 value: float = 0,
                 min_value: float = 0,
                 max_value: float = 1,
                 show_handle: bool = True,
                 style: Style = None,
                 parent: Component = None) -> None:
        """Create a new Button. <rect> is the rectangle representing this
        component's position and size on the screen. <on_value_changed> is the
        function called when the slider's value is changed. <value> is the
        starting value of the slider. <min_value> is the smallest number the
        slider can have. <max_value> is the largest number the slider can have.
        <show_handle> is whether or not the handle should be displayed. <style>
        dictates the appearence of the component. If None, the default style
        will be used. <parent> is the component that is
        immediately above this component in the tree.
        """
        self._show_handle = show_handle
        Component.__init__(self, rect, style=style, parent=parent)

        self._value = value
        self._min_value = min_value
        self._max_value = max_value
        self._on_value_changed = on_value_changed
Ejemplo n.º 2
0
 def __init__(self, colour):
     Component.__init__(self, 2, 4, 7, colour)
     self.__pixels = [
         [2, 7],
         [3, 7],
         [4, 7]
     ]
Ejemplo n.º 3
0
    def __init__(self,
                 window,
                 x,
                 y,
                 width=Constants.DEFAULT_WIDTH,
                 height=Constants.DEFAULT_HEIGHT,
                 fillColor=None,
                 borderColor=(0, 0, 0),
                 borderWidth=1,
                 text=None,
                 font=None,
                 textColor=(0, 0, 0),
                 padding=0):
        Component.__init__(self,
                           window,
                           x,
                           y,
                           width=width,
                           height=height,
                           fillColor=fillColor,
                           borderColor=borderColor,
                           borderWidth=borderWidth)
        Clickable.__init__(self, x, y, width=width, height=height)
        self.type = "Button"
        self.font = font
        self.textColor = textColor
        self.label = None
        self.padding = padding
        self.text = text

        if text is not None:
            self.initText()
Ejemplo n.º 4
0
 def __init__(self,
              rect: Rect,
              text: str = "",
              style: Style = None,
              parent: Component = None) -> None:
     """Create a new Label. <rect> is the rectangle representing this
     component's position and size on the screen. <text> is the text to be
     displayed. <style> dictates the appearence of the component. If None,
     the default style will be used. <parent> is the component that is
     immediately above this component in the tree.
     """
     Component.__init__(self, rect, style=style, parent=parent)
     self.set_text(text)
Ejemplo n.º 5
0
 def __init__(self,
              rect: Rect,
              expand_width: bool = True,
              expand_height: bool = True,
              space_around: bool = False,
              style: Style = None,
              parent: Component = None) -> None:
     """Create a new VerticalPanel. <rect> is the rectangle representing
     this component's position and size on the screen. <expand_width>
     decides whether or not to change the children's width to fill this
     component's rect. <expand_height> decides whether or not to change
     the children's height to fill this component's rect. <space_around>
     decides whether or not to add spacing on the top and bottom side of
     this component's children. The children of this component will be
     centered. <style> dictates the appearence of the component. If None,
     the default style will be used. <parent> is the component that is
     immediately above this component in the tree.
     """
     self._expand_width = expand_width
     self._expand_height = expand_height
     self._space_around = space_around
     Component.__init__(self, rect, style=style, parent=parent)
Ejemplo n.º 6
0
    def __init__(self,
                 rect: Rect,
                 folder_path: str = "",
                 animation_duration: float = 1000,
                 style: Style = None,
                 parent: Component = None) -> None:
        """Create a new AnimatedImage. <rect> is the rectangle representing
        this component's position and size on the screen. <folder_path> is
        the path to the folder containing the frames of the animation to be
        displayed. <animation_duration> is the length of the animation in
        miliseconds. <style> dictates the appearence of the component. If None,
        the default style will be used. <parent> is the component that is
        immediately above this component in the tree.
        """
        self._animation_frames = []
        self._raw_frames = []

        self._frame_index = 0
        self._time_since_last_frame = 0

        self._animation_duration = animation_duration
        self._load_animation(folder_path)

        Component.__init__(self, rect, style=style, parent=parent)
Ejemplo n.º 7
0
 def __init__(self, colour):
     Component.__init__(self, 3, 3, 6, colour)
     self.speed = 0
     self.__pixels = [
         [3, 6]
     ]