import panel as pn import param pn.extension('codeeditor') py_code = "import sys" editor = pn.widgets.CodeEditor(value=py_code, sizing_mode='stretch_width', language='python', height=300) editor editor.value += """ import Math x = Math.cos(x)**2 + Math.cos(y)**2 """ def print_code(value): print(value) editor = pn.widgets.CodeEditor(value=py_code, on_keyup=False) pn.bind(print_code, editor.param.value) html_code = r""" `substitute(Filename('', 'Page Title'), '^.', '\u&', '')`

Title1

Title2

Paragraph

""" editor.language = "html" editor.theme = "monokai" editor.value = html_code editor.annotations = [ dict(row=1, column=0, text='an error', type='error'), dict(row=2, column=0, text='a warning', type='warning') ] #editor.readonly = True editor.filename = 'test.html' from panel.viewable import Viewer class CodeEditorTest(Viewer): editor = param.String('Hello World') def __panel__(self): """ Map the string to appear as an Ace editor. """ return pn.Param( self.param, widgets=dict( editor=dict( type=pn.widgets.CodeEditor, language='python', ) ) ) edit = CodeEditorTest() edit widget = pn.widgets.CodeEditor(name='CodeEditor', value=py_code, language='python', sizing_mode='stretch_both', min_height=300) pn.Row(widget.controls(jslink=True), widget, sizing_mode='stretch_both')