Scroll_to issue

33 views
Skip to first unread message

Sergey Vdovin

unread,
Jan 8, 2019, 8:28:09 AM1/8/19
to Kivy users support
Hello.
I've got a problem with scrolling through a tree from an external script. I attached an original file and a captured video to the post.

What works well:
When I move up and down using a keyboard arrows, everthing is okay. A selected node follows me and a tree scrolls at the same time.

What works badly:
When I press buttons in the right side of the window, I expect that a node will be selected and ScrollView widget should scroll the window to the required node to show it me. As you can see from an attached video, it works incorrectly. For example, If you click "Select 155" button, when you don't see the node in the tree, node, obviously, is selected, but you have to click again to scroll to it.

I hope, my explanation, the video and the attached py file are understandable enough. I've been trying to solve the issue for several days and can't figure out what is happening. Thank you for your help in advance.
tree-scroll-nav.py
Example record.mp4

ZenCODE

unread,
Jan 8, 2019, 4:42:09 PM1/8/19
to Kivy users support
Try changing your node_selector below? I think it's a case of just delaying selection/scrolling until the item is properly opened...

    def node_selector(self, number):
        print(number)

        from kivy.clock import Clock
        def show_node(i):
            self.treeview.select_node(i)
            self.scroll_item.scroll_to(i)

        for item in self.treeview.iterate_all_nodes():
            if item.level != 0 and int(item.text) == number:
                if item.parent_node.is_open is False:
                    self.treeview.toggle_node(item.parent_node)     
                Clock.schedule_once(lambda dt, item=item: show_node(item))

Sergey Vdovin

unread,
Jan 9, 2019, 3:01:34 AM1/9/19
to Kivy users support
Wow! It works now! Thank you very much!!

среда, 9 января 2019 г., 0:42:09 UTC+3 пользователь ZenCODE написал:
Reply all
Reply to author
Forward
0 new messages