/QCodeEditor

Light QPlainTextEdit based widget which provides the line numbers bar and the syntax and the current line highlight (PyQt)

Primary LanguagePythonMIT LicenseMIT

QCodeEditor widget (PyQt)

Overview

QCodeEditor is a light code editor widget based on QPlainTextEdit and provides the following features:

  • line numbers bar - set by DISPLAY_LINE_NUMBERS flag equals True
  • curent line highligthing - set by HIGHLIGHT_CURRENT_LINE flag equals True
  • syntax highlighting - setting up a QSyntaxHighlighter. As an example XML syntax highlighter was used.

Widget is compatible with Python 2.7 or Python 3.3+ and PyQt4 4.6+ or PyQt5 5.2+.


./demo.gif

API

class QCodeEditor(QPlainTextEdit):

    def __init__(self, DISPLAY_LINE_NUMBERS=True, HIGHLIGHT_CURRENT_LINE=True,
                 SyntaxHighlighter=None, *args):
        '''
        Parameters
        ----------
        DISPLAY_LINE_NUMBERS : bool
            defines the presence of the lines number bar
        HIGHLIGHT_CURRENT_LINE : bool
            switch on/off the current line highliting
        SyntaxHighlighter : QSyntaxHighlighter
            should be inherited from QSyntaxHighlighter
        '''

References: