+ 9
[SOLVED] loading bar in python
so, I made this code a day ago, and it works great. but.... I was wondering. can I make it so that instead of making a bunch of loading bars and printing them all out. it would just make one loading bar and update it. this is the code i have https://code.sololearn.com/clVxw7CCrQW4/?ref=app
9 Answers
+ 9
In a console, you can use a carriage return (\r). Instead of jumping to the next line, you go back to the beginning of the current line and overwrite/update it. I've done it, works perfectly. And it's platform independent
/Edit: Here's an example code
https://code.sololearn.com/c4qL4yxM316Z/?ref=app
+ 8
Nafis Handoko that would only work if I ran my code in the command line right?
+ 6
How about GUIing it? (won't work in SL, but at least it works somewhere)
+ 5
Emerson Prado can you provide a example, I don't think I fully understand.
+ 2
LONGTIE👔 With Sololearn's code playground, it won't work...
Wait, your loader won't work under any circumstance, even with a proper IDE.
Reason being you can't clear your console.
+ 2
does python not have a cmd function to clear the console like os.execute(#cmd here)
+ 2
to clear the console
os.system ("cls")
+ 2
You could just output one char at a time, for every whatever percentage of completion. Like print with "" as line ending.
Caveat 1: won't work in SoloLearn playground
Caveat 2: you can't print anything else until your progress bar is finished.
Ah, remember to print a newline when bar finishes.
+ 1
⏩ Prometheus ⏪ will this code help in GUIing it
https://code.sololearn.com/WWX8x2YVp45v/?ref=app