Python Forum
is there an easy way to add a progress bar/counter to an existing script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is there an easy way to add a progress bar/counter to an existing script
#2
tkinter
https://riptutorial.com/tkinter/example/...rogressbar

console/terminal
import time, sys

if sys.version[0] == '2':
    range = xrange
    
def flush():
    if sys.version[0] == '2':
        sys.stdout.flush()


def progressbar_num():
    for num in range(101):
        time.sleep(.1)
        sys.stdout.write("\r{}%".format(num))    # or print >> sys.stdout, "\r%d%%" %i,
        flush()
    print('')

def progressbar_disp():
    display_char = '#'
    for num in range(101):
        time.sleep(.1)
        sys.stdout.write("\r[{0}] {1}%".format(int(num/3)*display_char, num))
        flush()
    print('')

def progressbar_disp_full():
    display_char = '#'
    incomplete_char = ' '
    for num in range(101):
        spacer = int(33-int(num/3)) * incomplete_char
        filler = int(num/3)*display_char
        time.sleep(.1)
        sys.stdout.write("\r[{0}{1}] {2}%".format(filler, spacer, num))
        flush()
    print('')
    
progressbar_num()
progressbar_disp()
progressbar_disp_full()
Whatever your current code is, you would increment the progressbar at the point at which it needs. I am not sure if your downloading, loading resources, etc.

This would be an example of downloading using a percentage progressbar
Recommended Tutorials:
Reply


Messages In This Thread
RE: is there an easy way to add a progress bar/counter to an existing script - by metulburr - Jun-09-2019, 02:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python beginner that needs an expression added to existing script markham 1 794 Sep-04-2023, 05:24 AM
Last Post: Pedroski55
  Progress bar bnadir55 1 1,942 Apr-11-2022, 01:52 PM
Last Post: deanhystad
  Progress Indicator for Xmodem 0.4.6 KenHorse 1 2,084 Jan-30-2021, 07:12 PM
Last Post: bowlofred
  Need help creating complex loop around existing script CephloRhod 5 2,903 Apr-16-2020, 01:23 PM
Last Post: deanhystad
  How can I add a progress bar for my software? aquerci 8 3,961 Nov-16-2019, 04:20 PM
Last Post: aquerci
  wget progress bar anasrocks 1 4,830 Jun-06-2019, 03:12 PM
Last Post: heiner55
  Progress Finished Question malonn 32 18,174 May-23-2018, 02:43 AM
Last Post: malonn
  Seeking feedback on my script-in-progress league55 2 2,764 Feb-12-2018, 03:03 PM
Last Post: league55
  how to progress with py jakegold98 1 2,718 Dec-05-2017, 02:58 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020