I want to use `for` to update a text using PySimpleGUI (Python)

Viewed 517

I want to use a for-loop to update a text using PySimpleGUI (Python) but it just updates the text to the last word of the array.

This is my code:

from time import sleep
import PySimpleGUI as sg

sg.theme('dark grey 9')

layout = [[sg.Input(key='paragrafo')],
          [sg.Text(size=(0,1), key='text', font=('Verdana', 20), visible=False)],
          [sg.Button('Start', size=(39,1), key='start')]
          ]

window = sg.Window('Fast reader', layout)

while True:
    event, values = window.read()
    if event == sg.WINDOW_CLOSED:
        break
    paragraf = values['paragrafo']
    paragrafo = paragraf.split()
    window['text'].update(visible=True)
    window['start'].update(visible=False)
    window['paragrafo'].update(visible=False)
    for i in range(0, len(paragrafo)):
        sleep(0.08)
        window['text'].update(paragrafo[i])

window.close()
0 Answers
Related