예제 #1
0
 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)
예제 #2
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
예제 #3
0
 def response(self, query):
     self.incoming_text.color = hex8("#000000")
     self.incoming_text.text = query
     self. incoming_text.halign = "center"
     self.incoming_text.valign = "middle"
     self.incoming_text.pos_hint = [0.5, 0.5]
     self.incoming_text.font_size = "17dp" if len(self.text.text) < 70 else '10dp'
     self.incoming_text.texture_update()
     self.incoming_text.text_size = self.width, None
     self.texture = self.incoming_text.texture
     self.incoming.md_bg_color = hex8("#ffff00")
     self.incoming.size_hint_x = 1
     self.incoming.height = 243
     self.incoming.padding = "3dp"
     self.incoming.add_widget(self.incoming_text)
     emp2 = Widget()
     emp2.size_hint_x = 1
     emp2.height = 0.5
     self.Top.size_hint_y = len(range(self.count))
     self.Bot.add_widget(emp2)
     self.Bot.add_widget(self.incoming)
     self.Container.height = self.text_msg.size_hint_y
     self.Bot.width = self.incoming_text.size_hint_y
     self.Scroll.scroll_to(self.incoming)
     sound.play()
예제 #4
0
 def send_it(self, message):
     self.count += 1
     br = Bot_Response()
     text = f"{self.text.text}"
     abc = br.respond(text)
     self.text_msg.color = hex8("#000000")
     self.text_msg.text = message
     self.text_msg.pos_hint = [0.5, 0.5]
     self.text_msg.halign = "center"
     self.text_msg.valign = "middle"
     self.text_msg.font_size = "17dp" if len(self.text.text) < 70 else '10dp'
     self.text_msg.texture_update()
     self.text_msg.text_size = self.width, None
     self.texture = self.text_msg.texture
     self.msg.md_bg_color = hex8("#ffff00")
     self.msg.size_hint_x = 1
     self.msg.height = 243
     self.msg.padding = "3dp"
     self.msg.add_widget(self.text_msg)
     emp = Widget()
     emp.size_hint_x = 1
     emp.height = 0.5
     sound.play()
     if self.count >= 1:
         print(self.count)
         self.Container.add_widget(self.msg)
         self.Container.add_widget(emp)
         self.response(abc)
     return self.count
예제 #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
예제 #6
0
    def collide_customed(self, widget):
        '''
        Function which implement custom collision between 2 widgets
        This function draw a square with center (self.center_x, self.center_y) and size = ( widget.size - self.size)/2 (1 if res <0)
        :param Widget: the widget to test collision with self
        :type widget = Widget, we will use center_x,center_y and size
        
        :return Return true is self's custom zone is in collision with widget
    '''
        #Calcul of radius
        size = ((widget.size_hint_x - self.size_hint_x) / 4)
        # if r <=0, the test will be done with a point
        if (size <= 0):
            size = 1
        #Creation of the zone
        zone = Widget()
        zone.center_x = widget.center_x
        zone.center_y = widget.center_y
        zone.size_hint_x = size
        zone.size_hint_y = size

        #Test the collision
        return (self.collide_widget(zone))
예제 #7
0
 def collide_customed(self, widget):
     '''
     Fonction which implement custom collision between 2 widgets
     This function draw a square with center (self.center_x, self.center_y) and size = ( widget.size - self.size)/2 (1 if res <0)
     :param Widget: the widget to test collision with self
     :type widget = Widget, we will use center_x,center_y and size
     
     :return Return true is self's custom zone is in collision with widget
 '''
     #Calcul of radius
     size = ((widget.size_hint_x - self.size_hint_x)/4)
     # if r <=0, the test will be done with a point
     if (size<=0):
         size = 1
     #Creation of the zone
     zone = Widget()
     zone.center_x = widget.center_x
     zone.center_y = widget.center_y
     zone.size_hint_x = size
     zone.size_hint_y = size
     
     #Test the collision
     return(self.collide_widget(zone))