pythonpython-3.xkivylabelkivymd

How i can make multiline label in KivyMD?


I want make multiline label in KV string:

MDLabel:
    text: '

              MultilineText'

But i receive this error:

 text: '
       8:                     
 >>    9:                     MultilineText'
      10:                     
      11:            pos_hint: {'center_x':.5,'center_y':.5}

... Invalid indentation, must be a multiple of 4 spaces Use triple bracket i can't, because my code already in triple bracket:

'''
<Code>
    size_hint_y: None
    height: 60
    FloatLayout:
        MDLabel:
            text: '
                     
                     MultilineText'
                     
            pos_hint: {'center_x':.5,'center_y':.5}
'''

I want multiline long text in one label. help(


Solution

  • Tricky topic. Try this:

    '''
    <Code>
        size_hint_y: None
        height: 60
        FloatLayout:
            MDLabel:
                text: '\\n' +\
                      '\\n' +\
                      'MultilineText'
                         
                pos_hint: {'center_x':.5,'center_y':.5}
    '''