The thread that communicates with the application through the window's events. Simulates downloading a random number of chinks from 50 to 100-
(window:sg.Window)
| 35 | DL_THREAD_EXITNG = '-THREAD EXITING-' |
| 36 | |
| 37 | def the_thread(window:sg.Window): |
| 38 | """ |
| 39 | The thread that communicates with the application through the window's events. |
| 40 | |
| 41 | Simulates downloading a random number of chinks from 50 to 100- |
| 42 | """ |
| 43 | max_value = random.randint(50, 100) |
| 44 | window.write_event_value((THREAD_KEY, DL_START_KEY), max_value) # Data sent is a tuple of thread name and counter |
| 45 | for i in range(max_value): |
| 46 | time.sleep(.1) |
| 47 | window.write_event_value((THREAD_KEY, DL_COUNT_KEY), i) # Data sent is a tuple of thread name and counter |
| 48 | window.write_event_value((THREAD_KEY, DL_END_KEY), max_value) # Data sent is a tuple of thread name and counter |
| 49 | |
| 50 | |
| 51 | def main(): |
no test coverage detected