Correct way to use multiline text for labels and such in kv.

3,012 views
Skip to first unread message

kent nyberg

unread,
Nov 16, 2015, 6:24:47 PM11/16/15
to kivy-...@googlegroups.com
Sorry if the topic is a bit unclear.

I may get into it from the wrong angle, but what if I want a label thats easier to be put in multiple lines in
the kv file?
Python as such seems to use

label = """this is line 1,
this is line 2"""


Correct?


The same usage in a kv files gives an error about object not having attribute __getitem__?


Take for example a label as such:


Label:
Text: """this is line 1
this is line 2"""


This does not work. So there must be a better way right?

Message has been deleted

John Boyd

unread,
Nov 16, 2015, 7:11:30 PM11/16/15
to Kivy users support, ke...@z-sverige.nu
Sorry,

Keep string on one line:

Label:
    text
: 'This is line 1.\n This is line 2'

qua non

unread,
Nov 16, 2015, 7:32:55 PM11/16/15
to kivy-...@googlegroups.com
You should look at the text_align example in the examples dir,  you need to set `text_size`, and halign/valign.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Halonen

unread,
May 17, 2017, 4:03:40 PM5/17/17
to Kivy users support, ke...@z-sverige.nu
Using 

Label:
    text
: 'This is line 1.\\n This is line 2'

Worked for me. (Escape the backslash)

chijindu Nnamani

unread,
May 12, 2020, 5:58:19 PM5/12/20
to Kivy users support
It worked for me too, thanks.
Reply all
Reply to author
Forward
0 new messages