def discover(self): """ Discovers nearby devices using the client object. :return: None """ my_box = DropDown() # drop down for discovered devices my_box.btns = [] # contains the buttons in the drop down child devices = self.client.discover( ) # discover and retrieve nearby devices my_box.btns = [] for device in devices: # create buttons for each discovered device in a drop down view print(device) button = Button(text=device[0], padding_x=25, padding_y=25, font_size=20, height=100, width=100) button.bind(on_press=lambda button: my_box.select(button.text)) my_box.btns.append(button) # keep tab on buttons my_box.add_widget(button) # add it to screen mainbutton = Button(text='Show devices', size_hint=(None, None)) mainbutton.bind(on_release=my_box.open) my_box.bind( on_select=lambda instance, x: setattr(mainbutton, 'text', x)) self.ids.d2.clear_widgets() # remove current widgets to add new one self.ids.d2.add_widget(my_box) # add the discovered devices