Git Product home page Git Product logo

Comments (1)

gaulinmp avatar gaulinmp commented on July 19, 2024

I had this problem too, and solved it using display_javascript. While I haven't gotten it working for IProgress (because checking is all done at import time in progressbar.py file), I do have it working for gaulinmp/tqdm.

Basically in the import preamble of the module, I put the following:

display.display_javascript("""IPython.notebook.kernel.execute(
                           'from IPython import get_ipython;
                           get_ipython().has_js=True');""", raw=True)

Then I have a simple check function which is run whenever I want to know if I'm in a notebook:

ip = IPython.get_ipython()
...
def _has_js():
    return hasattr(ip, 'has_js')

Because the get_ipython() object is global (seems to be in testing at least, I'm ignorant here on the specifics), the _has_js call will find the has_js object only if javascript is present, which is only the case when running a notebook. I don't know if this is always true though, so YMMV.

I didn't get it running for IProgress, but I think that's because the progressbar.py file checks for IPython at import time, not when the progress bar object is created. That's why I defer the check to decide which type of progress bar to create in my fork of tqdm linked above. I did copy the rest of your import code though, thanks for that!

from iprogress.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.