QPainTextEditer:纯文本编辑
案例
from PyQt5.Qt import * import sys # *************占位提示文本***************开始 # app = QApplication(sys.argv) # # window = QWidget() # window.setWindowTitle(‘学习‘) # window.resize(500, 500) # # text = QPlainTextEdit(window) # text.resize(100, 100) # text.move(200, 200) # text.setPlaceholderText(‘123‘) # 设置占位提示文本 # print(text.placeholderText()) # # window.show() # # sys.exit(app.exec_()) # *************占位提示文本***************结束 # *************设置只读***************开始 # app = QApplication(sys.argv) # # window = QWidget() # window.setWindowTitle(‘学习‘) # window.resize(500, 500) # # text = QPlainTextEdit(window) # text.resize(100, 100) # text.move(200, 200) # text.setPlaceholderText(‘123‘) # 设置占位提示文本 # print(text.placeholderText()) # # text1 = QPlainTextEdit(window) # text1.resize(100, 100) # text1.move(200, 300) # text1.setReadOnly(True) # 设置只读 # print(text1.isReadOnly()) # # window.show() # # sys.exit(app.exec_()) # *************设置只读***************结束 # *************覆盖模式***************开始 # app = QApplication(sys.argv) # # window = QWidget() # window.setWindowTitle(‘学习‘) # window.resize(500, 500) # # text = QPlainTextEdit(window) # text.resize(100, 100) # text.move(200, 200) # text.setPlaceholderText(‘123‘) # 设置占位提示文本 # print(text.placeholderText()) # text.setOverwriteMode(True) # 设置覆盖模式 # # text1 = QPlainTextEdit(window) # text1.resize(100, 100) # text1.move(200, 300) # text1.setReadOnly(True) # 设置只读 # print(text1.isReadOnly()) # # window.show() # # sys.exit(app.exec_()) # *************覆盖模式***************结束 # *************占位提示文本***************开始 # app = QApplication(sys.argv) # # window = QWidget() # window.setWindowTitle(‘学习‘) # window.resize(500, 500) # # text = QPlainTextEdit(window) # text.resize(100, 100) # text.move(200, 200) # text.setPlaceholderText(‘123‘) # 设置占位提示文本 # print(text.placeholderText()) # text.setOverwriteMode(False) # 设置覆盖模式 # text.setTabChangesFocus(True) # tab控制 # # # text1 = QPlainTextEdit(window) # text1.resize(100, 100) # text1.move(200, 300) # text1.setReadOnly(True) # 设置只读 # print(text1.isReadOnly()) # # window.show() # # sys.exit(app.exec_()) # *************占位提示文本***************结束 # *************文本操作***************开始 # app = QApplication(sys.argv) # # window = QWidget() # window.setWindowTitle(‘学习‘) # window.resize(500, 500) # # text = QPlainTextEdit(window) # text.resize(100, 100) # text.move(200, 200) # text.setPlaceholderText(‘123‘) # 设置占位提示文本 # print(text.placeholderText()) # text.setOverwriteMode(False) # 设置覆盖模式 # text.setTabChangesFocus(True) # tab控制 # # # text1 = QPlainTextEdit(window) # text1.resize(100, 100) # text1.move(200, 300) # text1.setPlainText(‘789‘) # 设置普通文本 # text1.appendPlainText(‘aaaaa‘) #添加文本 # print(text1.isReadOnly()) # # window.show() # # sys.exit(app.exec_()) # *************文本操作***************结束 # *************块操作***************开始 # app = QApplication(sys.argv) # # window = QWidget() # window.setWindowTitle(‘学习‘) # window.resize(500, 500) # # text = QPlainTextEdit(window) # text.resize(100, 100) # text.move(200, 200) # text.setPlaceholderText(‘123‘) # 设置占位提示文本 # print(text.placeholderText()) # text.setOverwriteMode(False) # 设置覆盖模式 # text.setTabChangesFocus(True) # tab控制 # # # text1 = QPlainTextEdit(window) # text1.resize(100, 100) # text1.move(200, 300) # text1.setMaximumBlockCount(3) # 设置最大块数显示的行数 # print(text1.isReadOnly()) # # window.show() # # sys.exit(app.exec_()) # *************块操作***************结束
原文:https://www.cnblogs.com/mosewumo/p/12532248.html