Skip to content

Commit

Permalink
fix set_description for notebook
Browse files Browse the repository at this point in the history
fixes tqdm#345
  • Loading branch information
Guangshuo CHEN authored and casperdcl committed Dec 10, 2017
1 parent 57f3c3b commit b1cfad8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tqdm/_tqdm_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def status_printer(_, total=None, desc=None):
container = HBox(children=[pbar, ptext])
display(container)

def print_status(s='', close=False, bar_style=None):
def print_status(s='', close=False, bar_style=None, desc=None):
# Note: contrary to native tqdm, s='' does NOT clear bar
# goal is to keep all infos if error happens so user knows
# at which iteration the loop failed.
Expand Down Expand Up @@ -147,6 +147,10 @@ def print_status(s='', close=False, bar_style=None):
container.close()
except AttributeError:
container.visible = False

# Update description
if desc:
pbar.description = desc

return print_status

Expand Down Expand Up @@ -213,6 +217,19 @@ def moveto(self, *args, **kwargs):
# void -> avoid extraneous `\n` in IPython output cell
return

def set_description(self, desc=None, refresh=True):
"""
Set/modify description of the progress bar.
Parameters
----------
desc : str, optional
refresh : bool, optional
Forces refresh [default: True]. Ineffective in tqdm_notebook.
"""
self.sp(desc=desc)



def tnrange(*args, **kwargs):
"""
Expand Down

0 comments on commit b1cfad8

Please sign in to comment.