Skip to content

Commit

Permalink
Merge branch 'notebook-nototal' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Sep 27, 2020
2 parents e7b531a + 3fce28f commit e835860
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions tqdm/notebook.py
Expand Up @@ -106,14 +106,11 @@ def status_printer(_, total=None, desc=None, ncols=None):
if ncols is None:
pbar.layout.width = "20px"

ltext = HTML()
rtext = HTML()
if desc:
pbar.description = desc
if IPYW >= 7:
pbar.style.description_width = 'initial'
# Prepare status text
ptext = HTML()
# Only way to place text to the right of the bar is to use a container
container = HBox(children=[pbar, ptext])
ltext.value = desc
container = HBox(children=[ltext, pbar, rtext])
# Prepare layout
if ncols is not None: # use default style of ipywidgets
# ncols could be 100, "100px", "100%"
Expand Down Expand Up @@ -151,7 +148,7 @@ def display(self, msg=None, pos=None,
if not msg and not close:
msg = self.__repr__()

pbar, ptext = self.container.children
ltext, pbar, rtext = self.container.children
pbar.value = self.n

if msg:
Expand All @@ -168,13 +165,10 @@ def display(self, msg=None, pos=None,
right = right[1:]

# Update description
pbar.description = left
if IPYW >= 7:
pbar.style.description_width = 'initial'

ltext.value = left
# never clear the bar (signal: msg='')
if right:
ptext.value = right
rtext.value = right

# Change bar style
if bar_style:
Expand Down Expand Up @@ -273,9 +267,12 @@ def reset(self, total=None):
----------
total : int or float, optional. Total to use for the new bar.
"""
_, pbar, _ = self.container.children
pbar.bar_style = ''
if total is not None:
pbar, _ = self.container.children
pbar.max = total
if not self.total and self.ncols is None: # no longer unknown total
pbar.layout.width = None # reset width
return super(tqdm_notebook, self).reset(total=total)


Expand Down

0 comments on commit e835860

Please sign in to comment.