You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I contribute to mne-python(opened issue) and I am working on integration into the Jupyter Notebook environment. The project has tight interactions between ipyevents, ipycanvas, ipyvtklink(opened issue) and ipywidgets, that's why I am not 100% sure it is the right place to open this issue but I will try to explain the unexpected behaviour I observe anyway.
Here is a demo of the final app in mne-python:
output.mp4
The issue
Let's assume an image contained in an HBox called viewer and a VBox called right_dock containing multiple widgets in an Accordion folded by default. Both viewer and right_dock are in turn contained into an HBox called app which is finally displayed:
I would like to get the coordinates of the click in image when the layout is set to image.layout.object_fit = 'contain' (useful to preserve the aspect ratio).
Unfortunately, I think ipyevents is not aware of object_fit because the coordinates that I observe in my experiments are the same as if the image was 'stretched' to fit its container.
output.mp4
Is there a way to obtain the real coordinates of a click on the image in this situation?
Minimum reproducible example
I share below a simplified example (inspired from the demo notebook):
fromipywidgetsimportBox, VBox, HBox, HTML, Image, AccordionfromipyeventsimportEventdefgen_opts(n):
return[HTML(f"option{i}") foriinrange(n)]
withopen('images/gaussian_600_x_300.png', 'rb') asf:
value=f.read()
image=Image(value=value, format='png')
image.layout.object_fit='contain'image.layout.border='5px red solid'right_dock=Accordion([VBox(gen_opts(15))])
right_dock.set_title(0, "Right dock")
right_dock.selected_index=Noneim_events=Event()
im_events.source=imageim_events.watched_events= ['click']
viewer=HBox([image])
red_layout(image)
coordinates=HTML('<h3>Click an image to see the click coordinates here</h3>')
defupdate_coords(event):
coordinates.value='<h3>Clicked at ({}, {})</h3>'.format(event['dataX'], event['dataY'])
im_events.on_dom_event(update_coords)
row=HBox([viewer, right_dock])
app=VBox([row, coordinates])
app
Hello maintainers and contributors of
ipyevents
👋The context
I contribute to
mne-python
(opened issue) and I am working on integration into theJupyter Notebook
environment. The project has tight interactions betweenipyevents
,ipycanvas
,ipyvtklink
(opened issue) andipywidgets
, that's why I am not 100% sure it is the right place to open this issue but I will try to explain the unexpected behaviour I observe anyway.Here is a demo of the final app in
mne-python
:output.mp4
The issue
Let's assume an
image
contained in anHBox
calledviewer
and aVBox
calledright_dock
containing multiple widgets in anAccordion
folded by default. Bothviewer
andright_dock
are in turn contained into anHBox
calledapp
which is finally displayed:I would like to get the coordinates of the click in
image
when the layout is set toimage.layout.object_fit = 'contain'
(useful to preserve the aspect ratio).Unfortunately, I think
ipyevents
is not aware ofobject_fit
because the coordinates that I observe in my experiments are the same as if the image was 'stretched' to fit its container.output.mp4
Is there a way to obtain the real coordinates of a click on the image in this situation?
Minimum reproducible example
I share below a simplified example (inspired from the demo notebook):
cc @larsoner, @banesullivan
The text was updated successfully, but these errors were encountered: