'time library not working with PySimpleGUI
here is the code:
import PySimpleGUI as pg
import time as tm
import numpy as np
num = 0
layout = [
[pg.Text('0', key='-txt')],
[pg.Button('Start')],
]
timer_nums = np.arange(0.1, 1, .1)
win = pg.Window('Stopwatch', layout)
while True:
e, v = win.read()
if e == pg.WIN_CLOSED:
break
if e == 'Start':
tm.sleep(.14)
for i in timer_nums:
win['-txt'].update(round(i, 3))
print(round(i, 3))
tm.sleep(.1)
win.close()
So I'm trying to use the tm.sleep() to delay the count on a stopwatch. But each time i run the program the gui freezes, so i have the print function in so i can see the console telling me it's working right but the gui won't update txt until the for loop finishes. Which kinda defeats the purpose of the program lol. Please help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
