I'd like to be able to display output from a program in an Output widget. (And I'd like to be able to kill the program from a widget too). Can someone offer advice?
import ipywidgets as widgets
import subprocess, os
run_output = widgets.Output(layout=widgets.Layout(width='500px', height='100px', border='solid'))
run_output
def run_cb(b):
#global run_output
print('run sim...')
with run_output:
print('trying subprocess - does hello output show up?')
args = ['hello']
run_proc = subprocess.Popen(args)
#os.system('hello')
run_button = widgets.Button(
description='Run',
disabled=False,
button_style='success', # 'success', 'info', 'warning', 'danger' or ''
tooltip='Run simulation',
)
run_button.on_click(run_cb)
run_button
widgets.VBox([run_button, run_output])
for (idx=0; idx<4; idx++) { printf("argc=%d, %d) hello, world...\n",argc,idx); fflush(stdout); sleep(1); }