Edwin
Edwin

Reputation: 805

How do I create multiline texts in kivyMD

I am trying to create a simple app with multiline text, but I keep getting a 'Invalid indentation (too many levels)'. Here is my main.py file;

from kivymd.app import MDApp


class TwoScreenApp(MDApp):
    def build(self):
        return


TwoScreenApp().run()

And here is my .kv file. I would appreciate any sort of help, Thanks.

MDScreen:
    md_bg_color: (255/255, 255/255, 255/255, 1)

MDLabel:
    halign: 'center'
    text: """With the production of the Model T automobile,
            \nHenry Ford had an unforeseen and tremendous
            \nimpact on American life. He became regarded
            \nas an apt symbol of the transition from an
            \nagricultural to an industrial America.
        """

Upvotes: 0

Views: 706

Answers (1)

John Anderson
John Anderson

Reputation: 39092

This will work:

MDLabel:
    halign: 'center'
    text:
        """With the production of the Model T automobile,
        Henry Ford had an unforeseen and tremendous
        impact on American life. He became regarded
        as an apt symbol of the transition from an
        agricultural to an industrial America."""

For some reason, putting the multiline literal starting on a separate line makes it work.

Upvotes: 2

Related Questions