Пример #1
0
    def create_adapters(self):
        list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 25}

        categories = sorted(fruit_categories.keys())

        self.fruit_categories_dict_adapter = DictAdapter(
                sorted_keys=categories,
                data=fruit_categories,
                args_converter=list_item_args_converter,
                selection_mode='single',
                allow_empty_selection=False,
                cls=ListItemButton)

        fruits = fruit_categories[categories[0]]['fruits']

        self.fruits_dict_adapter = DictAdapter(
                sorted_keys=fruits,
                data=fruit_data,
                args_converter=list_item_args_converter,
                selection_mode='single',
                allow_empty_selection=False,
                cls=ListItemButton)
Пример #2
0
    def create_adapters(self):
        list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 25}

        categories = sorted(fruit_categories.keys())

        self.fruit_categories_dict_adapter = DictAdapter(
            sorted_keys=categories,
            data=fruit_categories,
            args_converter=list_item_args_converter,
            selection_mode='single',
            allow_empty_selection=False,
            cls=ListItemButton)

        fruits = fruit_categories[categories[0]]['fruits']

        self.fruits_dict_adapter = DictAdapter(
            sorted_keys=fruits,
            data=fruit_data,
            args_converter=list_item_args_converter,
            selection_mode='single',
            allow_empty_selection=False,
            cls=ListItemButton)
Пример #3
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 3
        kwargs['size_hint'] = (1.0, 1.0)
        super(CascadingView, self).__init__(**kwargs)

        list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 25}

        # Fruit categories list on the left:
        #
        categories = sorted(fruit_categories.keys())
        fruit_categories_list_adapter = \
            DictAdapter(
                    sorted_keys=categories,
                    data=fruit_categories,
                    args_converter=list_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    cls=ListItemButton)
        fruit_categories_list_view = \
                ListView(adapter=fruit_categories_list_adapter,
                        size_hint=(.2, 1.0))
        self.add_widget(fruit_categories_list_view)

        # Fruits, for a given category, in the middle:
        #
        image_list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 32}
        fruits_list_adapter = \
                FruitsDictAdapter(
                    sorted_keys=fruit_categories[categories[0]]['fruits'],
                    data=fruit_data,
                    args_converter=image_list_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    template='ThumbnailedListItem')
        fruits_list_view = \
                ListView(adapter=fruits_list_adapter,
                    size_hint=(.2, 1.0))

        fruit_categories_list_adapter.bind(
                on_selection_change=fruits_list_adapter.fruit_category_changed)

        self.add_widget(fruits_list_view)

        # Detail view, for a given fruit, on the right:
        #
        detail_view = FruitImageDetailView(
                fruit_name=fruits_list_adapter.selection[0].fruit_name,
                size_hint=(.6, 1.0))

        fruits_list_adapter.bind(
                on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)
    def __init__(self, **kwargs):
        kwargs['cols'] = 3
        super(CascadingView, self).__init__(**kwargs)

        list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 25}

        # Fruit categories list on the left:
        #
        categories = sorted(fruit_categories.keys())
        fruit_categories_list_adapter = \
            DictAdapter(
                    sorted_keys=categories,
                    data=fruit_categories,
                    args_converter=list_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    cls=ListItemButton)
        fruit_categories_list_view = \
                ListView(adapter=fruit_categories_list_adapter,
                        size_hint=(.2, 1.0))
        self.add_widget(fruit_categories_list_view)

        # Fruits, for a given category, in the middle:
        #
        image_list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 32}
        fruits_list_adapter = \
                FruitsDictAdapter(
                    sorted_keys=fruit_categories[categories[0]]['fruits'],
                    data=fruit_data,
                    args_converter=image_list_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    template='ThumbnailedListItem')
        fruits_list_view = \
                ListView(adapter=fruits_list_adapter,
                    size_hint=(.2, 1.0))

        fruit_categories_list_adapter.bind(
                on_selection_change=fruits_list_adapter.fruit_category_changed)

        self.add_widget(fruits_list_view)

        # Detail view, for a given fruit, on the right:
        #
        detail_view = FruitImageDetailView(
                fruit_name=fruits_list_adapter.selection[0].fruit_name,
                size_hint=(.6, 1.0))

        fruits_list_adapter.bind(
                on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)
Пример #5
0
    def __init__(self, **kwargs):
        kwargs["cols"] = 3
        super(CascadingView, self).__init__(**kwargs)

        list_item_args_converter = lambda row_index, rec: {"text": rec["name"], "size_hint_y": None, "height": 25}

        # Fruit categories list on the left:
        #
        categories = sorted(fruit_categories.keys())
        fruit_categories_list_adapter = DictAdapter(
            sorted_keys=categories,
            data=fruit_categories,
            args_converter=list_item_args_converter,
            selection_mode="single",
            allow_empty_selection=False,
            cls=ListItemButton,
        )
        fruit_categories_list_view = ListView(adapter=fruit_categories_list_adapter, size_hint=(0.2, 1.0))
        self.add_widget(fruit_categories_list_view)

        # Fruits, for a given category, in the middle:
        #
        image_list_item_args_converter = lambda row_index, rec: {"text": rec["name"], "size_hint_y": None, "height": 32}
        fruits_list_adapter = FruitsDictAdapter(
            sorted_keys=fruit_categories[categories[0]]["fruits"],
            data=fruit_data,
            args_converter=image_list_item_args_converter,
            selection_mode="single",
            allow_empty_selection=False,
            template="ThumbnailedListItem",
        )
        fruits_list_view = ListView(adapter=fruits_list_adapter, size_hint=(0.2, 1.0))

        fruit_categories_list_adapter.bind(on_selection_change=fruits_list_adapter.fruit_category_changed)

        self.add_widget(fruits_list_view)

        # Detail view, for a given fruit, on the right:
        #
        detail_view = FruitImageDetailView(fruit_name=fruits_list_adapter.selection[0].fruit_name, size_hint=(0.6, 1.0))

        fruits_list_adapter.bind(on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)
Пример #6
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 3
        super(CascadingView, self).__init__(**kwargs)

        list_item_args_converter = \
                lambda row_index, selectable: {'text': selectable.name,
                                               'size_hint_y': None,
                                               'height': 25}

        # Add a fruit categories list on the left. We use ListAdapter, for
        # which we set the data argument to the list of CategoryItem
        # instances from above. The args_converter only pulls the name
        # property from these instances, adding also size_hint_y and height.
        # selection_mode is single, because this list will "drive" the second
        # list defined below. allow_empty_selection is False, because we
        # always want a selected category, so that the second list will be
        # populated. Finally, we instruct ListAdapter to build list item views
        # using the provided cls, ListItemButton.
        #
        fruit_categories_list_adapter = \
            ListAdapter(data=category_data_items,
                        args_converter=list_item_args_converter,
                        selection_mode='single',
                        allow_empty_selection=False,
                        cls=ListItemButton)

        fruit_categories_list_view = \
                ListView(adapter=fruit_categories_list_adapter,
                         size_hint=(.2, 1.0))

        self.add_widget(fruit_categories_list_view)

        # Fruits, for a given category, are in a list in the middle, which
        # uses FruitsListsAdapter, defined above. FruitsListAdapter has a
        # fruit_changed() method that updates the data list. The binding
        # to the fruit_categories_list_adapter is set up after
        # instantiation of the fruit_list_adapter.
        #
        first_category_fruits = \
            fruit_categories[fruit_categories.keys()[0]]['fruits']

        first_category_fruit_data_items = \
            [f for f in fruit_data_items if f.name in first_category_fruits]

        fruits_list_adapter = \
                FruitsListAdapter(data=first_category_fruit_data_items,
                                  args_converter=list_item_args_converter,
                                  selection_mode='single',
                                  allow_empty_selection=False,
                                  cls=ListItemButton)

        fruit_categories_list_adapter.bind(
            on_selection_change=fruits_list_adapter.fruit_category_changed)

        fruits_list_view = \
                ListView(adapter=fruits_list_adapter, size_hint=(.2, 1.0))

        self.add_widget(fruits_list_view)

        # Detail view, for a given fruit, on the right:
        #
        detail_view = FruitDetailView(
            fruit_name=fruits_list_adapter.selection[0].text,
            size_hint=(.6, 1.0))

        fruits_list_adapter.bind(on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)
Пример #7
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 3
        super(CascadingView, self).__init__(**kwargs)

        list_item_args_converter = \
                lambda row_index, selectable: {'text': selectable.name,
                                               'size_hint_y': None,
                                               'height': 25}

        # Add a fruit categories list on the left. We use ListAdapter, for
        # which we set the data argument to the list of CategoryItem
        # instances from above. The args_converter only pulls the name
        # property from these instances, adding also size_hint_y and height.
        # selection_mode is single, because this list will "drive" the second
        # list defined below. allow_empty_selection is False, because we
        # always want a selected category, so that the second list will be
        # populated. Finally, we instruct ListAdapter to build list item views
        # using the provided cls, ListItemButton.
        #
        fruit_categories_list_adapter = \
            ListAdapter(data=category_data_items,
                        args_converter=list_item_args_converter,
                        selection_mode='single',
                        allow_empty_selection=False,
                        cls=ListItemButton)

        fruit_categories_list_view = \
                ListView(adapter=fruit_categories_list_adapter,
                         size_hint=(.2, 1.0))

        self.add_widget(fruit_categories_list_view)

        # Fruits, for a given category, are in a list in the middle, which
        # uses FruitsListsAdapter, defined above. FruitsListAdapter has a
        # fruit_changed() method that updates the data list. The binding
        # to the fruit_categories_list_adapter is set up after
        # instantiation of the fruit_list_adapter.
        #
        first_category_fruits = \
            fruit_categories[list(fruit_categories.keys())[0]]['fruits']

        first_category_fruit_data_items = \
            [f for f in fruit_data_items if f.name in first_category_fruits]

        fruits_list_adapter = \
                FruitsListAdapter(data=first_category_fruit_data_items,
                                  args_converter=list_item_args_converter,
                                  selection_mode='single',
                                  allow_empty_selection=False,
                                  cls=ListItemButton)

        fruit_categories_list_adapter.bind(
            on_selection_change=fruits_list_adapter.fruit_category_changed)

        fruits_list_view = \
                ListView(adapter=fruits_list_adapter, size_hint=(.2, 1.0))

        self.add_widget(fruits_list_view)

        # Detail view, for a given fruit, on the right:
        #
        detail_view = FruitDetailView(
                fruit_name=fruits_list_adapter.selection[0].text,
                size_hint=(.6, 1.0))

        fruits_list_adapter.bind(
                on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)