@@ -178,6 +178,8 @@ class ProgressBar(StdRedirectMixin, ResizableMixin, ProgressBarBase):
178178 max_error (bool): When True the progressbar will raise an error if it
179179 goes beyond it's set max_value. Otherwise the max_value is simply
180180 raised when needed
181+ prefix (str): Prefix the progressbar with the given string
182+ suffix (str): Prefix the progressbar with the given string
181183
182184 A common way of using it is like:
183185
@@ -228,7 +230,7 @@ class ProgressBar(StdRedirectMixin, ResizableMixin, ProgressBarBase):
228230 def __init__ (self , min_value = 0 , max_value = None ,
229231 widgets = None , left_justify = True , initial_value = 0 ,
230232 poll_interval = None , widget_kwargs = None , custom_len = len ,
231- max_error = True , ** kwargs ):
233+ max_error = True , prefix = None , suffix = None , ** kwargs ):
232234 '''
233235 Initializes a progress bar with sane defaults
234236 '''
@@ -253,6 +255,8 @@ def __init__(self, min_value=0, max_value=None,
253255 self .max_value = max_value
254256 self .max_error = max_error
255257 self .widgets = widgets
258+ self .prefix = prefix
259+ self .suffix = suffix
256260 self .widget_kwargs = widget_kwargs or {}
257261 self .left_justify = left_justify
258262 self .value = initial_value
@@ -626,6 +630,14 @@ def start(self, max_value=None, init=True):
626630 if self .widgets is None :
627631 self .widgets = self .default_widgets ()
628632
633+ if self .prefix :
634+ self .widgets .insert (0 , widgets .FormatLabel (
635+ self .prefix , new_style = True ))
636+
637+ if self .suffix :
638+ self .widgets .append (widgets .FormatLabel (
639+ self .suffix , new_style = True ))
640+
629641 for widget in self .widgets :
630642 interval = getattr (widget , 'INTERVAL' , None )
631643 if interval is not None :
0 commit comments