()
| 105 | |
| 106 | |
| 107 | def main(): |
| 108 | |
| 109 | layout = [ [sg.Text('My Simulated Data Pump')], |
| 110 | [sg.Multiline(size=(60, 20), k='-MLINE-')], |
| 111 | [sg.Graph(gsize, (0, 0), gsize, k='-G-', background_color='gray')], |
| 112 | [sg.Button('Go'), sg.Button('Exit')] ] |
| 113 | |
| 114 | window = sg.Window('Simulated Data Pump', layout, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_EXIT) |
| 115 | |
| 116 | graph = window['-G-'] # type: sg.Graph |
| 117 | |
| 118 | while True: # Event Loop |
| 119 | event, values = window.read() |
| 120 | # print(event, values) |
| 121 | if event == sg.WIN_CLOSED or event == 'Exit': |
| 122 | break |
| 123 | if event == 'Go': |
| 124 | window.start_thread(lambda: the_thread(window, thread_queue), (THREAD_KEY, THREAD_EXITNG)) |
| 125 | window.start_thread(lambda: external_thread(thread_queue), (THREAD_KEY, THREAD_EXTERNAL_EXITNG)) |
| 126 | # Events coming from the Thread |
| 127 | elif event[0] == THREAD_KEY: |
| 128 | if event[1] == THREAD_INCOMING_DATA: |
| 129 | point, radius = values[event] |
| 130 | graph.draw_circle(point, radius=radius, fill_color='green') |
| 131 | window['-MLINE-'].print(f'Drawing at {point} radius {radius}', c='white on red') |
| 132 | elif event[1] == THREAD_EXITNG: |
| 133 | window['-MLINE-'].print('Thread has exited') |
| 134 | elif event[1] == THREAD_EXTERNAL_EXITNG: |
| 135 | window['-MLINE-'].print('Data Pump thread has exited') |
| 136 | if event == 'Edit Me': |
| 137 | sg.execute_editor(__file__) |
| 138 | elif event == 'Version': |
| 139 | sg.popup_scrolled(__file__, sg.get_versions(), location=window.current_location(), keep_on_top=True, non_blocking=True) |
| 140 | |
| 141 | window.close() |
| 142 | |
| 143 | if __name__ == '__main__': |
| 144 | main() |
no test coverage detected