How can I display terminal input and output in QtDesigner?

Viewed 15

I'm making a project in QtDesigner with Python where the user can build a matrix and the system will show the matrix in a text box or something similar.

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_window1(object):
    def setupUi(self, window1):
        window1.setObjectName("window1")
        window1.resize(485, 530) # 820 530
        self.centralwidget = QtWidgets.QWidget(window1)
        self.centralwidget.setObjectName("centralwidget")
        window1.setCentralWidget(self.centralwidget)

        self.groupBox_2 = QtWidgets.QGroupBox("groupBox_2", self.centralwidget)

        self.output_rd = QtWidgets.QTextBrowser(self.groupBox_2)
        self.output_rd.setGeometry(QtCore.QRect(10, 90, 331, 111))
        self.output_rd.setObjectName("output_rd")

        self.retranslateUi(window1)

        QtCore.QMetaObject.connectSlotsByName(window1)        

    def retranslateUi(self, window1):
            _translate = QtCore.QCoreApplication.translate
            window1.setWindowTitle(_translate("window1", "GUI"))


    def rad_distance(self):
        for i in range(4):
            for j in range(5):
                self.output_rd.append(str(j))                                     # + str


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    window1 = QtWidgets.QMainWindow()
    ui = Ui_window1()
    ui.setupUi(window1)

    ui.rad_distance()                                                           # +

    window1.show()
    sys.exit(app.exec_())

This code is the closest I could get. It's only printing "j" but the output is a number per line, and I don't want this. I want five columns and and four rows. But solving it, I'd also like to know how I can allow the user to enter each matrix value. In fact,what I want most is a simulation of the terminal input/output. Can someone help me?

0 Answers
Related