How to get progress bar to time Class exectution

Posted by chrissygormley on Stack Overflow See other posts from Stack Overflow or by chrissygormley
Published on 2010-06-09T09:24:22Z Indexed on 2010/06/09 9:42 UTC
Read the original article Hit count: 321

Filed under:
|
|

Hello,

I am trying to use progress bar to show the progress of a script. I want it increase progress after every function in a class is executed. The code I have tried is below:

import progressbar
from time import sleep

class hello():
    def no(self):
        print 'hello!'

    def yes(self):
        print 'No!!!!!!'


def pro():
    bar = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ', progressbar.Percentage()])

    for i in Yep():
        bar.update(Yep.i())
        sleep(0.1)
    bar.finish()

if __name__ == "__main__":
    Yep = hello()
    pro()

Does anyone know how to get this working. Thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about classes