本文整理汇总了Python中PyQt5.QtGui.QTextCursor.End方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCursor.End方法的具体用法?Python QTextCursor.End怎么用?Python QTextCursor.End使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QTextCursor
的用法示例。
在下文中一共展示了QTextCursor.End方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: content
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def content(self, data):
assert isinstance(data, (bytearray, bytes))
if isinstance(data, bytes):
data = bytearray(data)
self._content = data
if self.previous.formatted_view:
self.printable = True
self.ui.toggle_formatted_view.click()
elif not all(chr(c) in string.printable for c in self._content):
# If there are non-printable characters,
# switch to hex view.
self.printable = False
self.ui.toggle_hex_view.click()
else:
# Prevent the field from overwriting itself with invalid
# characters.
self.printable = True
self.ui.toggle_text_view.setEnabled(True)
self.ui.toggle_text_view.click()
self.text_field.moveCursor(QTextCursor.End)
self.update_length_field()
示例2: UpdateOutputText
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def UpdateOutputText(self, text):
""" write console output to text widget """
cursor = self.process.textCursor()
cursor.movePosition(QTextCursor.End)
if isinstance(text, bytes):
text = text.decode()
cursor.insertText(text)
self.process.setTextCursor(cursor)
self.process.ensureCursorVisible()
示例3: append_text
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def append_text(self, text):
"""Append new text and scroll output to bottom.
We can't use Qt's way to append stuff because that inserts weird
newlines.
"""
self.moveCursor(QTextCursor.End)
self.insertPlainText(text)
scrollbar = self.verticalScrollBar()
scrollbar.setValue(scrollbar.maximum())
示例4: update_content
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def update_content(self):
new_content = self.terminal.read()
new_content = self.process_backspaces(new_content)
if not new_content:
return
scrollbar = self.outputTextEdit.verticalScrollBar()
assert isinstance(scrollbar, QScrollBar)
# Preserve scroll while updating content
current_scroll = scrollbar.value()
prev_cursor = self.outputTextEdit.textCursor()
self.outputTextEdit.moveCursor(QTextCursor.End)
# Use any backspaces that were left in input to delete text
cut = 0
for x in new_content:
if x != "\b":
break
self.outputTextEdit.textCursor().deletePreviousChar()
cut += 1
self.outputTextEdit.insertPlainText(new_content[cut:])
self.outputTextEdit.setTextCursor(prev_cursor)
if self._auto_scroll:
scrollbar.setValue(scrollbar.maximum())
else:
scrollbar.setValue(current_scroll)
示例5: updateReceivedDataDisplay
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def updateReceivedDataDisplay(self,str):
if str != "":
curScrollValue = self.receiveArea.verticalScrollBar().value()
self.receiveArea.moveCursor(QTextCursor.End)
endScrollValue = self.receiveArea.verticalScrollBar().value()
self.receiveArea.insertPlainText(str)
if curScrollValue < endScrollValue:
self.receiveArea.verticalScrollBar().setValue(curScrollValue)
else:
self.receiveArea.moveCursor(QTextCursor.End)
self.statusBarSendCount.setText("%s(bytes):%d" %(parameters.strSend ,self.sendCount))
self.statusBarReceiveCount.setText("%s(bytes):%d" %(parameters.strReceive ,self.receiveCount))
示例6: write
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def write(self, msg):
self.insertPlainText('%s\n' % msg)
self.moveCursor(QTextCursor.End)
self._buffer.write(msg)
示例7: write
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def write(self, text: str, color: QColor) -> None:
self._cursor.movePosition(QTextCursor.End)
self._cursor.insertText(text, self._setupFormat(color))
示例8: logOutput
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def logOutput(self, log):
# 获取当前系统时间
time = datetime.now().strftime('[%Y/%m/%d %H:%M:%S]')
log = time + ' ' + log + '\n'
self.logTextEdit.moveCursor(QTextCursor.End)
self.logTextEdit.insertPlainText(log)
self.logTextEdit.ensureCursorVisible() # 自动滚屏
# 系统对话框
示例9: logOutput
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def logOutput(self, log):
time = datetime.now().strftime('[%Y/%m/%d %H:%M:%S]')
log = time + ' ' + log + '\n'
self.logTextEdit.moveCursor(QTextCursor.End)
self.logTextEdit.insertPlainText(log)
self.logTextEdit.ensureCursorVisible() # 自动滚屏
# 系统对话框
示例10: appendText
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def appendText(self, text):
# GUI CLEAR SIGNAL is a string that will be printed by RunMultiCMD to
# indicate a clear screen to this widget
if text == GUI_CLEAR_SIGNAL:
self.ui.textEdit.clear()
return
self.ui.textEdit.moveCursor(QTextCursor.End)
self.ui.textEdit.insertPlainText(text)
示例11: loadSigLogFile
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def loadSigLogFile(self):
"""读取本地信号日志并写入界面"""
sigLogPath = r"./log/trade.dat"
with open(sigLogPath, "r", encoding="utf-8") as f:
data = f.read()
self.signal_log_widget.setText(data)
self.signal_log_widget.moveCursor(QTextCursor.End)
示例12: loadSysLogFile
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def loadSysLogFile(self):
"""读取本地系统日志"""
sysLogPath = r"./log/equant.log"
# with open(sysLogPath, "r", encoding="utf-8") as f:
with open(sysLogPath, "r") as f:
data = f.read()
self.sys_log_widget.setText(data)
self.sys_log_widget.moveCursor(QTextCursor.End)
示例13: append_to_console
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def append_to_console(self, text):
self.consoleArea.moveCursor(QTextCursor.End)
self.consoleArea.insertHtml(text)
示例14: append_data
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def append_data(self, msg):
"""
Add data to the end of the text area.
"""
cursor = self.text_area.textCursor()
cursor.movePosition(QTextCursor.End)
cursor.insertText(msg)
cursor.movePosition(QTextCursor.End)
self.text_area.setTextCursor(cursor)
示例15: test_MicroPythonREPLPane_process_bytes
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import End [as 别名]
def test_MicroPythonREPLPane_process_bytes(qtapp):
"""
Ensure bytes coming from the device to the application are processed as
expected. Backspace is enacted, carriage-return is ignored, newline moves
the cursor position to the end of the line before enacted and all others
are simply inserted.
"""
mock_serial = mock.MagicMock()
mock_tc = mock.MagicMock()
mock_tc.movePosition = mock.MagicMock(
side_effect=[True, False, True, True]
)
mock_tc.deleteChar = mock.MagicMock(return_value=None)
rp = mu.interface.panes.MicroPythonREPLPane(mock_serial)
rp.textCursor = mock.MagicMock(return_value=mock_tc)
rp.setTextCursor = mock.MagicMock(return_value=None)
rp.insertPlainText = mock.MagicMock(return_value=None)
rp.ensureCursorVisible = mock.MagicMock(return_value=None)
bs = bytes([8, 13, 10, 65]) # \b, \r, \n, 'A'
rp.process_bytes(bs)
rp.textCursor.assert_called_once_with()
assert mock_tc.movePosition.call_count == 4
assert mock_tc.movePosition.call_args_list[0][0][0] == QTextCursor.Down
assert mock_tc.movePosition.call_args_list[1][0][0] == QTextCursor.Down
assert mock_tc.movePosition.call_args_list[2][0][0] == QTextCursor.Left
assert mock_tc.movePosition.call_args_list[3][0][0] == QTextCursor.End
assert rp.setTextCursor.call_count == 3
assert rp.setTextCursor.call_args_list[0][0][0] == mock_tc
assert rp.setTextCursor.call_args_list[1][0][0] == mock_tc
assert rp.setTextCursor.call_args_list[2][0][0] == mock_tc
assert rp.insertPlainText.call_count == 2
assert rp.insertPlainText.call_args_list[0][0][0] == chr(10)
assert rp.insertPlainText.call_args_list[1][0][0] == chr(65)
rp.ensureCursorVisible.assert_called_once_with()