Hi,
I am trying to learn how to make panel useful to me. Note, I do not use jupyter notebooks and am not that familiar with them, all work is done in a .py script. The first question is how do I have “events” in panel get updated by the external browser gui. (An example of what I want to do is below).
The second question is the script only works if the standard name == “main” is commented out when I run bokeh serve myfile.py . Is that by design?
def do_things(event,ar=array):
for element in (ar): if stop_button.value == True: print('Stopped!') stop_button.value = False break #Do some things print('Still running')
#%%
if name == “main”:
css = ‘’’
.panel-widget-box {
background: #f0f0f0;
border-radius: 5px;
border: 1px black solid;
}
‘’’
array = np.linspace(0,100,1000)
pn.extension(raw_css=[css])start_button = pn.widgets.Button(name=‘Start’, margin=(5, 5, 5, 5),button_type=‘primary’)
start_button.on_click(do_things)stop_button = pn.widgets.Toggle(name=‘Stop’, margin=(5, 5, 5, 5),button_type=‘danger’)
col = pn.Column(start_button,stop_button,css_classes=[‘panel-widget-box’])
col.show()