Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

PYTHON A progress bar or self-updated timer when reading a large pdf file with PyPDF2 convert_from_path

I am trying to show a self-updated timer/progress bar when the system is reading the following file:

#initialize widgets
widgets = ['Reading data, please wait: ', pb.Percentage(), ' ', 
pb.Bar(marker=pb.RotatingMarker()), ' ', pb.ETA()]

#initialize timer
timer = pb.ProgressBar(widgets=widgets, maxval=1000000).start()

for i in range(0,1000000):
    timer.update(i)
    pages = convert_from_path(filepath + "\" + file, poppler_path = r'C:UsersuserAppDataLocalProgramsPythonPython38PUGpoppler-0.67.0_x86poppler-0.67.0in')
    timer.finish()

However, if I put the above code in for loop, the time will not update itself but until the file is finished reading.

Is there any way to print the progress and update the time, at the same time, the system is reading that large pdf file.

e.g. Reading file, please wait... Time escape: 1s<-- the time will update itself every second

after the system finished reading, the timer will no longer update.

Thx

question from:https://stackoverflow.com/questions/65949870/python-a-progress-bar-or-self-updated-timer-when-reading-a-large-pdf-file-with-p

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...