G
G
Goodron2017-12-04 14:42:24
Python
Goodron, 2017-12-04 14:42:24

How to make it so that in PyQt5, when displaying information in textBrowser, the line does not replace the previous one?

I wrote the code, but when sending information from textEdit to textBrowser, the next line replaces the previous one, how can I make the next lines print below the previous ones?
Help me please.
5a253423b7c4b819648691.png

  1. Entered text appears here
  2. An example of where it should appear
import sys
# Импортируем наш интерфейс из файла
from bot import *
from PyQt5 import QtCore, QtGui, QtWidgets

class MyWin(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Событие нажатия на кнопку
        self.ui.pushButton.clicked.connect(self.MyFunction)

    # Функция которая выполняется при нажатии на кнопку 
    def MyFunction(self):
        dannie = self.ui.textEdit.toPlainText()
        self.ui.textBrowser.setText(dannie)

if __name__=="__main__":
    app = QtWidgets.QApplication(sys.argv)
    myapp = MyWin()
    myapp.show()
    sys.exit(app.exec_())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
artem78, 2017-12-04
@AlexDarkStalker

self.ui.textBrowser.append(dannie)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question