Ejemplo n.º 1
0
    def get_icon_bounding_box(self,
                              constr,
                              location,
                              image_area,
                              image_size,
                              padding,
                              show_label=True):
        """ Create icon bounding box

        :param constr: bounding box
        :param location: image location
        :param image_area: image area in bounding box
        :param image_size: image size inside of image area
        :param padding: padding
        """
        s = State()
        s.show_img = True
        s.show_label = show_label
        s.image_location = location
        s.image_area_percent = image_area
        image_size_percent = image_size
        s.bounding_box = constr
        s.padding = padding
        layout = ButtonLayout(s)
        box = layout.image_rectangle
        box.h = (box.h / 100) * image_size_percent

        return box
Ejemplo n.º 2
0
    def set_state(self, state):
        """ Set new button state
        
        :param state: new state
        """
        self.state = state
        self.components = []
        self.layout = ButtonLayout(state)
        self.show_img = getattr(state, "show_img", False)
        self.show_label = getattr(state, "show_label", False)

        self.selected = False
        self.add_background(state)
        self.add_image(state, self.layout.get_image_rectangle())
        self.add_label(state, self.layout.get_label_rectangle())

        self.name = None
        self.auto_update = state.auto_update
        self.clicked = False

        self.state.event_origin = self