当前位置: 首页>>代码示例>>Python>>正文


Python ListAdapter.check_for_empty_selection方法代码示例

本文整理汇总了Python中kivy.adapters.listadapter.ListAdapter.check_for_empty_selection方法的典型用法代码示例。如果您正苦于以下问题:Python ListAdapter.check_for_empty_selection方法的具体用法?Python ListAdapter.check_for_empty_selection怎么用?Python ListAdapter.check_for_empty_selection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.adapters.listadapter.ListAdapter的用法示例。


在下文中一共展示了ListAdapter.check_for_empty_selection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_list_adapter_selection_mode_single

# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import check_for_empty_selection [as 别名]
    def test_list_adapter_selection_mode_single(self):
        list_adapter = ListAdapter(data=fruit_data_items,
                                   args_converter=self.args_converter,
                                   selection_mode='single',
                                   propagate_selection_to_data=True,
                                   allow_empty_selection=True,
                                   cls=ListItemButton)
        list_view = ListView(adapter=list_adapter)

        # The reason why len(selection) == 0 here is because ListView,
        # at the end of its __init__(), calls check_for_empty_selection()
        # and does NOT trigger the initial selection, because we set
        # allow_empty_selection = True.
        self.assertEqual(len(list_adapter.selection), 0)
        list_adapter.check_for_empty_selection()

        # Nothing should have changed by that call, because still we have
        # allow_empty_selection = True, so no action in that check.
        self.assertEqual(len(list_adapter.selection), 0)

        # Still no selection, but triggering a selection should make len = 1.
        # So, first we need to select the associated data item.
        self.assertEqual(fruit_data_items[0].name, 'Apple')
        fruit_data_items[0].is_selected = True
        apple = list_view.adapter.get_view(0)
        self.assertEqual(apple.text, 'Apple')
        self.assertTrue(apple.is_selected)
        self.assertEqual(len(list_adapter.selection), 1)
开发者ID:Titousensei,项目名称:kivy,代码行数:30,代码来源:test_selection.py

示例2: test_list_adapter_selection_mode_single_auto_selection

# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import check_for_empty_selection [as 别名]
    def test_list_adapter_selection_mode_single_auto_selection(self):
        list_adapter = ListAdapter(data=fruit_data_items,
                                   args_converter=self.args_converter,
                                   selection_mode='single',
                                   allow_empty_selection=False,
                                   cls=ListItemButton)
        list_view = ListView(adapter=list_adapter)

        # The reason why len(selection) == 1 here is because ListView,
        # at the end of its __init__(), calls check_for_empty_selection()
        # and triggers the initial selection, because allow_empty_selection is
        # False.
        apple = list_view.adapter.cached_views[0]
        self.assertEqual(list_adapter.selection[0], apple)
        self.assertEqual(len(list_adapter.selection), 1)
        list_adapter.check_for_empty_selection()

        # Nothing should have changed for len, as we already have a selection.
        self.assertEqual(len(list_adapter.selection), 1)
开发者ID:Titousensei,项目名称:kivy,代码行数:21,代码来源:test_selection.py

示例3: test_list_adapter_selection_mode_none

# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import check_for_empty_selection [as 别名]
    def test_list_adapter_selection_mode_none(self):
        list_adapter = ListAdapter(data=fruit_data_items,
                                   args_converter=self.args_converter,
                                   selection_mode='none',
                                   allow_empty_selection=True,
                                   cls=ListItemButton)

        self.assertEqual(sorted([obj.name for obj in list_adapter.data]),
            ['Apple', 'Avocado', 'Banana', 'Cantaloupe', 'Cherry', 'Grape',
             'Grapefruit', 'Honeydew', 'Kiwifruit', 'Lemon', 'Lime',
             'Nectarine', 'Orange', 'Peach', 'Pear', 'Pineapple', 'Plum',
             'Strawberry', 'Tangerine', 'Watermelon'])

        # The reason why len(selection) == 0 here is because it is ListView,
        # at the end of its __init__(), that calls check_for_empty_selection()
        # and triggers the initial selection, and we didn't make a ListView.
        self.assertEqual(len(list_adapter.selection), 0)
        list_adapter.check_for_empty_selection()
        self.assertEqual(len(list_adapter.selection), 0)
开发者ID:Titousensei,项目名称:kivy,代码行数:21,代码来源:test_selection.py


注:本文中的kivy.adapters.listadapter.ListAdapter.check_for_empty_selection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。