Reputation: 23
So I've got a label inside a .kv file that has a paragraph set as the text. Now the text is of course broken up on different lines within the file held together by doc-strings so it doesn't run forever to the right. When I set the label text equal to the paragraph its alignment is way off. Everywhere I've pressed enter within the text, to drop it down to prevent the over-running, also shows up in the label. Is there a way to ignore those so the text is viewed as if it were on a single line?
Label:
text_size: self.size
valign: "top"
halign: "left"
text: """This is an example paragraph used to show how the text is broken
up inside the code. I lack the knowledge on how to remove the breaks from
pressing the 'ENTER' key. I am once again asking for your help"""
Idk if this is common either but everywhere I have a comma, the single space after it is ignored and I am required to double space for a single space to be shown.
Upvotes: 1
Views: 704
Reputation: 39092
You can escape the ENTER
with a \
as below:
text:
"""This is an example paragraph used to show how the text is broken\
up inside the code. I lack the knowledge on how to remove the breaks from\
pressing the 'ENTER' key. I am once again asking for your help"""
Note that the triple quote starts on a new line and is indented. The \
escapes the carriage returns at the end of the lines. And each additional line starts with a space (only because it is a space between words).
You can also do this using string concatenation:
text:
'This is an example paragraph used to show how the text is broken' +\
' up inside the code. I lack the knowledge on how to remove the breaks from' +\
' pressing the "ENTER" key. I am once again asking for your help'
The above uses the +
operator, but again the newlines must be escaped, otherwise the kivy lang parser will interpret the newline as the end of the element.
Upvotes: 1