I saw many different codes and examples with progression bar. However none of them shows it in a UI format. It only shows it in the IDE which is not going to work if the user is not going to the IDE to run it. I don't have PYQT so I can't use it to create progress bar in that way. Are there any other ways to create progression bar that a user can see it after running the program, not via IDE.
Asked
Active
Viewed 758 times
0
-
I have a super basic text progress bar for the command line if you want that – jacoblaw Jul 25 '17 at 23:22
-
Ok how does it show, the command line pops up and shows the % completed ? – Johnseito Jul 25 '17 at 23:24
-
Well if i run the program from a terminal, it appears in the terminal. I assume thats what you mean when you say you run the program not in an IDE – jacoblaw Jul 25 '17 at 23:25
-
no run the program in executable (icon) – Johnseito Jul 25 '17 at 23:30
-
Well you could have a command line pop up when the executable is run, and show the text progress bar – jacoblaw Jul 25 '17 at 23:32
-
Ok that is fine with me. how do you show that ? – Johnseito Jul 25 '17 at 23:34
-
This question is already answered here: https://stackoverflow.com/questions/3160699/python-progress-bar – Sandeep S. Sandhu Jun 10 '21 at 09:04
2 Answers
1
Here is some code for a very basic text progress bar:
class progressBar():
def __init__(self, title, length=40):
self.BAR_LENGTH = length
self.title = title
print('{}\t['.format(self.title) + ' ' * self.BAR_LENGTH + ']', end='')
def update(self, val):
# round from 0 to self.BAR_LENGTH
bars = round(val * self.BAR_LENGTH)
print('\r{}\t['.format(self.title) + '#' * bars + ' ' * (self.BAR_LENGTH - bars) + ']\t{0:.2f}%'.format(
val * 100), end='')
def close(self):
print('')
You use it like this:
bar = progressBar("Text beside progress bar")
while myLoopCondition == True
# loop that you want to show progress of
...
bar.update(new percentage) # decimal number from 0-1
bar.close()
Whatever program you use to make your executable should have a way of displaying a terminal when you run the program.
You should look into getting pyqt for this though

jacoblaw
- 1,263
- 9
- 9
-
That is not something I can answer with the info you gave. Put it wherever seems appropriate i guess – jacoblaw Jul 25 '17 at 23:45
0
You could use the tqdm library.
You only need to modify your loop to include a counter, see this example:
from tqdm import tqdm
import time
startTime = time.clock()
totalCount = len(listOfItems)
for index, item in enumerate(listOfItems):
stopTime = time.clock()
statusBarText = tqdm.format_meter(index + 1,
totalCount,
stopTime - startTime,
ncols=80, # prints text 80 characters wide
ascii=False)
print(statusBarText, '\b' * 81, end='')
startTime = time.clock()
... rest of the code in your loop goes here ...

Sandeep S. Sandhu
- 417
- 9
- 13