pyqode.python.code_edit

This package contains the python code editor widget

class pyqode.python.code_edit.PyCodeEdit(parent=None)[source]

Bases: pyqode.core.api.code_edit.CodeEdit

Extends CodeEdit with a hardcoded set of modes and panels specifics to a python code editor widget.

It also implements utility methods to switch from a white style to a dark style and inversely.

Note

This code editor widget use PEP 0263 to detect file encoding. If the opened file does not respects the PEP 0263, locale.getpreferredencoding() is used as the default encoding.

setPlainText(txt, mimetype='text/x-python', encoding='utf-8')[source]

Extends QCodeEdit.setPlainText to allow user to setPlainText without mimetype (since the python syntax highlighter does not use it).

use_dark_style(use=True)[source]

Changes the editor style to a dark color scheme similar to pycharm’s darcula color scheme.

use_white_style(use=True)[source]

Changes the editor style to a dark color scheme similar to QtCreator’s default color scheme.

DARK_STYLE = 0
LIGHT_STYLE = 1
pyqode.python.code_edit.set_dark_color_scheme(code_edit)[source]

Set a dark scheme on a pyqode.core.api.CodeEdit.

The color scheme is similar to pycharm’s darcula color scheme.

Note

This function will work only if a pyqode.python.modes.PyHighlighterMode has been installed on the CodeEdit instance

Parameters:code_edit (pyqode.core.api.CodeEdit) – CodeEdit instance
pyqode.python.code_edit.set_white_color_scheme(code_edit)[source]

Set a light scheme on a pyqode.core.api.CodeEdit.

The color scheme is similar to the qt creator’s default color scheme.

Note

This function will work only if a pyqode.python.modes.PyHighlighterMode has been installed on the `code_edit` instance.

Parameters:code_edit (pyqode.core.api.CodeEdit) – CodeEdit instance