Panel | Tutorial 9 Linking(Unfinished)

2023/02/19 11:38 AM posted in  Coding Notes   comments
Tags:  #Panel

  • obj.link: convenient high-level API to link objects via Python calls
  • obj.param.watch: powerful but lower-level Python API provided by param
  • obj.jslink: high-level API to link objects via JS code
  • obj.jscallback: a lower-level API to define arbitrary Javascript callbacks

Python Link Using Link Method

markdown = pn.pane.Markdown("Some text")
text_input = pn.widgets.TextInput(value=markdown.object)

text_input.link(markdown, value='object')

pn.Row(text_input, markdown)

Link + Callback

m = pn.pane.Markdown("")
t = pn.widgets.TextInput()

def callback(target, event):
    target.object = event.new.upper() + '!!!'

t.link(m, callbacks={'value': callback})
t.value="Some text"

pn.Row(t, m)