Web Analytics Made Easy - Statcounter
Skip to content

ProgressBar

ProgressBar call reference

Displays a horizontal or vertical 2-color progress bar.

layout = [[sg.ProgressBar(10, key='-PROGRESS_BAR-'), sg.Button('Update!', key='-UPDATE-')]]
count = 0

window = sg.Window(title='ProgressBar Element', layout=layout, resizable=True)

while True:
    event, values = window.read()

    if event == sg.WIN_CLOSED:
        break
    elif event == '-UPDATE-':
        count += 1
        window['-PROGRESS_BAR-'].update(current_count=count)

Events

The ProgressBar element does not generate any events.

Values Dictionary

The ProgressBar element does not have a Values Dictionary entry.

Size

The size parameter is a tuple (length, width).

The easiest rule to learn about the size for this element is "the width is always measured in pixels". If you have a horizontal progress bar, then the length will be in "characters". If your progress bar is vertical, then the length will be in "rows".

Both of these progress bars have used a size value of (10, 25). The width of the white bar is 25 pixels wide.

Here the orientation was set to 'h' indicating horizontal. The length is 10 characters.

image And in this example the orientation was set to 'v' indicating vertical. The length is 10 rows.

image

Colors

The ProgressBar has 2 colors. Like other elements that take 2 colors, such as the Button, you can specify the colors using a tuple or a dual-color-string. In both cases, the "foreground color" is the first specified. If you want a bar that has a red foreground and white background, you can set the parameter bar_color=('red', 'white') or bar_color='red on white'). The foreground color is the percent completed indicator and thus not be visible when initialized.