Skip to content Skip to sidebar Skip to footer

Waiting Screen While Data Is Being Extracted From An Api

I have created a Python Script to download data using an API. And I have put a simple GUI on top of it as well using PySimpleGUI. However, while the data is being downloaded, I wan

Solution 1:

Two ways easily for it, element sg.ProgressBar or simple sg.Text with different length of string, maybe , to show the state of progress.

Demo_Progress_Meters

or

enter image description here

from random import randint
import PySimpleGUI as sg

sg.theme('DarkBlue')

layout = [[sg.Text('', size=(50, 1), relief='sunken', font=('Courier', 11),
    text_color='yellow', background_color='black',key='TEXT')]]
window = sg.Window('Title', layout, finalize=True)
text = window['TEXT']
state = 0whileTrue:

    event, values = window.read(timeout=100)

    if event == sg.WINDOW_CLOSED:
        break
    state = (state+1)%51
    text.update('█'*state)

window.close()

Note: remember to use monospaced font, otherwise the length of sg.Text will be different as length of state string.

Depend on progress of job to set state of progress.

Post a Comment for "Waiting Screen While Data Is Being Extracted From An Api"