<jupyter_start><jupyter_text>Use ParamNB to create a Widget Obj from a Param Obj; Sync behavior: Widget UI  Widget Obj ---> Param Obj;<jupyter_code>import numpy as np
import param 
import paramnb
# Param Class
class SineWave(param.Parameterized):
    
    offset = param.Number(default=0.0, bounds=(-5.0,5.0))
    amplitude = param.Number(default=1.0, bounds=(-5.0,5.0))
    phase = param.Number(default=0.0,bounds=(0.0,2*np.pi))
    frequency = param.Number(default=1.0, bounds=(0.1, 5.1))
    N = param.Integer(default=200, bounds=(0,None))

# Param Obj
mysine = SineWave()
# Create and display a ParamWidget from Param Obj
# This way can't explicitly get a var references Widget Obj/Instance
paramnb.Widgets(mysine)
# Change UI and check Param Obj (Widget UI ---> Param Obj)
mysine
# Change Param Obj and check UI (Param Obj X--> UI)
mysine.N=99<jupyter_output><empty_output><jupyter_text>A special way to get a Widget Obj var explicitly to reveal Widget UI  Widget Obj ---> Param Obj<jupyter_code># Create an empty paramnb Widget obj/instance
widget_obj2 = paramnb.Widgets.instance()
# Create a param Obj
mysine2 = SineWave()
def UI_callback(*args, **kwargs):    
    print ("UI changed")
    print (args, kwargs)
    print ("Widget Obj Value: {}".format(widget_obj2._widgets["N"].value))
    print ("Param Obj Value {}".format(mysine2.N))
    
# Pass a param Obj to paramNB Widget Obj (paramNB Widget Obj is callable)
widget_obj2(mysine2, callback=UI_callback)
# change UI, check widget obj and param Obj (UI  <----> Widget Obj ----> ParamObj)
print(type(widget_obj2._widgets["N"]))
print(widget_obj2._widgets["N"].value)
print(widget_obj2.parameterized.N)
print(mysine2.N)  # same param obj as widget_obj2.parameterized
# Change Param Obj, check Widget Obj and UI  (UI  <----> Widget Obj ----> ParamObj)
widget_obj2.parameterized.N = 11
print (mysine2.N) # same as above widget_obj2.parameterized
print (widget_obj2._widgets["N"].value)
# Change Widget Obj, check UI and param Obj (UI  <----> Widget Obj ----> ParamObj)
widget_obj2._widgets["N"].value = 3
print (mysine2.N)
print(widget_obj2.parameterized.N)<jupyter_output>UI changed
(SineWave(N=3, amplitude=1.0, frequency=1.0, name='SineWave00005', offset=0.0, phase=0.0),) {'N': 3}
Widget Obj Value: 3
Param Obj Value 3
3
3
{'fraction_non_alphanumeric': 0.1357862461673237, 'fraction_numerical': 0.030223390275952694, 'mean_word_length': 4.530266343825666, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '616934', 'license': 'MIT', 'n_tokens_mistral': 831, 'n_tokens_neox': 828, 'n_words': 234, 'path': 'reviews/Jupyter_Widgets/param/paramNB_one_way_Widget_UI_to_paramObj.ipynb', 'repo_name': 'Aquaveo/jupyter_to_tethys', 'size': '2283'}