src/eric7/EricWidgets/EricSpellCheckedTextEdit.py

branch
eric7
changeset 9473
3f23dbf37dbe
parent 9221
bf71ee032bb4
child 9600
367d1b4fcca8
equal deleted inserted replaced
9472:5798ee4a8807 9473:3f23dbf37dbe
11 import contextlib 11 import contextlib
12 12
13 try: 13 try:
14 import enchant 14 import enchant
15 import enchant.tokenize 15 import enchant.tokenize
16 from enchant.errors import TokenizerNotFoundError, DictNotFoundError 16
17 from enchant.errors import DictNotFoundError, TokenizerNotFoundError
17 from enchant.utils import trim_suggestions 18 from enchant.utils import trim_suggestions
18 19
19 ENCHANT_AVAILABLE = True 20 ENCHANT_AVAILABLE = True
20 except ImportError: 21 except ImportError:
21 ENCHANT_AVAILABLE = False 22 ENCHANT_AVAILABLE = False
22 23
23 from PyQt6.QtCore import pyqtSlot, Qt, QCoreApplication 24 from PyQt6.QtCore import QCoreApplication, Qt, pyqtSlot
24 from PyQt6.QtGui import ( 25 from PyQt6.QtGui import (
25 QAction, 26 QAction,
26 QActionGroup, 27 QActionGroup,
27 QSyntaxHighlighter, 28 QSyntaxHighlighter,
28 QTextBlockUserData, 29 QTextBlockUserData,
29 QTextCharFormat, 30 QTextCharFormat,
30 QTextCursor, 31 QTextCursor,
31 ) 32 )
32 from PyQt6.QtWidgets import QMenu, QTextEdit, QPlainTextEdit 33 from PyQt6.QtWidgets import QMenu, QPlainTextEdit, QTextEdit
33 34
34 if ENCHANT_AVAILABLE: 35 if ENCHANT_AVAILABLE:
35 36
36 class SpellCheckMixin: 37 class SpellCheckMixin:
37 """ 38 """
684 QTextEdit.setAcceptRichText(self, accept) 685 QTextEdit.setAcceptRichText(self, accept)
685 self.setFormat("html" if accept else "text") 686 self.setFormat("html" if accept else "text")
686 687
687 688
688 if __name__ == "__main__": 689 if __name__ == "__main__":
690 import os
689 import sys 691 import sys
690 import os 692
691 from PyQt6.QtWidgets import QApplication 693 from PyQt6.QtWidgets import QApplication
692 694
693 if ENCHANT_AVAILABLE: 695 if ENCHANT_AVAILABLE:
694 dictPath = os.path.expanduser(os.path.join("~", ".eric7", "spelling")) 696 dictPath = os.path.expanduser(os.path.join("~", ".eric7", "spelling"))
695 SpellCheckMixin.setDefaultLanguage( 697 SpellCheckMixin.setDefaultLanguage(

eric ide

mercurial