Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll_to method jumps new widgets between bottom and top #8717

Open
tjolin-awe opened this issue May 6, 2024 · 0 comments
Open

Scroll_to method jumps new widgets between bottom and top #8717

tjolin-awe opened this issue May 6, 2024 · 0 comments

Comments

@tjolin-awe
Copy link

Software Versions

  • Python: 3
  • OS: Raspbian Bookworm (Raspberry Pi4) & Windows 10
  • Kivy: 2.3.0
  • Kivy installation method: pip

Describe the bug
"scroll_to" causes added widgets to jump between the top and bottom of a "GridLayout"

Expected behavior
The widget should be added to the top of the "GridLayout" and scroll to the new item
if it overflows the visible portion of the "GridLayout"

To Reproduce
Add widget to "GridLayout"
Add a second widget of the same type to the same "GridLayout"

Code and Logs and screenshots

        listview = self.ids.layout_container
        if partstr not in Globals.partlist:
            Globals.partlist.append(partstr)
            listview.add_widget(PartWidget())
            listview.children[0].part_label = partstr
        else:
            Globals.partlist.append("Duplicate part: {}".format(partstr))
            listview.dup_label = "Duplicate part: {}".format(partstr)
            listview.add_widget(DuplicateWidget())
            listview.children[0].dup_label = "Duplicate part: {}".format(partstr)
        
      
        listview.parent.scroll_to(listview.children[0], animate=True)   # If this is not called lines stack from top to bottom 
        Clock.schedule_once(self.manager.get_screen('scanlistscreen')._refocus_text_input, 1)
        self.manager.get_screen('scanlistscreen').reset_form()
<PartWidget>:
    size_hint: 1, .1
    id: 'dragwidget'
    spacing: 5

    BoxLayout:
        Label:
            id: part_label
            size_hint: .84, 1
            text: root.part_label
            font_size: 16
            canvas.before:
                Color:
                    rgba: .196,.5,1,1
                Rectangle:
                    size: self.size
                    pos: self.pos
        Button:
            id: delbtn
            size_hint: .15, 1
            on_press:
                root.del_part()
            Image:
                source: "./trashcan_part.png"
                background_color: .196,.5,1,1
                allow_stretch: True
                size: delbtn.size
                pos: delbtn.pos
<ScanListScreen>:
    name: 'ScanListScreen'
    BoxLayout:
        id: scanlistscreen
        orientation: 'vertical'
        height: self.minimum_height

        BoxLayout:
            # Message at top of screen
            size_hint: 1, .095
            Label:
                text: root.message
                font_size: 32

        ScrollView:
            GridLayout:
                layout_container: layout_container
                # Grid containing part widgets
                id: layout_container
                cols: 1
                spacing: 5
                row_force_default: True
                row_default_height: 70
                size_hint_x: 1
                size_hint_y: None
                height: self.minimum_height

        TextInput:
            id: partstr
            # Tiniest height possible, hidden widget
            size_hint: 1, 1
            # An input box that can be seen
            # size_hint: 1, 1
            width: root.width
            focus: True
            # opacity: 0 hides the widget
            opacity: 0
            multiline:False
            on_text_validate:
                root.add_part(partstr.text)

        BoxLayout:
            # Box for Accept/Cancel buttons
            spacing: 5
            size_hint: 1,.13
            width: root.width
            pos: root.pos
            orientation: 'horizontal'
            Button:
                text: "Cancel"
                background_color: 1,0,0,1
                font_size: 24
                on_press:
                    root.cancel()
            Button:
                text: "Accept"
                background_color: 0,1,0,1
                font_size: 24
                on_press:
                    root.accept()

Expected Behavior from Kivy 1.11
expected_adding_first_item(Kivy_1_11)
expected_adding_second_item(Kivy_1_11)

Behavior with Kivy 2.3.0
issue_adding_first_item(Kivy_2_3_0)
issue_adding_second_item(Kivy_2_3_0)
issue_adding_third_item(Kivy_2_3_0)

Additional context
-Unexpected behavior difference between Kivy 1.11 and Kivy 2.3.0.
-Tried running 'scroll_to' using Clock.schedule. Behavior still occurs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant