`ipywidgets.HBox` with a pretty representation
| 67 | |
| 68 | |
| 69 | class TqdmHBox(HBox): |
| 70 | """`ipywidgets.HBox` with a pretty representation""" |
| 71 | def _json_(self, pretty=None): |
| 72 | pbar = getattr(self, 'pbar', None) |
| 73 | if pbar is None: |
| 74 | return {} |
| 75 | d = pbar.format_dict |
| 76 | if pretty is not None: |
| 77 | d["ascii"] = not pretty |
| 78 | return d |
| 79 | |
| 80 | def __repr__(self, pretty=False): |
| 81 | pbar = getattr(self, 'pbar', None) |
| 82 | if pbar is None: |
| 83 | return super().__repr__() |
| 84 | return pbar.format_meter(**self._json_(pretty)) |
| 85 | |
| 86 | def _repr_pretty_(self, pp, *_, **__): |
| 87 | pp.text(self.__repr__(True)) |
| 88 | |
| 89 | |
| 90 | class tqdm_notebook(std_tqdm): |