Manage the printing of an IPython/Jupyter Notebook progress bar widget.
(_, total=None, desc=None, ncols=None)
| 93 | """ |
| 94 | @staticmethod |
| 95 | def status_printer(_, total=None, desc=None, ncols=None): |
| 96 | """ |
| 97 | Manage the printing of an IPython/Jupyter Notebook progress bar widget. |
| 98 | """ |
| 99 | # Fallback to text bar if there's no total |
| 100 | # DEPRECATED: replaced with an 'info' style bar |
| 101 | # if not total: |
| 102 | # return super(tqdm_notebook, tqdm_notebook).status_printer(file) |
| 103 | |
| 104 | # fp = file |
| 105 | |
| 106 | # Prepare IPython progress bar |
| 107 | if IProgress is None: # #187 #451 #558 #872 |
| 108 | raise ImportError(WARN_NOIPYW) |
| 109 | if total: |
| 110 | pbar = IProgress(min=0, max=total) |
| 111 | else: # No total? Show info style bar with no progress tqdm status |
| 112 | pbar = IProgress(min=0, max=1) |
| 113 | pbar.value = 1 |
| 114 | pbar.bar_style = 'info' |
| 115 | if ncols is None: |
| 116 | pbar.layout.width = "20px" |
| 117 | |
| 118 | ltext = HTML() |
| 119 | rtext = HTML() |
| 120 | if desc: |
| 121 | ltext.value = desc |
| 122 | container = TqdmHBox(children=[ltext, pbar, rtext]) |
| 123 | # Prepare layout |
| 124 | if ncols is not None: # use default style of ipywidgets |
| 125 | # ncols could be 100, "100px", "100%" |
| 126 | ncols = str(ncols) # ipywidgets only accepts string |
| 127 | try: |
| 128 | if int(ncols) > 0: # isnumeric and positive |
| 129 | ncols += 'px' |
| 130 | except ValueError: |
| 131 | pass |
| 132 | pbar.layout.flex = '2' |
| 133 | container.layout.width = ncols |
| 134 | container.layout.display = 'inline-flex' |
| 135 | container.layout.flex_flow = 'row wrap' |
| 136 | |
| 137 | return container |
| 138 | |
| 139 | def display(self, msg=None, pos=None, |
| 140 | # additional signals |