Esempio n. 1
0
    def _update_ipython_widget(self, value=None):
        """
        Update the progress bar to the given value (out of a total
        given to the constructor).

        This method is for use in the IPython notebook 2+.
        """

        # Create and display an empty progress bar widget,
        # if none exists.
        if not hasattr(self, '_widget'):
            # Import only if an IPython widget, i.e., widget in iPython NB
            if ipython_major_version < 4:
                self._widget = widgets.FloatProgressWidget()
            else:
                self._widget = widgets.FloatProgress()

            if is_widgets_available():
                display(self._widget)
            self._widget.value = 0

        # Calculate percent completion, and update progress bar
        percent = (float(value)/self._total) * 100.0
        self._widget.value = percent
        self._widget.description =' ({0:>6s}%)'.format('{0:.2f}'.format(percent))
Esempio n. 2
0
    def _update_ipython_widget(self, value=None):
        """
        Update the progress bar to the given value (out of a total
        given to the constructor).

        This method is for use in the IPython notebook 2+.
        """

        # Create and display an empty progress bar widget,
        # if none exists.
        if not hasattr(self, '_widget'):
            # Import only if an IPython widget, i.e., widget in iPython NB
            if ipython_major_version < 4:
                from IPython.html import widgets
                self._widget = widgets.FloatProgressWidget()
            else:
                from ipywidgets import widgets
                self._widget = widgets.FloatProgress()
            from IPython.display import display

            display(self._widget)
            self._widget.value = 0

        # Calculate percent completion, and update progress bar
        frac = (value / self._total)
        self._widget.value = frac * 100
        self._widget.description = ' ({:>6.2%})'.format(frac)
Esempio n. 3
0
    def _update_ipython_widget(self, value=None):
        """
        Update the progress bar to the given value (out of a total
        given to the contructor).

        This method is for use in the IPython notebook 2+.
        """

        # Create and display an empty progress bar widget,
        # if none exists.
        if not hasattr(self, '_widget'):
            # Import only if an IPython widget, i.e., widget in iPython NB
            from IPython.html import widgets
            from IPython.display import display

            self._widget = widgets.FloatProgressWidget()
            display(self._widget)
            self._widget.value = 0

        # Calculate percent completion, and update progress bar
        percent = (value / self._total) * 100
        self._widget.value = percent
        self._widget.description = ' ({0:>6s}%)'.format(
            '{0:.2f}'.format(percent))