MultiLine output text - properties - text is printing as single line

57 Views Asked by At

i have a question:

i read text from a textfile which looks like this:

Item1

Item2

Item3

Item4

def collect_contents(path):
    print("coll")
    f = open(path, "r")
    logdata = f.read()
    f.close()
    return logdata

def load_contents(path):
    print("load")
    logdata = collect_contents(path)
    print(logdata)
    return logdata`

and it prints() in in the stdout like this:
2023/11/26 13:06:09 stdout Item4
2023/11/26 13:06:09 stdout Item3
2023/11/26 13:06:09 stdout Item2
2023/11/26 13:06:09 stdout Item1

but unfortunately this code:

def update_content(state):
    print("update content")
    path = "...path... "
    state.content = load_contents(path)

index = """
#MULTILINE-TEXT
<|ReloadButton|button|on_action=button_pressed|>
#MulitLineTextFromTXTFile
<|{content}|text|>
#MulitLineTextFromTXTFile2
<|{content}|text|raw=True|>
#MulitLineTextFromTXTFile3
<|{content}|text|mode="e;pre"e;:|>
"""

app = Gui(page=index)

leads to this:

MulitLineTextFromTXTFile Item1 Item2 Item3 Item4 MulitLineTextFromTXTFile2 Item1 Item2 Item3 Item4 MulitLineTextFromTXTFile3 Item1 Item2 Item3 Item4

So my question: -Why are the line-breaks lost? What am i missing here? I want to have the Items listed as in the text file..

What would be the character to new line since < br > and "\n" in python won't work...

I was hoping the "raw" or mode="e;pre"e;: would help me keep the line breaks as described here:

https://docs.taipy.io/en/release-2.2/manuals/gui/viselements/text/

#MULTILINE-TEXT
<|ReloadButton|button|on_action=button_pressed|>
#MulitLineTextFromTXTFile
<|{content}|text|>
#MulitLineTextFromTXTFile2
<|{content}|text|raw=True|>
#MulitLineTextFromTXTFile3
<|{content}|text|mode="e;pre"e;:|>

Thanks in advance you for your help!

1

There are 1 best solutions below

1
Florian Jacta On BEST ANSWER

There exists an open issue on this. It would be soon done. For now, replace your text visual elements by an input visual element like this:

<|{your_text}|input|multiline|class_name=fullwidth|>

Not editable:

<|{your_text}|input|multiline|active=False|class_name=fullwidth|>

enter image description here