lib.spelltextedit.*

Provides

class lib.spelltextedit.LineNumberArea(parent)[source]

Bases: PyQt5.QtWidgets.QWidget

Parameters

parent (QPlainTextEdit) – Editor in which the line numbers shall be displayed

paintEvent(event)[source]

Paint event called by parent

sizeHint(self) QSize[source]
class lib.spelltextedit.PythonEnchantHighlighter(*args)[source]

Bases: PyQt5.QtGui.QSyntaxHighlighter

QSyntaxHighlighter subclass which consults a PyEnchant dictionary

braces = ['\\{', '\\}', '\\(', '\\)', '\\[', '\\]']
chunkers()[source]

Gets the chunkers in use

dict()[source]

Gets the spelling dictionary in use

enable_enchant = False
err_format = <PyQt5.QtGui.QTextCharFormat object>
highlightBlock(text)[source]

Overridden QSyntaxHighlighter method to apply the highlight

highlightBlock_enchant(text)[source]

Method for pyenchant spell checker

highlightBlock_python(text)[source]

Method for Python highlighter

keywords = ['and', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'yield', 'None', 'True', 'False']
match_multiline(text, delimiter, in_state, style)[source]

Do highlighting of multi-line strings. delimiter should be a QRegExp for triple-single-quotes or triple-double-quotes, and in_state should be a unique integer to represent the corresponding state changes when inside those strings. Returns True if we’re still inside a multi-line string when this function is finished.

operators = ['=', '==', '!=', '<', '<=', '>', '>=', '\\+', '-', '\\*', '/', '//', '\\%', '\\*\\*', '\\+=', '-=', '\\*=', '/=', '\\%=', '\\^', '\\|', '\\&', '\\~', '>>', '<<']
setChunkers(chunkers)[source]

Sets the list of chunkers to be used

setDict(sp_dict)[source]

Sets the spelling dictionary to be used

class lib.spelltextedit.SpellTextEdit(parent=None, line_numbers=True)[source]

Bases: PyQt5.QtWidgets.QPlainTextEdit

QPlainTextEdit subclass which does spell-checking using PyEnchant

cb_correct_word(action)[source]

Event handler for ‘Spelling Suggestions’ entries.

cb_set_format(action)[source]

Event handler for ‘Language’ menu entries.

cb_set_language(action)[source]

Event handler for ‘Language’ menu entries.

contextMenuEvent(event)[source]

Custom context menu handler to add a spelling suggestions submenu

createCorrectionsMenu(cursor, parent=None)[source]

Create and return a menu for correcting the selected word.

createFormatsMenu(parent=None)[source]

Create and return a menu for selecting the spell-check language.

createLanguagesMenu(parent=None)[source]

Create and return a menu for selecting the spell-check language.

createSpellcheckContextMenu(pos)[source]

Create and return an augmented default context menu.

This may be used as an alternative to the QPoint-taking form of createStandardContextMenu and will work on pre-5.5 Qt.

cursorForMisspelling(pos)[source]

Return a cursor selecting the misspelled word at pos or None

This leverages the fact that QPlainTextEdit already has a system for processing its contents in limited-size blocks to keep things fast.

get_line_number_area_width()[source]

Returns width of line number area

Return type

int

keyPressEvent(event)[source]

Overide to change tab into spaces_per_tab spaces

max_suggestions = 20
resizeEvent(event)[source]

Overides QPlainTextEdit.resizeEvent for handling line_number_area

show_line_numbers(visible)[source]

Show line number area if visible else hide it

Parameters

visible (bool) – Line number area visibility

spaces_per_tab = 4
update_line_number_area(rect, dy)[source]

Handle updates for line_number_area

update_line_number_area_width()[source]

Updates width of line_number_area

lib.spelltextedit.format(color, style='')[source]

Return a QTextCharFormat with the given attributes.

lib.spelltextedit.trim_suggestions(word, suggs, maxlen, calcdist=None)[source]

API Polyfill for earlier versions of PyEnchant.