def highlight_slipfactor_description(self):
"""Highlight the description of currosponding slipfactor on selection of inputs
Note : This routine is not in use in current version
:return:
"""
slip_factor = str(self.ui.combo_slipfactor.currentText())
self.textCursor = QTextCursor(self.ui.textBrowser.document())
cursor = self.textCursor
# Setup the desired format for matches
format = QTextCharFormat()
format.setBackground(QBrush(QColor("red")))
# Setup the regex engine
pattern = str(slip_factor)
regex = QRegExp(pattern)
# Process the displayed document
pos = 0
index = regex.indexIn(self.ui.textBrowser.toPlainText(), pos)
while (index != -1):
# Select the matched text and apply the desired format
cursor.setPosition(index)
cursor.movePosition(QTextCursor.EndOfLine, 1)
# cursor.movePosition(QTextCursor.EndOfWord, 1)
cursor.mergeCharFormat(format)
# Move to the next match
pos = index + regex.matchedLength()
index = regex.indexIn(self.ui.textBrowser.toPlainText(), pos)
评论列表
文章目录