Making a Jupyter Lab widget for before/after image sliders also available in vscode-jupyter #9955
-
I wrote a fully functional jupyter-splitview widget for Jupyter Lab, and I'd love to make it available in VS Code Notebooks as well. from IPython.core.display import HTML
from IPython.display import display
html_code = f"""
<div class="outer_layer" style="position: relative; padding-top: 300px;">
<div class="juxtapose" data-startingposition="35%" style="height: 400px; width: 400px; top: 1%; left: 1%; position: absolute;">
<img src="https://raw.githubusercontent.com/scikit-image/scikit-image/main/skimage/data/chelsea.png" />' <img src="https://raw.githubusercontent.com/scikit-image/scikit-image/main/skimage/data/coins.png" />'
</div>
</div>
"""
display(HTML(html_code)) As soon as I add the third party JavaScript code for the split view slider, it does only work in Jupyter Lab, however VS Code does not show the slider: from IPython.core.display import HTML
from IPython.display import display
html_code = f"""
<div class="outer_layer" style="position: relative; padding-top: 300px;">
<div class="juxtapose" data-startingposition="35%" style="height: 400px; width: 400px; top: 1%; left: 1%; position: absolute;">
<img src="https://raw.githubusercontent.com/scikit-image/scikit-image/main/skimage/data/chelsea.png" />' <img src="https://raw.githubusercontent.com/scikit-image/scikit-image/main/skimage/data/coins.png" />'
</div>
</div>
<script src="https://cdn.knightlab.com/libs/juxtapose/latest/js/juxtapose.min.js"></script>
<link rel="stylesheet" href="https://cdn.knightlab.com/libs/juxtapose/latest/css/juxtapose.css" />
"""
display(HTML(html_code)) Any ideas how I can make this work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@kolibril13 Looks like the code in |
Beta Was this translation helpful? Give feedback.
@kolibril13
Thanks for trying to get this working in VS Code as well. I've tried to run this code sample and found some errors in the console window, see below
Looks like the code in
setWrapperDimensions
is falling over. I believe once you fix that, things should work as expected.