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'))

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)
run_button = widgets.Button(
    button_style='success', # 'success', 'info', 'warning', 'danger' or ''
    tooltip='Run simulation',
widgets.VBox([run_button, run_output])

where hello.c is simply:

#include <stdio.h> 
#include <unistd.h> 
int main(int argc, char **argv) { 
  int idx; 
  for (idx=0; idx<4; idx++) { printf("argc=%d, %d) hello, 
world...\n",argc,idx); fflush(stdout); sleep(1); } 

You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to