panel.widgets.codeeditor module#
Defines the CodeEditor widget based on Ace.
- class panel.widgets.codeeditor.CodeEditor(*, annotations, filename, language, on_keyup, print_margin, readonly, theme, value_input, disabled, loading, align, aspect_ratio, css_classes, design, height, height_policy, margin, max_height, max_width, min_height, min_width, sizing_mode, styles, stylesheets, tags, visible, width, width_policy, value, name)[source]#
Bases:
Widget
The CodeEditor widget allows displaying and editing code in the powerful Ace editor.
Reference: https://panel.holoviz.org/reference/widgets/CodeEditor.html
- Example:
>>> CodeEditor(value=py_code, language='python', theme='monokai')
Parameter Definitions
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.widgets.base.Widget
: height, margin, width, disabledvalue = String(default='', label='Value')
State of the current code in the editor if on_keyup. Otherwise, only upon loss of focus, i.e. clicking outside the editor, or pressing <Ctrl+Enter> or <Cmd+Enter>.
annotations = List(bounds=(0, None), default=[], label='Annotations')
List of annotations to add to the editor.
filename = String(default='', label='Filename')
Filename from which to deduce language
language = String(default='text', label='Language')
Language of the editor
on_keyup = Boolean(default=True, label='On keyup')
Whether to update the value on every key press or only upon loss of focus / hotkeys.
print_margin = Boolean(default=False, label='Print margin')
Whether to show the a print margin.
readonly = Boolean(default=False, label='Readonly')
Define if editor content can be modified. Alias for disabled.
theme = Selector(default='chrome', label='Theme', names={}, objects=['ambiance', 'chaos', 'chrome', 'clouds', 'clouds_midnight', 'cobalt', 'crimson_editor', 'dawn', 'dracula', 'dreamweaver', 'eclipse', 'github', 'gob', 'gruvbox', 'idle_fingers', 'iplastic', 'katzenmilch', 'kr_theme', 'kuroir', 'merbivore', 'merbivore_soft', 'mono_industrial', 'monokai', 'pastel_on_dark', 'solarized_dark', 'solarized_light', 'sqlserver', 'terminal', 'textmate', 'tomorrow', 'tomorrow_night', 'tomorrow_night_blue', 'tomorrow_night_bright', 'tomorrow_night_eighties', 'twilight', 'vibrant_ink', 'xcode'])
If no value is provided, it defaults to the current theme set by pn.config.theme, as specified in the CodeEditor.THEME_CONFIGURATION dictionary. If not defined there, it falls back to the default parameter value.
value_input = String(default='', label='Value input')
State of the current code updated on every key press. Identical to value if on_keyup.