diff --git a/itkwidgets/_initialization_params.py b/itkwidgets/_initialization_params.py index 3ff6272f..99ae4df4 100644 --- a/itkwidgets/_initialization_params.py +++ b/itkwidgets/_initialization_params.py @@ -60,6 +60,7 @@ def build_config(ui=None): else: config = {} config['maxConcurrency'] = os.cpu_count() * 2 + config['showSaveRoiButton'] = True return config diff --git a/itkwidgets/viewer.py b/itkwidgets/viewer.py index 106b3dbe..6c0ad375 100644 --- a/itkwidgets/viewer.py +++ b/itkwidgets/viewer.py @@ -82,6 +82,9 @@ async def run(self, ctx): itk_viewer.registerEventListener( 'screenshotTaken', self.update_screenshot ) + itk_viewer.registerEventListener( + 'saveRoi', self.save_roi + ) # Once the viewer has been created any queued requests can be run CellWatcher().update_viewer_status(self.parent) asyncio.get_running_loop().call_soon_threadsafe(self.viewer_event.set) @@ -124,6 +127,9 @@ def update_screenshot(self, base64_image): ''') self.img.display(html) + + def save_roi(self, roi): + api.log(f'save roi {roi}') def set_event(self, event_data): # Once the data has been set the deferred queue requests can be run