Hi , everyone and Merry Christmas to you. I want to know how to change Tqdm text color. in my question, I can change text color. but next step , this text color return to normal(‘black’) . I want to remain this color. What should I do?
import time
import panel as pn
# **** Hack Fix ****
class ptqdm2(pn.widgets.indicators.ptqdm):
def display(self, msg=None, pos=None, bar_style=None):
super().display(msg, pos)
style = self._indicator.text_pane.style or {}
if not "color" in style:
color = self.colour or 'black'
self._indicator.text_pane.style = dict(style, color=color)
if self.total is not None and self.n is not None:
self._indicator.max = int(self.total) # Can be numpy.int64
self._indicator.value = int(self.n)
self._indicator.text = self._to_text(**self.format_dict)
return True
pn.widgets.indicators.ptqdm=ptqdm2
# **** Hack Fix ****
from panel.widgets import Tqdm
pn.extension()
tqdm_outer = Tqdm()
tqdm_inner = Tqdm(margin=(0, 0, 0, 20))
tqdm_outer.text_pane.style={'color': 'green'}
tqdm_inner.text_pane.style={'color': 'red'}
def run_nested_loop(*events, timeout=0.05):
for i in tqdm_outer(range(10)):
for j in tqdm_inner(range(10)):
time.sleep(timeout)
run_nested_loop(timeout=0.001)
button = pn.widgets.Button(name="Run Nested Loop", button_type="success")
button.on_click(run_nested_loop)
app = pn.Column(tqdm_outer, tqdm_inner,button)
app.servable()
@Marc Thank you for your cooperation. I tried it. It works that I wanted. Let me show this screen shot.
Screen shot
How ever , in my condition . I have to delete super function. when super function execute , color return to black. this is the point that I comment outed line.