Brudle
Brudle

Reputation: 25

GridLayout Not Scrolling in Kivy

Please tell me why this doesn't work, the whole program works fine, it uses a function inside the main program to get it's text, but it won't scroll so the user won't be able to view the entire output.

<AnswerScreen@Screen>:
    input_textb: input_textb
    ScrollView:
        size_hint: (1, None)
        do_scroll_y: True
        do_scroll_x: False
        bar_width: 4
        GridLayout:
            padding: root.width * 0.02, root.height * 0.02
            cols: 1
            size_hint_y: None
            size_hint_x: 1
            height: self.minimum_height
            Label:
                id: input_textb
                text: ""
                font_size: root.height / 25
                text_size: self.width, None

Edit:

Upvotes: 0

Views: 1066

Answers (2)

Kareem El-Ozeiri
Kareem El-Ozeiri

Reputation: 1

You should set a value for the property scroll_y of the ScrollView between 0 and 1.

Upvotes: 0

Tshirtman
Tshirtman

Reputation: 5949

I believe the label's size is not set, which i agree can be confusing at first, Label has a widget size (size as all widgets) and a texture_size, which is set to the actual size of the displayed text, kivy doesn't relate these two in any particular way at first, and it's up to you to decide how one influences the other, you did half of the work in setting text_size to (width, None), which forces the texture into having the width of the widget, but you are missing the other part of the deal, which is that you want to be the widget to be as tall as the generated texture. For this size to be effective, you also have to disable size_hint_y for Label, since it's in a GridLayout.

        Label:
            id: input_textb
            text: ""
            font_size: root.height / 25
            text_size: self.width, None
            height: self.texture_size[1]
            size_hint_y: None

and you should be all set.

Upvotes: 1

Related Questions