Skip to content

Commit

Permalink
Let default generated .py instrument contain an active "interface"
Browse files Browse the repository at this point in the history
  • Loading branch information
willend committed Feb 10, 2024
1 parent d5bff0c commit 957a288
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions mcstas/src/pygen.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -994,11 +994,12 @@ cogen(char *output_name, struct instr_def *instr)
cout("#import mcstasscript.jb_interface as ms_widget");
cout("#ms_widget.show(data)");
cout("\n\n# Bring up the simulation 'interface' - only relevant in Jupyter");
cout("#%matplotlib widget");
cout("#import mcstasscript.jb_interface as ms_widget");
cout("#sim_widget = ms_widget.SimInterface(instr)");
cout("#sim_widget.show_interface()");
cout("#data = sim_widget.get_data()");
cout("%matplotlib widget");
cout("import mcstasscript.jb_interface as ms_widget");
cout("sim_widget = ms_widget.SimInterface(instr)");
cout("sim_widget.show_interface()");
cout("\n\n# Acessing data from the interface");
cout("data = sim_widget.get_data()");
coutf("\n\n# end of generated Python code %s ", output_name);

fclose(output_handle);
Expand Down
11 changes: 6 additions & 5 deletions mcxtrace/src/pygen.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -937,11 +937,12 @@ cogen(char *output_name, struct instr_def *instr)
cout("#import mcstasscript.jb_interface as ms_widget");
cout("#ms_widget.show(data)");
cout("\n\n# Bring up the simulation 'interface' - only relevant in Jupyter");
cout("#%matplotlib widget");
cout("#import mcstasscript.jb_interface as ms_widget");
cout("#sim_widget = ms_widget.SimInterface(instr)");
cout("#sim_widget.show_interface()");
cout("#data = sim_widget.get_data()");
cout("%matplotlib widget");
cout("import mcstasscript.jb_interface as ms_widget");
cout("sim_widget = ms_widget.SimInterface(instr)");
cout("sim_widget.show_interface()");
cout("\n\n# Acessing data from the interface");
cout("data = sim_widget.get_data()");
coutf("\n\n# end of generated Python code %s ", output_name);

fclose(output_handle);
Expand Down

0 comments on commit 957a288

Please sign in to comment.