Python ipywidgets.FloatProgress() Examples

The following are 7 code examples of ipywidgets.FloatProgress(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module ipywidgets , or try the search function .
Example #1
Source File: ipython.py    From OpenModes with GNU General Public License v3.0 6 votes vote down vote up
def progress_iterator(orig_iterator, description):
    """Wrap an iterator so that a progress bar is displayed

    Parameters
    ----------
    orig_iterator: iterator
        The original iterator. It must implement the __len__ operation so that
        its length can be calculated in advance.
    description: string
        Description will give a text label for the bar.
    """
    progress_widget = FloatProgress(min=0, max=len(orig_iterator)-1)
    widget = HBox([Label(description), progress_widget])
    display(widget)
    for count, val in enumerate(orig_iterator):
        yield val
        progress_widget.value = count 
Example #2
Source File: ABuProgress.py    From abu with GNU General Public License v3.0 6 votes vote down vote up
def init_ui_progress(self):
        """初始化ui进度条"""
        if not self.show_progress:
            return

        if not ABuEnv.g_is_ipython or self._total < 2:
            return

        if ABuEnv.g_main_pid == os.getpid():
            # 如果是在主进程下显示那就直接来
            self.progress_widget = FloatProgress(value=0, min=0, max=100)
            self.text_widget = Text('pid={} begin work'.format(os.getpid()))
            self.progress_box = Box([self.text_widget, self.progress_widget])
            display(self.progress_box)
        else:
            if g_show_ui_progress and g_socket_fn is not None:
                # 子进程下通过socket通信将pid给到主进程,主进程创建ui进度条
                ABuOsUtil.socket_send_msg(g_socket_fn, '{}|init'.format(os.getpid()))

    # 不管ui进度条有什么问题,也不能影响任务工作的进度执行,反正有文字进度会始终显示 
Example #3
Source File: progress.py    From pywr with GNU General Public License v3.0 5 votes vote down vote up
def reset(self):
        from ipywidgets import FloatProgress, HBox, Label, Layout
        from IPython.display import display
        super(JupyterProgressRecorder, self).reset()
        self.progress_bar = FloatProgress(min=0, max=100, description='Running:')
        self.label = Label("", layout=Layout(width='100%'))
        self.box = HBox([self.progress_bar, self.label])
        display(self.box) 
Example #4
Source File: progress.py    From mead-baseline with Apache License 2.0 5 votes vote down vote up
def __init__(self, total):
        super(ProgressBarJupyter, self).__init__()
        from ipywidgets import FloatProgress
        from IPython.display import display

        self.progress = FloatProgress(min=0, max=total)
        display(self.progress) 
Example #5
Source File: progress_bar.py    From threeML with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _setup(self):

        # Setup the widget, which is a bar between 0 and 100

        self._bar = FloatProgress(min=0, max=100)

        # Set explicitly the bar to 0

        self._bar.value = 0

        # Setup also an HTML label (which will contain the progress, the elapsed time and the foreseen
        # completion time)

        self._title_cell = HTML()

        if self._title is not None:

            self._title_cell.value = "%s : " % self._title

        self._label = HTML()
        self._vbox = VBox(children=[self._title_cell, self._label, self._bar])

        # Display everything

        display(self._vbox)

        self._animate(0) 
Example #6
Source File: ABuProgress.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, a_pid):
        """通过进程pid初始化ui组件"""
        self.progress_widget = FloatProgress(value=0, min=0, max=100)
        self.text_widget = Text('pid={} begin work'.format(a_pid))
        # 通过box容器都放到一个里面
        self.progress_box = Box([self.text_widget, self.progress_widget])
        display(self.progress_box) 
Example #7
Source File: ABuProgress.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def show(self, a_progress=None, ext='', p_format="{}:{}:{}%"):
        """
        进行进度控制显示主方法
        :param ext: 可以添加额外的显示文字,str,默认空字符串
        :param a_progress: 默认None, 即使用类内部计算的迭代次数进行进度显示
        :param p_format: 进度显示格式,默认{}: {}%,即'self._label:round(self._progress / self._total * 100, 2))%'
        """
        self.progress = a_progress if a_progress is not None else self.progress + 1
        ps = round(self._progress / self._total * 100, 2)

        if self._label is not None:
            # 如果初始化label没有就只显示ui进度
            self.f.write('\r')
            self.f.write(p_format.format(self._label, ext, ps))

        if ABuEnv.g_is_ipython:
            if self.progress_widget is None:
                self.progress_widget = FloatProgress(value=0, min=0, max=100)
                display(self.progress_widget)
            self.progress_widget.value = ps

        # 这样会出现余数结束的情况,还是尽量使用上下文管理器控制结束
        if self._progress == self._total:
            self.f.write('\r')
            if self.progress_widget is not None:
                self.progress_widget.close()