Skip to content Skip to sidebar Skip to footer

Pyqt - How To Turn On/off Spellchecking

I'm using the following as a basis for my editor's spellchecker. I want to make an auto-spellcheck button, which when pressed will make the spellchecker work, and when not pressed,

Solution 1:

You can enable and disable the syntax highlighter by using it's setDocument method.

The SpellTextEdit class keeps a reference to its highlighter, so just add a couple of methods like this:

defhighlighterEnabled(self):
     return self.highlighter.document() isnotNonedefsetHighlighterEnabled(self, enable):
    if enable != self.highlighterEnabled():
        if enable:
            self.highlighter.setDocument(self.document())
        else:
            self.highlighter.setDocument(None)

Post a Comment for "Pyqt - How To Turn On/off Spellchecking"