QPlainTextEdit的学习
from PyQt5.Qt import *
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('QPlainTextEdit的学习')
self.resize(500, 500)
self.setup_ui()
def setup_ui(self):
pte=QPlainTextEdit(self)
self.pte=pte
pte.resize(300,300)
pte.move(100,100)
self.占位文本提示()
def 占位文本提示(self):
self.pte.setPlaceholderText("请输入你的个人信息")
print(self.pte.placeholderText())
pass
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
from PyQt5.Qt import *
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('QPlainTextEdit的学习')
self.resize(500, 500)
self.setup_ui()
def setup_ui(self):
pte=QPlainTextEdit(self)
self.pte=pte
pte.resize(300,300)
pte.move(100,100)
self.占位文本提示()
# self.只读设置()
self.格式设置()
self.自动换行()
self.覆盖模式()
def 覆盖模式(self):
print(self.pte.overwriteMode())
self.pte.setOverwriteMode(True)
print(self.pte.overwriteMode())
def 自动换行(self):
print(self.pte.lineWrapMode())
self.pte.setLineWrapMode(QPlainTextEdit.NoWrap)
def 格式设置(self):
tcf=QTextCharFormat()
tcf.setFontUnderline(True)
tcf.setUnderlineColor(QColor(100,100,100))
self.pte.setCurrentCharFormat(tcf)
def 只读设置(self):
self.pte.setReadOnly(True)
print(self.pte.isReadOnly())
def 占位文本提示(self):
self.pte.setPlaceholderText("请输入你的个人信息")
print(self.pte.placeholderText())
pass
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())