mkfmtr
mkfmtr

Reputation: 47

Kivy - KivyMD ScrollView doesn't scroll and bigger the text, the more goes out of the frame from the top

I'm trying to make an application in python with Kivy and KivyMD that enables a user to see their tasks from a to do list and tap on the tasks to see details of them; like due date, task name and task description. If the task description is too long, I want it to scroll. But for some reason, as the text gets bigger, text inside the ScrollView first gets out of the frame from the top and then from the bottom. It actually lets me do the scrolling function but instead of scrolling, it just acts like I don't have any space to scroll and springs back to it's initial location. I also use ScrollView with MDList for the tasks list and so far, it seems to be working fine.

I tried making a test application with just the scrollview and see if the problem still exists. It does. Here's the test application:

main.py

from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

class MainApp(MDApp):
    def build(self):
        return Builder.load_file('main.kv')

class WindowManager(ScreenManager):
    pass

class TestWindow(Screen):
    pass

if __name__ == "__main__":
    MainApp().run()

main.kv

#: include testwindow.kv

WindowManager:
    TestWindow:

testwindow.kv

<TestWindow>:
    name: "testwin"
    Screen:
        ScrollView:
            do_scroll_x: False
            size_hint: 1, 1
            pos_hint: {"center_x": 0.5, "center_y": 0.5}
            MDLabel:
                id: scrollabel
                text: "Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as analysis, generating algorithms, profiling algorithms' accuracy and resource consumption, and the implementation of algorithms (usually in a chosen programming language, commonly referred to as coding). The source code of a program is written in one or more languages that are intelligible to programmers, rather than machine code, which is directly executed by the central processing unit. The purpose of programming is to find a sequence of instructions that will automate the performance of a task (which can be as complex as an operating system) on a computer, often for solving a given problem. Proficient programming thus usually requires expertise in several different subjects, including knowledge of the application domain, specialized algorithms, and formal logic."
                text_size: self.height, None
                font_size: 16
                halign: 'left'
                size_hint_y: None

Upvotes: 0

Views: 446

Answers (1)

ApuCoder
ApuCoder

Reputation: 2888

In order to enable the vertical scrolling of text you need to bind the prop. height of MDLabel to its texture height, also don't modify its text_size.

            MDLabel:
                id: scrollabel
                text: "Computer programming is the process...formal logic."
                size_hint_y: None
                height: self.texture_size[1]
#                text_size: self.height, None
                font_size: 16
                halign: 'left'

Upvotes: 1

Related Questions