mirror of https://github.com/tqdm/tqdm.git
autonotebook: check for ipywidgets
- closes #1218 - fixes #1082 - fixes #1217
This commit is contained in:
parent
01ae86bd09
commit
7cdbfee224
|
@ -8,6 +8,7 @@ Usage:
|
|||
"""
|
||||
import os
|
||||
import sys
|
||||
from warnings import warn
|
||||
|
||||
try:
|
||||
get_ipython = sys.modules['IPython'].get_ipython
|
||||
|
@ -15,11 +16,14 @@ try:
|
|||
raise ImportError("console")
|
||||
if 'VSCODE_PID' in os.environ: # pragma: no cover
|
||||
raise ImportError("vscode")
|
||||
from .notebook import WARN_NOIPYW, IProgress
|
||||
if IProgress is None:
|
||||
from .std import TqdmWarning
|
||||
warn(WARN_NOIPYW, TqdmWarning, stacklevel=2)
|
||||
raise ImportError('ipywidgets')
|
||||
except Exception:
|
||||
from .std import tqdm, trange
|
||||
else: # pragma: no cover
|
||||
from warnings import warn
|
||||
|
||||
from .notebook import tqdm, trange
|
||||
from .std import TqdmExperimentalWarning
|
||||
warn("Using `tqdm.autonotebook.tqdm` in notebook mode."
|
||||
|
|
|
@ -71,6 +71,9 @@ if True: # pragma: no cover
|
|||
|
||||
__author__ = {"github.com/": ["lrq3000", "casperdcl", "alexanderkuk"]}
|
||||
__all__ = ['tqdm_notebook', 'tnrange', 'tqdm', 'trange']
|
||||
WARN_NOIPYW = ("IProgress not found. Please update jupyter and ipywidgets."
|
||||
" See https://ipywidgets.readthedocs.io/en/stable"
|
||||
"/user_install.html")
|
||||
|
||||
|
||||
class TqdmHBox(HBox):
|
||||
|
@ -112,10 +115,7 @@ class tqdm_notebook(std_tqdm):
|
|||
|
||||
# Prepare IPython progress bar
|
||||
if IProgress is None: # #187 #451 #558 #872
|
||||
raise ImportError(
|
||||
"IProgress not found. Please update jupyter and ipywidgets."
|
||||
" See https://ipywidgets.readthedocs.io/en/stable"
|
||||
"/user_install.html")
|
||||
raise ImportError(WARN_NOIPYW)
|
||||
if total:
|
||||
pbar = IProgress(min=0, max=total)
|
||||
else: # No total? Show info style bar with no progress tqdm status
|
||||
|
|
Loading…
Reference in New Issue