使用QPlainTextEdit在特定位置打印文本

时间:2019-05-23 05:32:34

标签: python pyqt5

我想在GUI中打印我的句子,如下所示:

Example

我尝试了“ QTextEditLogger”

但是我不知道如何在此QTextEditLogger中打印句子或如何更改位置。

def print__(self): 
    print('hello world')

什么都没打印

这里是所有代码


import sys
from PyQt5.QtWidgets import * 
from PyQt5.QtCore import *
import logging

class CInputDialogWindow(QMainWindow):
def __init__(self): 
    super().__init__()
    self.setupUI1()

def setupUI(self): 
    self.setWindowTitle("PyQtInputDialog ex") 
    self.setGeometry(100,100,300,100) 
    self.label = QLabel("age : ", self) 
    self.label.move(20,20) 
    self.label.resize(150,20) 
    self.lineEdit = QLineEdit("", self) 
    self.lineEdit.move(60,20) 
    self.lineEdit.resize(200,20) 
    self.lineEdit.setReadOnly(True) 
    self.btnSave = QPushButton("INPUIT NUMBER", self) 
    self.btnSave.move(10, 50) 
    self.btnSave.clicked.connect(self.btnInput_clicked)

def print__(self): 
    print('hello world')

def setupUI1(self): 
    self.setWindowTitle("PyQtFileDialog es") 
    self.setGeometry(100,100,300,100) 
    self.btnSave = QPushButton("Print Hello world", self) 
    self.btnSave.move(10, 50) 
    self.btnSave.clicked.connect(self.print__)
    self.logBox =  QPlainTextEdit(self)
    self.logBox.setReadOnly(True)


#enter code here


if __name__ == "__main__": 
app = QApplication(sys.argv) 
window = CInputDialogWindow() 
window.show() 
app.exec_()

0 个答案:

没有答案