# eric7.EricWidgets.EricSpellCheckedTextEdit

Module implementing QTextEdit and QPlainTextEdit widgets with embedded spell checking.

### Global Attributes

None

### Classes

EnchantHighlighter | Class implementing a QSyntaxHighlighter subclass that consults a pyEnchant dictionary to highlight misspelled words.
EricSpellCheckedPlainTextEdit | Class implementing a QPlainTextEdit with built-in spell checker.
EricSpellCheckedTextEdit | Class implementing a QTextEdit with built-in spell checker.
SpellCheckMixin | Class implementing the spell-check mixin for the widget classes.
SpellCheckMixin | Class implementing the spell-check mixin for the widget classes.

### Functions

None

## EnchantHighlighter

Class implementing a QSyntaxHighlighter subclass that consults a pyEnchant dictionary to highlight misspelled words.

### Derived from

QSyntaxHighlighter

### Class Attributes

ErrorFormat
TokenFilters

### Class Methods

None

### Methods

EnchantHighlighter | Constructor
chunkers | Public method to get the chunkers in use.
dict | Public method to get the spelling dictionary in use.
highlightBlock | Public method to apply the text highlight.
setChunkers | Public method to set the chunkers to be used.
setDict | Public method to set the spelling dictionary to be used.

### Static Methods

None

#### EnchantHighlighter (Constructor)

EnchantHighlighter(*args, **kwargs)

Constructor

*args (list)
  list of arguments for the QSyntaxHighlighter
**kwargs= (dict)
  dictionary of keyword arguments for the QSyntaxHighlighter

#### EnchantHighlighter.chunkers

chunkers()

Public method to get the chunkers in use.

Return:
  list of chunkers in use

Return Type:
  list

#### EnchantHighlighter.dict

dict()

Public method to get the spelling dictionary in use.

Return:
  spelling dictionary

Return Type:
  enchant.Dict

#### EnchantHighlighter.highlightBlock

highlightBlock(text)

Public method to apply the text highlight.

text (str)
  text to be spell-checked

#### EnchantHighlighter.setChunkers

setChunkers(chunkers)

Public method to set the chunkers to be used.

chunkers (list)
  chunkers to be used

#### EnchantHighlighter.setDict

setDict(spellDict)

Public method to set the spelling dictionary to be used.

spellDict (enchant.Dict)
  spelling dictionary

Up

## EricSpellCheckedPlainTextEdit

Class implementing a QPlainTextEdit with built-in spell checker.

### Derived from

QPlainTextEdit, SpellCheckMixin

### Class Attributes

None

### Class Methods

None

### Methods

EricSpellCheckedPlainTextEdit | Constructor

### Static Methods

None

#### EricSpellCheckedPlainTextEdit (Constructor)

EricSpellCheckedPlainTextEdit(*args, **kwargs)

Constructor

*args (list)
  list of arguments for the QPlainTextEdit constructor.
**kwargs= (dict)
  dictionary of keyword arguments for the QSyntaxHighlighter

Up

## EricSpellCheckedTextEdit

Class implementing a QTextEdit with built-in spell checker.

### Derived from

QTextEdit, SpellCheckMixin

### Class Attributes

None

### Class Methods

None

### Methods

EricSpellCheckedTextEdit | Constructor
setAcceptRichText | Public method to set the text edit mode.

### Static Methods

None

#### EricSpellCheckedTextEdit (Constructor)

EricSpellCheckedTextEdit(*args, **kwargs)

Constructor

*args (list)
  list of arguments for the QPlainTextEdit constructor.
**kwargs= (dict)
  dictionary of keyword arguments for the QSyntaxHighlighter

#### EricSpellCheckedTextEdit.setAcceptRichText

setAcceptRichText(accept)

Public method to set the text edit mode.

accept (bool)
  flag indicating to accept rich text

Up

## SpellCheckMixin

Class implementing the spell-check mixin for the widget classes.

### Derived from

None

### Class Attributes

DefaultLanguage
DefaultUserExceptionList
DefaultUserWordList
MaxSuggestions

### Class Methods

setDefaultLanguage | Class method to set the default spell-check language.

### Methods

SpellCheckMixin | Constructor
__addRemoveEntry | Private method to create a menu entry to remove the word at the menu position.
__addToUserDict | Private method to add a word to the user word or exclude list.
__correctWord | Private method to replace some misspelled text.
__createCorrectionsMenu | Private method to create a menu for corrections of the selected word.
__createFormatsMenu | Private method to create a menu for selecting the document format.
__createLanguagesMenu | Private method to create a menu for selecting the spell-check language.
__createSpellcheckContextMenu | Private method to create the spell-check context menu.
__cursorForMisspelling | Private method to create a text cursor selecting the misspelled word.
__cursorForPosition | Private method to create a text cursor selecting the word at the given position.
__setFormat | Private slot to set the selected document format.
__setLanguage | Private slot to set the selected language.
__spellMenuTriggered | Private slot to handle a selection of the spell menu.
_showContextMenu | Protected slot to show a context menu.
dict | Public method to get a reference to the dictionary in use.
setDict | Public method to set the dictionary to be used.
setFormat | Public method to set the document format.
setLanguage | Public slot to set the spellchecker language.
setLanguageWithPWL | Public slot to set the spellchecker language and associated user word lists.

### Static Methods

None

#### SpellCheckMixin.setDefaultLanguage (class method)

setDefaultLanguage(language, pwl=None, pel=None)

Class method to set the default spell-check language.

language (str)
  language to be set as default
pwl (str)
  file name of the personal word list
pel (str)
  file name of the personal exclude list

#### SpellCheckMixin (Constructor)

SpellCheckMixin()

Constructor

#### SpellCheckMixin.__addRemoveEntry

__addRemoveEntry(cursor, menu)

Private method to create a menu entry to remove the word at the menu position.

cursor (QTextCursor)
  reference to the text cursor for the misspelled word
menu (QMenu)
  reference to the context menu

#### SpellCheckMixin.__addToUserDict

__addToUserDict(word, command)

Private method to add a word to the user word or exclude list.

word (str)
  text to be added
command (str)
  command indicating the user dictionary type

#### SpellCheckMixin.__correctWord

__correctWord(cursor, word)

Private method to replace some misspelled text.

cursor (QTextCursor)
  reference to the text cursor for the misspelled word
word (str)
  replacement text

#### SpellCheckMixin.__createCorrectionsMenu

__createCorrectionsMenu(cursor, parent=None)

Private method to create a menu for corrections of the selected word.

cursor (QTextCursor)
  reference to the text cursor
parent (QWidget (optional))
  reference to the parent widget (defaults to None)

Return:
  menu with corrections

Return Type:
  QMenu

#### SpellCheckMixin.__createFormatsMenu

__createFormatsMenu(parent=None)

Private method to create a menu for selecting the document format.

parent (QWidget (optional))
  reference to the parent widget (defaults to None)

Return:
  menu with document formats

Return Type:
  QMenu

#### SpellCheckMixin.__createLanguagesMenu

__createLanguagesMenu(parent=None)

Private method to create a menu for selecting the spell-check language.

parent (QWidget (optional))
  reference to the parent widget (defaults to None)

Return:
  menu with spell-check languages

Return Type:
  QMenu

#### SpellCheckMixin.__createSpellcheckContextMenu

__createSpellcheckContextMenu(pos)

Private method to create the spell-check context menu.

pos (QPoint)
  position of the mouse pointer

Return:
  context menu with additional spell-check entries

Return Type:
  QMenu

#### SpellCheckMixin.__cursorForMisspelling

__cursorForMisspelling(pos)

Private method to create a text cursor selecting the misspelled word.

pos (QPoint)
  position of the misspelled word

Return:
  text cursor for the misspelled word

Return Type:
  QTextCursor

#### SpellCheckMixin.__cursorForPosition

__cursorForPosition(pos)

Private method to create a text cursor selecting the word at the given position.

pos (QPoint)
  position of the misspelled word

Return:
  text cursor for the word

Return Type:
  QTextCursor

#### SpellCheckMixin.__setFormat

__setFormat(act)

Private slot to set the selected document format.

act (QAction)
  reference to the selected action

#### SpellCheckMixin.__setLanguage

__setLanguage(act)

Private slot to set the selected language.

act (QAction)
  reference to the selected action

#### SpellCheckMixin.__spellMenuTriggered

__spellMenuTriggered(act)

Private slot to handle a selection of the spell menu.

act (QAction)
  reference to the selected action

#### SpellCheckMixin._showContextMenu

_showContextMenu(pos)

Protected slot to show a context menu.

pos (QPoint)
  position for the context menu

#### SpellCheckMixin.dict

dict()

Public method to get a reference to the dictionary in use.

Return:
  reference to the current dictionary

Return Type:
  enchant.Dict

#### SpellCheckMixin.setDict

setDict(spellDict)

Public method to set the dictionary to be used.

spellDict (emchant.Dict)
  reference to the spell-check dictionary

#### SpellCheckMixin.setFormat

setFormat(formatName)

Public method to set the document format.

formatName (str)
  name of the document format

#### SpellCheckMixin.setLanguage

setLanguage(language)

Public slot to set the spellchecker language.

language (str)
  language to be set

#### SpellCheckMixin.setLanguageWithPWL

setLanguageWithPWL(language, pwl, pel)

Public slot to set the spellchecker language and associated user word lists.

language (str)
  language to be set
pwl (str)
  file name of the personal word list
pel (str)
  file name of the personal exclude list

Up

## SpellCheckMixin

Class implementing the spell-check mixin for the widget classes.

### Derived from

None

### Class Attributes

None

### Class Methods

setDefaultLanguage | Class method to set the default spell-check language.

### Methods

SpellCheckMixin | Constructor
_showContextMenu | Protected slot to show a context menu.
dict | Public method to get a reference to the dictionary in use.
setDict | Public method to set the dictionary to be used.
setFormat | Public method to set the document format.
setLanguage | Public slot to set the spellchecker language.
setLanguageWithPWL | Public slot to set the spellchecker language and associated user word lists.

### Static Methods

None

#### SpellCheckMixin.setDefaultLanguage (class method)

setDefaultLanguage(language, pwl=None, pel=None)

Class method to set the default spell-check language.

language (str)
  language to be set as default
pwl (str)
  file name of the personal word list
pel (str)
  file name of the personal exclude list

#### SpellCheckMixin (Constructor)

SpellCheckMixin()

Constructor

#### SpellCheckMixin._showContextMenu

_showContextMenu(pos)

Protected slot to show a context menu.

pos (QPoint)
  position for the context menu

#### SpellCheckMixin.dict

dict()

Public method to get a reference to the dictionary in use.

Return:
  reference to the current dictionary

Return Type:
  enchant.Dict

#### SpellCheckMixin.setDict

setDict(spellDict)

Public method to set the dictionary to be used.

spellDict (emchant.Dict)
  reference to the spell-check dictionary

#### SpellCheckMixin.setFormat

setFormat(formatName)

Public method to set the document format.

formatName (str)
  name of the document format

#### SpellCheckMixin.setLanguage

setLanguage(language)

Public slot to set the spellchecker language.

language (str)
  language to be set

#### SpellCheckMixin.setLanguageWithPWL

setLanguageWithPWL(language, pwl, pel)

Public slot to set the spellchecker language and associated user word lists.

language (str)
  language to be set
pwl (str)
  file name of the personal word list
pel (str)
  file name of the personal exclude list

Up