本文整理汇总了Python中PyQt5.QtWidgets.QPlainTextEdit.insertPlainText方法的典型用法代码示例。如果您正苦于以下问题:Python QPlainTextEdit.insertPlainText方法的具体用法?Python QPlainTextEdit.insertPlainText怎么用?Python QPlainTextEdit.insertPlainText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QPlainTextEdit
的用法示例。
在下文中一共展示了QPlainTextEdit.insertPlainText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TextAreaWindow
# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import insertPlainText [as 别名]
class TextAreaWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(440, 240))
self.setWindowTitle("PyQt5 Textarea example")
# Add text field
self.b = QPlainTextEdit(self)
self.b.insertPlainText("You can write text here.\n")
self.b.move(10, 10)
self.b.resize(400, 200)
示例2: TracebackWidget
# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import insertPlainText [as 别名]
class TracebackWidget(QWidget):
"""
Represents a python traceback
"""
def __init__(self, traceback_msg):
super(TracebackWidget, self).__init__()
vbox = QVBoxLayout(self)
self._editor = QPlainTextEdit()
vbox.addWidget(QLabel(_translate("TracebackWidget", 'Traceback')))
vbox.addWidget(self._editor)
self._editor.setReadOnly(True)
self._editor.insertPlainText(traceback_msg)
示例3: TracebackWidget
# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import insertPlainText [as 别名]
class TracebackWidget(QWidget):
"""
Represents a python traceback
"""
def __init__(self, traceback_msg):
super(TracebackWidget, self).__init__()
vbox = QVBoxLayout(self)
self._editor = QPlainTextEdit()
vbox.addWidget(QLabel(translations.TR_TRACEBACK))
vbox.addWidget(self._editor)
self._editor.setReadOnly(True)
self._editor.setLineWrapMode(0)
self._editor.insertPlainText(traceback_msg)
self._editor.selectAll()
示例4: DependenciesHelpDialog
# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import insertPlainText [as 别名]
class DependenciesHelpDialog(QDialog):
"""Help on Plugin Dependencies widget"""
def __init__(self, requirements_dict):
super(DependenciesHelpDialog, self).__init__()
self.setWindowTitle(translations.TR_REQUIREMENTS)
self.resize(525, 400)
vbox = QVBoxLayout(self)
label = QLabel(translations.TR_SOME_PLUGINS_NEED_DEPENDENCIES)
vbox.addWidget(label)
self._editor = QPlainTextEdit()
self._editor.setReadOnly(True)
vbox.addWidget(self._editor)
hbox = QHBoxLayout()
btnAccept = QPushButton(translations.TR_ACCEPT)
btnAccept.setMaximumWidth(100)
hbox.addWidget(btnAccept)
vbox.addLayout(hbox)
#signals
btnAccept.clicked['bool'].connect(self.close)
command_tmpl = "<%s>:\n%s\n"
for name, description in list(requirements_dict.items()):
self._editor.insertPlainText(command_tmpl % (name, description))
示例5: HgServeDialog
# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import insertPlainText [as 别名]
#.........这里部分代码省略.........
self.process.start('hg', args)
procStarted = self.process.waitForStarted(5000)
if procStarted:
self.__startAct.setEnabled(False)
self.__stopAct.setEnabled(True)
self.__browserAct.setEnabled(True)
self.__portSpin.setEnabled(False)
self.__styleCombo.setEnabled(False)
self.vcs.getPlugin().setPreferences("ServerPort", port)
self.vcs.getPlugin().setPreferences("ServerStyle", style)
else:
E5MessageBox.critical(
self,
self.tr('Process Generation Error'),
self.tr(
'The process {0} could not be started. '
'Ensure, that it is in the search path.'
).format('hg'))
def __stopServer(self):
"""
Private slot to stop the Mercurial server.
"""
if self.process is not None and \
self.process.state() != QProcess.NotRunning:
self.process.terminate()
self.process.waitForFinished(5000)
if self.process.state() != QProcess.NotRunning:
self.process.kill()
self.__startAct.setEnabled(True)
self.__stopAct.setEnabled(False)
self.__browserAct.setEnabled(False)
self.__portSpin.setEnabled(True)
self.__styleCombo.setEnabled(True)
def __startBrowser(self):
"""
Private slot to start a browser for the served repository.
"""
ui = e5App().getObject("UserInterface")
ui.launchHelpViewer(
"http://localhost:{0}".format(self.__portSpin.value()))
def closeEvent(self, e):
"""
Protected slot implementing a close event handler.
@param e close event (QCloseEvent)
"""
self.__stopServer()
def __procFinished(self, exitCode, exitStatus):
"""
Private slot connected to the finished signal.
@param exitCode exit code of the process (integer)
@param exitStatus exit status of the process (QProcess.ExitStatus)
"""
self.__stopServer()
def __readStdout(self):
"""
Private slot to handle the readyReadStandardOutput signal.
It reads the output of the process and inserts it into the log.
"""
if self.process is not None:
s = str(self.process.readAllStandardOutput(),
self.vcs.getEncoding(), 'replace')
self.__appendText(s, False)
def __readStderr(self):
"""
Private slot to handle the readyReadStandardError signal.
It reads the error output of the process and inserts it into the log.
"""
if self.process is not None:
s = str(self.process.readAllStandardError(),
self.vcs.getEncoding(), 'replace')
self.__appendText(s, True)
def __appendText(self, txt, error=False):
"""
Private method to append text to the end.
@param txt text to insert (string)
@param error flag indicating to insert error text (boolean)
"""
tc = self.__log.textCursor()
tc.movePosition(QTextCursor.End)
self.__log.setTextCursor(tc)
if error:
self.__log.setCurrentCharFormat(self.cErrorFormat)
else:
self.__log.setCurrentCharFormat(self.cNormalFormat)
self.__log.insertPlainText(txt)
self.__log.ensureCursorVisible()