9
9
window = sg .Window ('Timer' , layout , size = (300 , 120 ), modal = True )
10
10
11
11
while True :
12
+
13
+ # For more details on non-blobking window events and the usage of 'timeout' parameter
14
+ # read @ https://github.com/PySimpleGUI/PySimpleGUI/issues/520
15
+ # Read with a timeout is a very good thing for your GUIs to use in a read non-blocking situation,
16
+ # if you can use them. If your device can wait for a little while, then use this kind of read.
17
+ # The longer you're able to add to the timeout value, the less CPU time you'll be taking).
18
+ # window.read(timeout=10) : This program will quickly test for user input, then deal with the hardware.
19
+ # Then it'll sleep for 10ms, while your gui is non-responsive, then it'll check in with your GUI again.
12
20
event , values = window .read (timeout = 10 )
13
21
22
+ # Close window if exit.\/close is clicked.
14
23
if event == sg .WINDOW_CLOSED or event == 'Exit' :
15
24
break
16
25
17
26
current_time = datetime .now ()
18
27
current_time = current_time .strftime ("%H:%M:%S" )
19
28
window ['text' ].update (current_time )
20
29
30
+ # Pause the timer.
21
31
if event == 'Pause' :
22
32
timer_paused = True
23
33
24
34
if timer_paused == True :
25
35
window ['text' ].update ('Timer Paused' )
26
36
37
+ # Resume the timer.
27
38
if event == 'Resume' :
28
39
timer_paused = False
29
40
window ['text' ].update (current_time )
41
+
30
42
# Finish up by removing from the screen
31
43
window .close ()
0 commit comments