def set_nbr_steps(self, nbr_steps, width, is_indicator_with_image):
     if nbr_steps != self.nbr_steps:
         self.nbr_steps = nbr_steps
         self.indicators.clear()
         self.clear_widgets()
         # add dummy button to be correctly aligned
         dummy_but = Widget()  # instead of Button
         dummy_but.size_hint_x = None
         dummy_but.width = width
         dummy_but.disabled = True
         self.add_widget(dummy_but)
         self.add_widget(
             ImageSeparator())  # add a Track Sound Button with a width
         # rebuild layout by adding the PIBs or the PIIs
         if is_indicator_with_image:
             for i in range(0, nbr_steps):
                 pii = PlayIndicatorImage(
                 )  # (source="images/indicator_light_off.png")
                 self.indicators.append(pii)
                 self.add_widget(pii)
         else:
             for i in range(0, nbr_steps):
                 pib = PlayIndicatorButton(text=str(i + 1))
                 pib.disabled = True
                 pib.color = (1, 1, 1, 0.5)  # text color is (1,1,1,0.4)
                 pib.background_color = (0, 1, 1, .5
                                         )  # bgd color is (0.1,0.1,0.6,.3)
                 pib.background_normal = ''
                 pib.background_disabled_down = ''
                 # tog_but.state = 'down' if i == 0 else 'normal'
                 self.indicators.append(pib)
                 self.add_widget(pib)
Example #2
0
def add_widget_to_menu(
    root_widget: Widget,
    widget: Widget,
) -> None:
    # Searches for Menu Object
    for child in root_widget.children:
        if isinstance(child, Menu):
            widget.width = child.width
            child.add_widget(widget)
            return None
Example #3
0
    def build(self):
        Window.size = (1000, 1000)
        parent = Widget()
        parent.height = 1000
        parent.width = 1000
        self.clearbtn = Button(text='Translate',
                               width=parent.width,
                               height=parent.height,
                               font_size = '50dp')

        self.clearbtn.width = parent.width
        self.clearbtn.height = parent.height
        parent.add_widget(self.clearbtn)
        self.clearbtn.bind(on_release=self.main_pprocess)
        return parent
Example #4
0
    def set_widget_size(w: Widget, x: int, y: int):
        if x <= 1 and x > 0:
            w.size_hint_x = x
        elif x > 1:
            w.size_hint_x = None
            w.width = x
        else:
            pass

        if y <= 1 and y > 0:
            w.size_hint_x = x
        elif y > 1:
            w.size_hint_y = None
            w.height = y
        else:
            pass
Example #5
0
    def set_nb_steps(self, nb_steps):
        if not nb_steps == self.nb_steps:
            # Reconstruire notre layout -> mettre les boutons
            self.lights = []
            self.clear_widgets()

            dummy_widget = Widget()
            dummy_widget.size_hint_x = None
            dummy_widget.width = self.left_align
            self.add_widget(dummy_widget)

            for i in range(0, nb_steps):
                light = PlayIndicatorLight()
                light.source = "images/indicator_light_off.png"
                #    button.state = "down"
                self.lights.append(light)
                self.add_widget(light)

            self.nb_steps = nb_steps