BrudleMontford BrudleMontford - 10 days ago 5
Python Question

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:


  • I had already tried doing the same as many previous answers, in the particular one mentioned in the comments, I got an error saying "NoneType" has no attribute "bind".

  • I removed the size hint, it still doesn't work, but thanks anyway.

  • The text is definitely long enough.


Answer

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 high 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.