SpellChecker class reference

class gtkspellcheck.spellcheck.SpellChecker(view, language='en', prefix='gtkspellchecker', collapse=True, params={})

Main spellchecking class, everything important happens here.

Parameters:
  • view – GtkTextView the SpellChecker should be attached to.
  • language – the language which should be used for spellchecking. Use a combination of two letter lower-case ISO 639 language code with a two letter upper-case ISO 3166 country code, for example en_US or de_DE.
  • prefix – a prefix for some internal GtkTextMarks.
  • collapse – enclose suggestions in its own menu.
  • params – dictionary with Enchant broker parameters that should be set e.g. enchant.myspell.dictionary.path.
languages

A list of supported languages.

exists(language)

checks if a language exists

Parameters:language – language to check
add_to_dictionary(word)

Adds a word to user’s dictionary.

Parameters:word – the word to add
append_filter(regex, filter_type)

Append a new filter to the filter list. Filters are useful to ignore some misspelled words based on regular expressions.

Parameters:
  • regex – the regex used for filtering
  • filter_type – the type of the filter

Filter Types:

SpellChecker.FILTER_WORD: The regex must match the whole word you want to filter. The word separation is done by Pango’s word separation algorythm so, for example, urls won’t work here because they are split in many words.

SpellChecker.FILTER_LINE: If the expression you want to match is a single line expression use this type. It should not be an open end expression because then the rest of the line with the text you want to filter will become correct.

SpellChecker.FILTER_TEXT: Use this if you want to filter multiline expressions. The regex will be compiled with the MULTILINE flag. Same with open end expressions apply here.

append_ignore_tag(tag)

Appends a tag to the list of ignored tags. A string will be automatic resolved into a tag object.

Parameters:tag – tag object or tag name
buffer_initialize()

Initialize the GtkTextBuffer associated with the GtkTextView. If you associate a new GtkTextBuffer with the GtkTextView call this method.

check_range(start, end, force_all=False)

Checks a specified range between two GtkTextIters.

Parameters:
  • start – start iter - checking starts here
  • end – end iter - checking ends here
disable()

Disable spellchecking.

enable()

Enable spellchecking.

enabled

Enable or disable spellchecking

ignore_all(word)

Ignores a word for the current session.

Parameters:word – the word to ignore
language

The language used for spellchecking

recheck()

Rechecks the spelling of the whole text.

remove_filter(regex, filter_type)

Remove a filter from the filter list.

Parameters:
  • regex – the regex which used for filtering
  • filter_type – the type of the filter
remove_ignore_tag(tag)

Removes a tag from the list of ignored tags. A string will be automatic resolved into a tag object.

Parameters:tag – tag object or tag name