# \[Question - Resolved\] \[Perspective\] Is there a way to use Python to add a view into a Carousel?

**URL:** <https://forum.inductiveautomation.com/t/question-resolved-perspective-is-there-a-way-to-use-python-to-add-a-view-into-a-carousel/22230>\
**Category:** Ignition Early Access\
**Created:** [January 30, 2019, 6:27pm UTC](https://forum.inductiveautomation.com/t/question-resolved-perspective-is-there-a-way-to-use-python-to-add-a-view-into-a-carousel/22230 "2019-01-30T18:27:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe.friedrich](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joe.friedrich/32/7505_2.png) [@joe.friedrich](https://forum.inductiveautomation.com/u/joe.friedrich)\
**Post date:** [January 30, 2019, 6:27pm UTC](https://forum.inductiveautomation.com/t/question-resolved-perspective-is-there-a-way-to-use-python-to-add-a-view-into-a-carousel/22230/1 "2019-01-30T18:27:47Z")

</div>

I wish to populate a Carousel with DataSet data. My thinking is that this would be similar to populating a FlexRepeater.

-Is there a Python command to create a new View under view.Carousel.props.views?  
-Is there a Python command to create a new Value under view.Carousel.props.views[#].viewParams?

The idea is to have a Carousel of variable length.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 30, 2019, 6:55pm UTC](https://forum.inductiveautomation.com/t/question-resolved-perspective-is-there-a-way-to-use-python-to-add-a-view-into-a-carousel/22230/2 "2019-01-30T18:55:13Z")

</div>

You’d want to build a dataset where each item in the dataset is a an object which has a viewPath key and an internal list named viewParams where each entry is a tuple of viewParam key:value pairs.

pseudo-code:

```auto
view_list = []
# for each entry in your list
for i in range(len(view_dataset)):
    # make a new viewPath key:value entry
    view_list[i]['viewPath'] = view_dataset[i]['view_path']
    # if we also have viewParams for the entry
    if view_dataset[i]['view_params'] is not None:
        # make a new dictionary with a key of 'viewParams' to hold the keys and values
        view_list[i]['viewParams'] = () # dictionary, not list
        # for every param we specify
        for j in range(len(view_dataset[i]['view_params'])):
            # set our viewParam dictionary to have a key which is our first value in the tuple, and a value which is our second tuple value
            view_list[i]['viewParams'][view_dataset[i]['view_params'][j][0]] = view_dataset[i]['view_params'][j][1]
# set our props.views value to be our new list
self.props.views = view_list

```

There’s got to be a less-verbose-but-more-visually-complicated way to manage that, but there you go.  
hard-coding a dataset worked for me:

```auto
    first_view_dict = dict()
    first_view_dict['viewPath'] = 'Templates/PopupViews/Displays/Icon/ComponentSettings'
    second_view_dict = dict()
    second_view_dict['viewPath'] = 'Experimentation/ReplThree'
    second_view_dict['viewParams'] = dict()
    second_view_dict['viewParams']['End Time'] = 'Supplied'
    third_view_dict = dict()
    third_view_dict['viewPath'] = 'Templates/PopupViews/Inputs/Dropdown/ComponentSettings'
    view_dataset = dict()
    view_dataset['views'] = []
    view_dataset['views'].append(first_view_dict)
    view_dataset['views'].append(second_view_dict)
    view_dataset['views'].append(third_view_dict)
    self.getSibling('Carousel').props.views = view_dataset['views']

```

---

<div class="post-metadata">

**Author:** ![joe.friedrich](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joe.friedrich/32/7505_2.png) [@joe.friedrich](https://forum.inductiveautomation.com/u/joe.friedrich)\
**Post date:** [January 30, 2019, 7:24pm UTC](https://forum.inductiveautomation.com/t/question-resolved-perspective-is-there-a-way-to-use-python-to-add-a-view-into-a-carousel/22230/3 "2019-01-30T19:24:47Z")

</div>

**Thank You!!** 👏
