MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / periodic_timer_thread

Function periodic_timer_thread

DemoPrograms/Demo_Timer_Periodic.py:60–78  ·  view source on GitHub ↗

Thread that sends messages to the GUI after some interval of time :param window: Window the events will be sent to :type window: sg.Window :param interval: How frequently to send an event :type interval: float :param timer_id: A timer identifier :type timer_id: i

(window, interval, timer_id)

Source from the content-addressed store, hash-verified

58
59
60def periodic_timer_thread(window, interval, timer_id):
61 """
62 Thread that sends messages to the GUI after some interval of time
63
64 :param window: Window the events will be sent to
65 :type window: sg.Window
66 :param interval: How frequently to send an event
67 :type interval: float
68 :param timer_id: A timer identifier
69 :type timer_id: int
70 """
71
72
73 while True:
74 time.sleep(interval) # sleep until time to send a timer event
75 window.write_event_value(('-THREAD-', '-TIMER EVENT-'), timer_id)
76 if not timer_is_running(timer_id): # If timer has been stopped, delete it and return from thread
77 timer_status_change(timer_id, delete=True)
78 return
79
80
81def main():

Callers 1

mainFunction · 0.85

Calls 3

timer_is_runningFunction · 0.85
timer_status_changeFunction · 0.85
write_event_valueMethod · 0.80

Tested by

no test coverage detected