skvsree
skvsree

Reputation: 497

Adding Scrollbar to Boxlayout in Kivy

I am trying to a Boxlayout with ScrollBar in Kivy, but I am not able to do it. Below excerpt of .kv file. I am dynamically adding controls to Boxlayout once the Boxlayout overflows controls are hidden and there is not Scrollbar. Please advise.

<ProcessorUI>: #GridLayout
    cols: 1
    rows: 3
    Label:
        text: 'Output'
        size_hint_x: None
        width: 100
        size_hint_y: None
        height: 20
    ScrollView:
        size_hint: (None, None)
        size: (400, 400)
        BoxLayout:
            id: output
            orientation: 'vertical'
    GridLayout
        cols: 2
        TextInput:
            id: input
            multiline: True
            size_hint_y: None
            height: 40
        Button:
            id: btn_process
            text: 'Process'
            size_hint_x: None
            width: 100
            size_hint_y: None
            height: 40
            on_press: root.on_event()

Upvotes: 1

Views: 7040

Answers (1)

inclement
inclement

Reputation: 29450

ScrollView:
        size_hint: (None, None)
        size: (400, 400)
        BoxLayout:
            id: output
            orientation: 'vertical'

The BoxLayout has no manually set height, so it always precisely fills the Scrollview, and never needs a scrollbar.

You probably actually want something like the following

ScrollView:
        size_hint: (None, None)
        size: (400, 400)
        GridLayout:
            id: output
            cols: 1
            size_hint_y: None
            height: self.minimum_height

These last two lines set the gridlayout height to track the sum of heights of its children. You could also set the height to anything else.

Upvotes: 7

Related Questions