Checkbutton: what are the jscallback() arguments?

How would I figure out the arguments of the jscallback function for some panel widgets?
I have a pn.widgets.CheckBox, and want to set some javascript to execute when
the checkbox is set/unset.

All I can figure out is that i need cb.jscallback( args={}, ??? )

got a little further: this triggers

cb = pn.widgets.Checkbox(name="Show Left Bottom Corner")
cb.jscallback(**{"value": "console.log('value changed');"} )

now how do I get at the value in javascript?

Still struggling with this…

cb = pn.widgets.Checkbox(name="Show Left Bottom Corner")

def cb_proc(event):
    Javascript('console.log( "got an event...")')
    print("Checked:",, "value" )

Clicking on the checkbox prints Checked True in the notebook, and

Python callback returned following output: 
	Checked: True

in the console: it does not appear to execute the Javascript.

@philippjfr how do I get the checkbox value in javascript, please?
I just can’t figure it out?

Sorry, missed this. For all jscallbacks there is always a cb_obj in the arguments, which in this case represents the widget model. The Checkbox is actually a reduced case of a checkbox group so it has an active property, which represents the checked items and since there’s only one item active is either empty ([]) or contains a zero-index ([0]).

A callback that reports true or false therefore would look like this:

cb.jscallback(**{"value": "console.log( ? true : false);"} )
1 Like