StatusBar

Status Bar utility for tasks without a known size limit

Attributes

StatusBar.default_animation

tuple of strings that will be printed one in each state in a cyclic fashion:

('-', '\\', '|', '/')

Functions

StatusBar.__init__(self, message, num_spaces, time_format=None, refresh_interval=0.5, animation=default_animation)

Configures the newly built status bar instance

Parameters:
  • message – (str): message that should be used when printing the status
  • num_spaces – (int): number of spaces that should be used before the message is printed
  • time_format – (str, optional) : time format to be used for the elapsed time (None by default)
  • refresh_interval – (int, optional): time period (in seconds) used to update the shown status, or -1 if not activated. (0.5 by default)
  • animation – (tuple, optional): tuple of strings that will be printed one in each state in a cyclic fashion (default_animation by default)
StatusBar.start(self)

Marks the start of the status bar

StatusBar.update(self, force_print=False, status=None)

Update the shown status bar

Parameters:
  • force_print – (bool, optional): True iff should force an update of the printed message (False by default)
  • status – (str, optional): the status message for the update (None by default)
StatusBar.printStatus(self)

Prints the status bar + animation

StatusBar.finish(self, status=None)

Close the status bar (on error / successful finish)

Parameters:status – (str, optional): the finish status message (None by default)

Usage Examples

Creating a classic status bar that causes the user to think that something happens:
s = StatusBar('Waiting for the debugger to boot', 30, time_format="Elapsed %M:%S -")
s.start()
for i in range(100):
    s.update()
    time.sleep(0.1)
s.finish()