Skip to content

Commit

Permalink
notebook: add colour
Browse files Browse the repository at this point in the history
- fixes #450
  • Loading branch information
casperdcl committed Sep 27, 2020
1 parent 3f7e8e9 commit 4d36140
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tqdm/notebook.py
Expand Up @@ -190,6 +190,14 @@ def display(self, msg=None, pos=None,
except AttributeError:
self.container.visible = False

@property
def colour(self):
return self.container.children[-2].style.bar_color

@colour.setter
def colour(self, bar_color):
self.container.children[-2].style.bar_color = bar_color

def __init__(self, *args, **kwargs):
kwargs = kwargs.copy()
# Setup default output
Expand All @@ -204,6 +212,7 @@ def __init__(self, *args, **kwargs):
'{bar}', '<bar/>')
# convert disable = None to False
kwargs['disable'] = bool(kwargs.get('disable', False))
colour = kwargs.pop('colour', None)
super(tqdm_notebook, self).__init__(*args, **kwargs)
if self.disable or not kwargs['gui']:
self.sp = lambda *_, **__: None
Expand All @@ -218,6 +227,7 @@ def __init__(self, *args, **kwargs):
self.container = self.status_printer(
self.fp, total, self.desc, self.ncols)
self.sp = self.display
self.colour = colour

# Print initial bar state
if not self.disable:
Expand Down

0 comments on commit 4d36140

Please sign in to comment.