@@ -628,17 +628,20 @@ def __call__(self, progress, data, format=None):
628628class Percentage (FormatWidgetMixin , WidgetBase ):
629629 '''Displays the current percentage as a number with a percent sign.'''
630630
631- def __init__ (self , format = '%(percentage)3d%%' , ** kwargs ):
631+ def __init__ (self , format = '%(percentage)3d%%' , na = 'N/A%%' , ** kwargs ):
632+ self .na = na
632633 FormatWidgetMixin .__init__ (self , format = format , ** kwargs )
633634 WidgetBase .__init__ (self , format = format , ** kwargs )
634635
635636 def __call__ (self , progress , data , format = None ):
637+ return FormatWidgetMixin .__call__ (self , progress , data , self .get_format (progress , data ))
638+
639+ def get_format (self , progress , data ):
636640 # If percentage is not available, display N/A%
637641 if 'percentage' in data and not data ['percentage' ]:
638- return FormatWidgetMixin .__call__ (self , progress , data ,
639- format = 'N/A%%' )
642+ return self .na
640643
641- return FormatWidgetMixin . __call__ ( self , progress , data )
644+ return self . format
642645
643646
644647class SimpleProgress (FormatWidgetMixin , WidgetBase ):
0 commit comments