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

Make this work on Jupyter Lab #33

Open
rachelstephlee opened this issue Mar 6, 2018 · 22 comments · May be fixed by #38 or #49
Open

Make this work on Jupyter Lab #33

rachelstephlee opened this issue Mar 6, 2018 · 22 comments · May be fixed by #38 or #49

Comments

@rachelstephlee
Copy link

I really love this magic command, but it only works on Jupyter notebook and not jupyter lab for some reason.

I was hoping that you could extend this magic command so that it also works for jupyter lab.

Thank you!

@mdagost
Copy link
Contributor

mdagost commented Mar 8, 2018

Hey @rachlee93 ! I was thinking the same thing last week. It doesn't work in JupyterLab out of the box because they disabled Javascript display, which we use. I've pinged them to see if there is a workaround to get it working. I'll leave this issue open until I learn more.

@gorogm
Copy link

gorogm commented Jun 18, 2018

Hi @mdagost , could you solve somehow? Thanks.

@ajing
Copy link

ajing commented Jul 19, 2018

Any progress?

@mdagost
Copy link
Contributor

mdagost commented Jul 19, 2018

Unfortunately no. It's a big change (developing for jupyterlab). I'd be happy to look at and help with PR's, but we won't be able to get to this for awhile...

@markusschanta
Copy link

Hi all (@mdagost, @diffractometer, @mr-david)!

This is a great extension. I just added it to awesome-jupyter.

Agree with @rachlee93 and the other people who gave this issue a thumbs-up: It would be great if this would work for JupyterLab as well. If anyone here comes across a solution that does, please add it to the list.

@balmasi
Copy link

balmasi commented Apr 4, 2019

it works if you inject jquery into the page

@ajing
Copy link

ajing commented Apr 4, 2019

How to inject jquery into the page?

@BlazJurisic
Copy link

@ajing
open the console inside browser and paste

var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);

// ... give time for script to load, then type (or see below for non wait option)
jQuery.noConflict();

It silences the error, but I still miss notifications.

@ajing
Copy link

ajing commented Apr 24, 2019

@BlazJurisic OK, nice. I also don't see the notification..

@cphyc
Copy link

cphyc commented May 1, 2019

@BlazJurisic this also works for me!
However I had to skip the jQuery.noConflict() part, otherwise jupyter-notify can't find the symbol $ (jQuery's object).

I did exactly this:

# Cell 1
%%javascript
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
# Cell 2
%load_ext jupyternotify

@cphyc cphyc linked a pull request May 1, 2019 that will close this issue
@BlazJurisic
Copy link

@cphyc, I haven't had success in presenting notification with the code above

@cphyc
Copy link

cphyc commented May 1, 2019

@BlazJurisic did you try with #38?

@BlazJurisic
Copy link

Yes, still not getting notifications

@gary159
Copy link

gary159 commented Jun 26, 2019

@cphyc works for me. Thanks

@diffractometer
Copy link

👍

@bojiang
Copy link

bojiang commented Sep 23, 2019

Yes, still not getting notifications

If you are using Chrome and your jupyter lab is not under HTTPS, the Chrome just block all the notifications.

@StefanBrand
Copy link

You can simply call Javascript to trigger a new notification at the end of the cell:

Simple version

This is without body and icon:

from IPython.display import Javascript
Javascript("new Notification('Cell Execution Has Finished')")

Advanced version

With title/body and JupyterLab icon:

from IPython.display import Javascript
Javascript("new Notification('JupyterLab', {body: 'Cell Execution Has Finished!', icon: \"data:image/svg+xml,%3Csvg width='39' height='51' viewBox='0 0 39 51' version='2.0' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:figma='http://www.figma.com/figma/ns'%3E %3Ctitle%3Elogo-5.svg%3C/title%3E %3Cdesc%3ECreated using Figma 0.90%3C/desc%3E %3Cg id='Canvas' transform='translate(-1638 -2281)' figma:type='canvas'%3E %3Cg id='logo' style='mix-blend-mode:normal;' figma:type='group'%3E %3Cg id='g' style='mix-blend-mode:normal;' figma:type='group'%3E %3Cg id='path' style='mix-blend-mode:normal;' figma:type='group'%3E %3Cg id='path7 fill' style='mix-blend-mode:normal;' figma:type='vector'%3E %3Cuse xlink:href='%23path0_fill' transform='translate(1669.3 2281.31)' fill='%23767677' style='mix-blend-mode:normal;'/%3E %3C/g%3E %3C/g%3E %3Cg id='path' style='mix-blend-mode:normal;' figma:type='group'%3E %3Cg id='path8 fill' style='mix-blend-mode:normal;' figma:type='vector'%3E %3Cuse xlink:href='%23path1_fill' transform='translate(1639.74 2311.98)' fill='%23F37726' style='mix-blend-mode:normal;'/%3E %3C/g%3E %3C/g%3E %3Cg id='path' style='mix-blend-mode:normal;' figma:type='group'%3E %3Cg id='path9 fill' style='mix-blend-mode:normal;' figma:type='vector'%3E %3Cuse xlink:href='%23path2_fill' transform='translate(1639.73 2285.48)' fill='%23F37726' style='mix-blend-mode:normal;'/%3E %3C/g%3E %3C/g%3E %3Cg id='path' style='mix-blend-mode:normal;' figma:type='group'%3E %3Cg id='path10 fill' style='mix-blend-mode:normal;' figma:type='vector'%3E %3Cuse xlink:href='%23path3_fill' transform='translate(1639.8 2323.81)' fill='%23989798' style='mix-blend-mode:normal;'/%3E %3C/g%3E %3C/g%3E %3Cg id='path' style='mix-blend-mode:normal;' figma:type='group'%3E %3Cg id='path11 fill' style='mix-blend-mode:normal;' figma:type='vector'%3E %3Cuse xlink:href='%23path4_fill' transform='translate(1638.36 2286.06)' fill='%236F7070' style='mix-blend-mode:normal;'/%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/g%3E %3C/g%3E %3Cdefs%3E %3Cpath id='path0_fill' d='M 5.89353 2.844C 5.91889 3.43165 5.77085 4.01367 5.46815 4.51645C 5.16545 5.01922 4.72168 5.42015 4.19299 5.66851C 3.6643 5.91688 3.07444 6.00151 2.49805 5.91171C 1.92166 5.8219 1.38463 5.5617 0.954898 5.16401C 0.52517 4.76633 0.222056 4.24903 0.0839037 3.67757C -0.0542483 3.10611 -0.02123 2.50617 0.178781 1.95364C 0.378793 1.4011 0.736809 0.920817 1.20754 0.573538C 1.67826 0.226259 2.24055 0.0275919 2.82326 0.00267229C 3.60389 -0.0307115 4.36573 0.249789 4.94142 0.782551C 5.51711 1.31531 5.85956 2.05676 5.89353 2.844Z'/%3E %3Cpath id='path1_fill' d='M 18.2646 7.13411C 10.4145 7.13411 3.55872 4.2576 0 0C 1.32539 3.8204 3.79556 7.13081 7.0686 9.47303C 10.3417 11.8152 14.2557 13.0734 18.269 13.0734C 22.2823 13.0734 26.1963 11.8152 29.4694 9.47303C 32.7424 7.13081 35.2126 3.8204 36.538 0C 32.9705 4.2576 26.1148 7.13411 18.2646 7.13411Z'/%3E %3Cpath id='path2_fill' d='M 18.2733 5.93931C 26.1235 5.93931 32.9793 8.81583 36.538 13.0734C 35.2126 9.25303 32.7424 5.94262 29.4694 3.6004C 26.1963 1.25818 22.2823 0 18.269 0C 14.2557 0 10.3417 1.25818 7.0686 3.6004C 3.79556 5.94262 1.32539 9.25303 0 13.0734C 3.56745 8.82463 10.4232 5.93931 18.2733 5.93931Z'/%3E %3Cpath id='path3_fill' d='M 7.42789 3.58338C 7.46008 4.3243 7.27355 5.05819 6.89193 5.69213C 6.51031 6.32607 5.95075 6.83156 5.28411 7.1446C 4.61747 7.45763 3.87371 7.56414 3.14702 7.45063C 2.42032 7.33712 1.74336 7.0087 1.20184 6.50695C 0.660328 6.0052 0.27861 5.35268 0.105017 4.63202C -0.0685757 3.91135 -0.0262361 3.15494 0.226675 2.45856C 0.479587 1.76217 0.931697 1.15713 1.52576 0.720033C 2.11983 0.282935 2.82914 0.0334395 3.56389 0.00313344C 4.54667 -0.0374033 5.50529 0.316706 6.22961 0.987835C 6.95393 1.65896 7.38484 2.59235 7.42789 3.58338L 7.42789 3.58338Z'/%3E %3Cpath id='path4_fill' d='M 2.27471 4.39629C 1.84363 4.41508 1.41671 4.30445 1.04799 4.07843C 0.679268 3.8524 0.385328 3.52114 0.203371 3.12656C 0.0214136 2.73198 -0.0403798 2.29183 0.0258116 1.86181C 0.0920031 1.4318 0.283204 1.03126 0.575213 0.710883C 0.867222 0.39051 1.24691 0.164708 1.66622 0.0620592C 2.08553 -0.0405897 2.52561 -0.0154714 2.93076 0.134235C 3.33591 0.283941 3.68792 0.551505 3.94222 0.90306C 4.19652 1.25462 4.34169 1.67436 4.35935 2.10916C 4.38299 2.69107 4.17678 3.25869 3.78597 3.68746C 3.39516 4.11624 2.85166 4.37116 2.27471 4.39629L 2.27471 4.39629Z'/%3E %3C/defs%3E %3C/svg%3E\"});")

Screenshot

screenshot of custom notifications for when JupyterLab cell execution has finished

@leej11
Copy link

leej11 commented Sep 4, 2020

You can simply call Javascript to trigger a new notification at the end of the cell:

Hey this is a great workaround! Do you know of how I could wrap this with a Python function... I tried something like this:

def play_notification():
    Javascript("new Notification('Cell Execution Has Finished')")

play_notification()

But that doesn't work, which I'm not surprised, but I'm curious if there's a way one can do this?

@markgeejw
Copy link

@leej11 try adding a return, i.e.

def play_notification():
   return Javascript("new Notification('Cell Execution Has Finished')")

play_notification()

@GF-Huang
Copy link

Still alive?

@krassowski
Copy link

If you are using Ubuntu or another distribution with GNOME you can give https://github.com/krassowski/jupyter-helpers a try.
It might also work on Windows.

@mwakaba2
Copy link

I created one that supports both jupyter notebook and jupyterlab.
https://github.com/mwakaba2/jupyter_notifications

@samiemad samiemad linked a pull request Aug 9, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.