How are the TreeView and/or RecycleView used in Kivy?
<p>I'm using python 3.5 along with Kivy to write a simple timeclock program.</p>

<p>I need to list employees out so that they can be selected, so that whoever is doing payroll can get an overview of the employees hours.</p>

<p>I have gone over the documentation for both <a href="https://kivy.org/docs/api-kivy.uix.treeview.html" rel="nofollow"><code>TreeView</code></a> and <a href="https://kivy.org/docs/api-kivy.uix.recycleview.html" rel="nofollow"><code>RecycleView</code></a>, but I cannot seem to wrap my head around either of them when it comes to using them in <code>.kv</code> files.</p>

<p>Are there any good examples out there? I am fairly new to Kivy, so maybe I'm missing something?  I cannot seem to find anything on the subject other than, "It's way more complicated than it needs to be and nobody knows how it works".</p>

<p>Here is one approach I took using <code>TreeView</code>, but I couldn't apply colors to the text on the <code>TreeViewLabel</code>s which is desired.  Basically, I just created new classes based on the <code>TreeView</code> and <code>TreeViewLabel</code> classes:</p>

<pre><code>class CustomTreeViewLabel(TreeViewLabel):
    """
    Custom TreeViewLabel for attaching database model instances to a node.
    """
    def __init__(self, user=None, **kwargs):
        super(CustomTreeViewLabel, self).__init__(**kwargs)
        self.user = user


class CustomTreeView(FloatLayout):
    """
    The CustomTreeView is what is used in place of a TreeView since they are useless
    inside of the .kv files.
    """
    def __init__(self, **kwargs):
        super(CustomTreeView, self).__init__(**kwargs)
        self.selected = None

        tree_view = TreeView(
            hide_root=True,
            indent_level=4
        )

        # Use Peewee ORM to grab the teams set up in database
        teams = [team for team in models.Team.select().execute()]

        for team in teams:
            # Create a node with no parent to the TreeView
            team_tree_label = TreeViewLabel(text=team.name)
            tree_view.add_node(team_tree_label)

            # Get users on the given team.
            users = [u for u in models.User.select().where(models.User.team_id == team.id)]
            for user in users:
                # Add the users full name as a TreeViewLabel with the team_tree_label as the parent node.
                user_text = '{} {}'.format(user.first_name, user.last_name)
                tree_view.add_node(CustomTreeViewLabel(user=user, text=user_text, on_touch_up=self.touch, color=(65, 207, 63, 1)), parent=team_tree_label)

        # Add the TreeView widget to the FloatLayout
        self.add_widget(tree_view)

    def touch(self, *args, **kwargs):
        """
        Handle a touch event on a child TreeViewLabel

        :param args:
        :param kwargs:
        :return:
        """

        tree_view_label, motion = args

        if tree_view_label.is_selected and self.selected != tree_view_label:
            # Set the selected label
            self.selected = tree_view_label
            print(tree_view_label.user.id)
            print(tree_view_label.text)
</code></pre>

<p>Then I just imported the <code>CustomTreeView</code> in my <code>.kv</code> file and use it:</p>

<pre><code>#: import CustomTreeView views.CustomTreeView

&lt;TimeClockApp&gt;:
    do_default_tab: False
    tab_width: 200
    padding: 3
    TabbedPanelItem:
        text: 'Time Clock'
        BoxLayout:
            cols: 2
            CustomTreeView
            GridLayout:
                cols: 1
                spacing: 25
                padding: [50, 150, 50, 150]
                BoxLayout:
                    orientation: 'vertical'
                    Label:
                        text: ''
                Button:
                    size_hint: (2, .5)
                    text: 'Clock In'
                    size: (20, 20)
                    on_press: app.root.clock_in(*args)
                Button:
                    size_hint: (2, .5)
                    text: 'Clock Out'
                    size: (20, 20)
</code></pre>

<p>This seems a bit excessive for something that should be pretty simple, and I doubt it would scale well.</p>

<p>What can I do to fix this?  Is this how people normally go about making lists of data in Kivy?  I really don't like doing it this way.</p>