How to print continously in QTextEdit in PyQt5?

Question:

I try to print variables in QTextEdit in a continuous form and not to print each value in a new line in PyQt5. I use the code below to print values:

       for i in myDict.keys():
            L = len(myDict[i])
            if L >= 5:
                self.ui.valueText.append(str(i))

the output of this code is like this:

1
2
3
...

But i want to print them in one line and if i reach the end of Text edit, wrap the text and print them in new line. I want this output:

1,2,3,4,5.....
51,52, ....

I appreciate any answer on this problem.

Asked By: Orca

||

Answers:

You should at first take the text of current QTextEdit and then append it with new value and then print it:

        for i in myDict.keys():
            L = len(myDict[i])
            if L >= 5:
                x= self.ui.valueText.toPlainText()
                self.ui.valueText.setText(x+"("+str(i)+","+str(L)+") ,")
Answered By: Hamid Roghani
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.