Added class for easy granular marker configuration · commit-0/python-progressbar@c1fcabf · GitHub
Skip to content

Commit c1fcabf

Browse files
committed
Added class for easy granular marker configuration
1 parent 0ad8251 commit c1fcabf

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

examples.py

Lines changed: 2 additions & 1 deletion

progressbar/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def __init__(self, target, capturing=False, listeners=set()):
192192
self.listeners = listeners
193193
self.needs_clear = False
194194

195-
def isatty(self):
195+
def isatty(self): # pragma: no cover
196196
return self.target.isatty()
197197

198198
def write(self, value):

progressbar/widgets.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,15 @@ def get_values(self, progress, data):
909909
return ranges
910910

911911

912+
class GranularMarkers:
913+
smooth = ' ▏▎▍▌▋▊▉█'
914+
bar = ' ▁▂▃▄▅▆▇█'
915+
snake = ' ▖▌▛█'
916+
fade_in = ' ░▒▓█'
917+
dots = ' ⡀⡄⡆⡇⣇⣧⣷⣿'
918+
growing_circles = ' .oO'
919+
920+
912921
class GranularBar(AutoWidthWidgetBase):
913922
'''A progressbar that can display progress at a sub-character granularity
914923
by using multiple marker characters.
@@ -920,14 +929,18 @@ class GranularBar(AutoWidthWidgetBase):
920929
- Fade in: ` ░▒▓█`
921930
- Dots: ` ⡀⡄⡆⡇⣇⣧⣷⣿`
922931
- Growing circles: ` .oO`
932+
933+
The markers can be accessed through GranularMarkers. GranularMarkers.dots
934+
for example
923935
'''
924936

925-
def __init__(self, markers=' ▏▎▍▌▋▊▉█', left='|', right='|', **kwargs):
937+
def __init__(self, markers=GranularMarkers.smooth, left='|', right='|',
938+
**kwargs):
926939
'''Creates a customizable progress bar.
927940
928941
markers - string of characters to use as granular progress markers. The
929942
first character should represent 0% and the last 100%.
930-
Ex: ` .oO`
943+
Ex: ` .oO`.
931944
left - string or callable object to use as a left border
932945
right - string or callable object to use as a right border
933946
'''

tests/test_monitor_progress.py

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)