Search code examples
pythonkivykivy-languagekivymd

Scrollable text field in kivymd


I am trying to create a text field where I can display codes and snippets without wrapping text instead I want the text to scroll text along both x and y axis. I am trying to use following code but can't do that

ScrollView:
    CodeInput:
        text:"abc"*30
        scroll_x: True

Solution

  • from kivy.lang import Builder
    from kivymd.app import MDApp
    
    
    KV = '''
    Screen:
        ScrollView:
            id: scroll
            CodeInput:
                size_hint: 1, None
                text: "abc"*3000
                height: max(self.minimum_height, scroll.height)
    '''
    
    
    class MainApp(MDApp):
        def build(self):
            return Builder.load_string(KV)
    
    
    MainApp().run()