eric7/EricWidgets/EricSpellCheckedTextEdit.py

branch
eric7
changeset 8629
1b58dc890b87
parent 8432
074407b4c107
child 8639
71cc2b932ff6
--- a/eric7/EricWidgets/EricSpellCheckedTextEdit.py	Fri Sep 24 16:30:28 2021 +0200
+++ b/eric7/EricWidgets/EricSpellCheckedTextEdit.py	Fri Sep 24 16:34:15 2021 +0200
@@ -324,11 +324,7 @@
             @type QAction
             """
             language = act.data()
-            self.__highlighter.setDict(enchant.Dict(
-                language,
-                SpellCheckMixin.DefaultUserWordList,
-                SpellCheckMixin.DefaultUserExceptionList
-            ))
+            self.setLanguage(language)
         
         @pyqtSlot(QAction)
         def __setFormat(self, act):
@@ -372,6 +368,46 @@
             """
             self.__highlighter.setDict(spellDict)
         
+        @pyqtSlot(str)
+        def setLanguage(self, language):
+            """
+            Public slot to set the spellchecker language.
+            
+            @param language language to be set
+            @type str
+            """
+            epwl = self.dict().pwl
+            pwl = (
+                epwl.provider.file
+                if isinstance(epwl, enchant.Dict) else
+                None
+            )
+            
+            epel = self.dict().pel
+            pel = (
+                epel.provider.file
+                if isinstance(epel, enchant.Dict) else
+                None
+            )
+            self.setLanguageWithPWL(language, pwl, pel)
+        
+        @pyqtSlot(str, str, str)
+        def setLanguageWithPWL(self, language, pwl, pel):
+            """
+            Public slot to set the spellchecker language and associated user
+            word lists.
+            
+            @param language language to be set
+            @type str
+            @param pwl file name of the personal word list
+            @type str
+            @param pel file name of the personal exclude list
+            @type str
+            """
+            self.__highlighter.setDict(
+                enchant.DictWithPWL(language, pwl, pel)
+            )
+        
         @classmethod
         def setDefaultLanguage(cls, language, pwl=None, pel=None):
             """

eric ide

mercurial