Doing a spell checker (using PyQt5 for the interface). I check the sentence entered in the editor and misspelled words, I highlight in red.
Tell me how to do what when you hover over such a word with the mouse, below popup text appeared with correct options? Here is a sample spell check code
import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui, QtWidgets
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Hello")
self.editTextArea = QtWidgets.QPlainTextEdit(self)
self.editTextArea.setGeometry(QtCore.QRect(10, 10, 250, 250))
self.editTextArea.setObjectName("editTextArea")
variants = ['hello', 'hello1', 'hello2']
word = 'Hallo'
text = "The word %s is not spelled correctly! Variants in the variants array and need to be displayed when hovering over the red word of the mouse " % word
text = text.replace(word, '<span style="text-decoration: underline; color: red">' + word + '</span>')
self.editTextArea.appendHtml(text)
if __name__ == '__main__':
app = QApplication(sys.argv)
form = Example()
form.show()
app.exec()
I would like that when you hover the mouse over the red word, a window pops up with the correct options from the variants array, and when you click on one of the correct words, the wrong one is replaced.