Search code examples
pythonkivykivy-language

How does one wrap text in kivy python file?


I'm attempting to wrap text in kivy in my label. How would I go about that? I've tried googling it, but I've only seen results in a .kv file. There is a specific reason in why I need to use a python file, so I haven't gotten any leads.

class GUI(App):
    def build(self):
        mainLayout = BoxLayout(orientation="vertical")      
  
        out = Label(text="Output: ", font_size="25dp", color="#00FFCE")
        mainLayout.add_widget(out)
        return mainLayout

if __name__ == "__main__":
    window = GUI()
    window.run()

Solution

  • Try using \n:

    out = Label(text="Output: \nInput", font_size="25dp", color="#00FFCE")
    

    or:

            text = '''
    Abba
    Dabba
    Doo
            '''
            out = Label(text=text, font_size="25dp", color="#00FFCE")