-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose colo(u)r for IntProgress/FloatProgress #2982
Comments
It looks like these are exposed, though perhaps not in the most obvious way. You need to set them after you create the widget: import ipywidgets as widgets
prog = widgets.IntProgress()
prog.value = 50
prog.style.bar_color = 'maroon'
display(prog) (Also, I ❤️ tqdm) Looking at the code here: ipywidgets/ipywidgets/widgets/widget_int.py Lines 173 to 193 in 6667f81
ipywidgets/ipywidgets/widgets/trait_types.py Lines 13 to 33 in 6667f81
|
hmm thanks (though as you say, non-intuitive). Maybe wanna consider tidying up the init kwargs... import ipywidgets as widgets
prog = widgets.IntProgress()
prog.value = 50
#prog.style.bar_color = 'maroon' # overrides `bar_style`
#prog.bar_style = 'success' # turns green only if `bar_color` not set
display(prog) or better: import ipywidgets as widgets
prog = widgets.IntProgress(style={'bar_color': 'maroon'})
prog.value = 50
display(prog) Feel free to close if you want. P.S.: from tqdm.notebook import tqdm, trange
with trange(int(1e7)) as pbar:
pbar.container.children[-2].style.bar_color = '#ffff00' # or 'yellow'
for i in pbar:
pass |
ah srry thought you were a maintainer. Was being lazy. Anyway updated the description. |
@casperdcl would you like to open a PR to update the docs? |
do you mean update the |
Yes, if you think it would be useful for the examples provided in the comments above to be in the documentation. |
Problem
IntProgress
andFloatProgress
have abar_style
argument to control colour... yet the option strings it accepts don't sound like they control colour. Directly defining custom colours is also not documented. This seems an odd design choice (or lack thereof).Proposed Solutions
style
kwarg, i.e.:style={'bar_color': 'green'}
bar_style
accept colours (hex or plaintext,'#00ff00' == 'green' == 'success'
)colour
(orcolor
to keep Americans happy)bar_style
Additional context
tqdm/tqdm#450 (comment)
The text was updated successfully, but these errors were encountered: