Version

Quick search

Code Input

New in version 1.5.0.

_images/codeinput.jpg

Note

This widget requires pygments package to run. Install it with pip.

The CodeInput provides a box of editable highlighted text like the one shown in the image.

It supports all the features provided by the textinput as well as code highlighting for languages supported by pygments along with KivyLexer for kivy.lang highlighting.

Usage example

To create a CodeInput with highlighting for KV language:

from kivy.uix.codeinput import CodeInput
from kivy.extras.highlight import KivyLexer
codeinput = CodeInput(lexer=KivyLexer())

To create a CodeInput with highlighting for Cython:

from kivy.uix.codeinput import CodeInput
from pygments.lexers import CythonLexer
codeinput = CodeInput(lexer=CythonLexer())
class kivy.uix.codeinput.CodeInput(**kwargs)

Bases: kivy.uix.behaviors.codenavigation.CodeNavigationBehavior, kivy.uix.textinput.TextInput

CodeInput class, used for displaying highlighted code.