Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: register callback for saveRoi viewer event #701

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions itkwidgets/_initialization_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def build_config(ui=None):
else:
config = {}
config['maxConcurrency'] = os.cpu_count() * 2
config['showSaveRoiButton'] = True

return config

Expand Down
6 changes: 6 additions & 0 deletions itkwidgets/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -124,6 +127,9 @@ def update_screenshot(self, base64_image):
</script>
''')
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
Expand Down