def search_contact_setp2(self, _result_friend, _result_room): _main = BoxLayout() _popup = Popup(title='搜索结果', title_font=cn_font_1) # 显示好友搜索结果 _scroll_friends = ScrollView(size_hint=[1, 1]) _box_friends = StackLayout(spacing=[5, 5], size_hint=[1, None]) for _result_name, _result_value in _result_friend.items(): _btn = Button(text=_result_name, font_name=cn_font_1, size_hint=[0.25, None]) _btn._id = _result_value['username'] _btn.bind(on_release=partial(self.search_result_choose, _popup)) _box_friends.add_widget(_btn) _scroll_friends.add_widget(_box_friends) _box_friends.height = self.height / 9 * (int(len(_result_friend) / 4) + 1) _scroll_friends.height = self.height * 0.8 # 显示群组搜索结果 _scroll_rooms = ScrollView(size_hint=[1, 1]) _box_rooms = StackLayout(spacing=[5, 5], size_hint=[1, None]) for _result_name, _result_value in _result_room.items(): _btn = Button(text=_result_name, font_name=cn_font_1, size_hint=[0.25, None]) _btn._id = _result_value['username'] _btn.bind(on_release=partial(self.search_result_choose, _popup)) _box_rooms.add_widget(_btn) _scroll_rooms.add_widget(_box_rooms) _box_rooms.height = self.height / 9 * (int(len(_result_room) / 4) + 1) _scroll_rooms.height = self.height * 0.8 _main.add_widget(_scroll_friends) _main.add_widget(_scroll_rooms) _popup.content = _main _popup.open()