##// END OF EJS Templates
Minimal progressbar primitive...
Marius van Niekerk -
Show More
@@ -5,7 +5,7 b''
5 # Distributed under the terms of the Modified BSD License.
5 # Distributed under the terms of the Modified BSD License.
6
6
7
7
8 from binascii import b2a_hex, b2a_base64
8 from binascii import b2a_hex, b2a_base64, hexlify
9 import json
9 import json
10 import mimetypes
10 import mimetypes
11 import os
11 import os
@@ -728,6 +728,38 b' class SVG(DisplayObject):'
728 def _repr_svg_(self):
728 def _repr_svg_(self):
729 return self._data_and_metadata()
729 return self._data_and_metadata()
730
730
731 class ProgressBar(object):
732 """Progressbar supports displaying a progressbar like element
733 """
734 def __init__(self, total):
735 """Creates a new progressbar
736
737 Parameters
738 ----------
739 total : int
740 maximnum size of the progressbar
741 """
742 self._display_id = hexlify(os.urandom(8)).decode('ascii')
743 self.total = total
744 self._progress = 0
745
746 def _repr_html_(self):
747 return "<progress style='width:100%' max='{}' value='{}'></progress>".format(self.total, self.progress)
748
749 def display(self):
750 display(self, display_id=self._display_id)
751
752 def update(self):
753 display(self, display_id=self._display_id, update=True)
754
755 @property
756 def progress(self):
757 return self._progress
758
759 @progress.setter
760 def progress(self, value):
761 self._progress = value
762 self.update()
731
763
732 class JSON(DisplayObject):
764 class JSON(DisplayObject):
733 """JSON expects a JSON-able dict or list
765 """JSON expects a JSON-able dict or list
General Comments 0
You need to be logged in to leave comments. Login now