PySDM_examples.utils.kinematic_2d.gui
1import os 2import sys 3 4from open_atmos_jupyter_utils import TemporaryFile 5from PySDM_examples.utils.kinematic_2d.gui_controller import ( 6 GUIController, 7) 8from PySDM_examples.utils.kinematic_2d.gui_viewer import GUIViewer 9from PySDM_examples.utils.widgets import HTML, Tab, VBox, display 10 11from PySDM.exporters import NetCDFExporter 12 13 14def launch(settings, simulation, storage): 15 ncdf_file = TemporaryFile(".nc") 16 ncdf_exporter = NetCDFExporter( 17 storage, settings, simulation, ncdf_file.absolute_path 18 ) 19 20 vtk_file = TemporaryFile(".zip") 21 22 viewer = GUIViewer(storage, settings) 23 controller = GUIController(simulation, viewer, ncdf_exporter, ncdf_file, vtk_file) 24 25 controller_box = controller.box() 26 27 tabs = Tab([VBox([controller_box, viewer.box()]), settings.box()]) 28 tabs.set_title(1, "Settings") 29 tabs.set_title(0, "Simulation") 30 tabs.observe(controller.reinit, "selected_index") 31 32 # https://github.com/googlecolab/colabtools/issues/1302 33 hack = ( 34 "<link" 35 ' rel="stylesheet"' 36 ' href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"' 37 "> " 38 ) 39 if "google.colab" in sys.modules: 40 display(HTML(hack)) 41 42 display(tabs) 43 44 if "CI" in os.environ: 45 controller_box.children[1].click()
def
launch(settings, simulation, storage):
15def launch(settings, simulation, storage): 16 ncdf_file = TemporaryFile(".nc") 17 ncdf_exporter = NetCDFExporter( 18 storage, settings, simulation, ncdf_file.absolute_path 19 ) 20 21 vtk_file = TemporaryFile(".zip") 22 23 viewer = GUIViewer(storage, settings) 24 controller = GUIController(simulation, viewer, ncdf_exporter, ncdf_file, vtk_file) 25 26 controller_box = controller.box() 27 28 tabs = Tab([VBox([controller_box, viewer.box()]), settings.box()]) 29 tabs.set_title(1, "Settings") 30 tabs.set_title(0, "Simulation") 31 tabs.observe(controller.reinit, "selected_index") 32 33 # https://github.com/googlecolab/colabtools/issues/1302 34 hack = ( 35 "<link" 36 ' rel="stylesheet"' 37 ' href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"' 38 "> " 39 ) 40 if "google.colab" in sys.modules: 41 display(HTML(hack)) 42 43 display(tabs) 44 45 if "CI" in os.environ: 46 controller_box.children[1].click()