()
| 44 | return sg.Window('Window Title', layout, element_justification='c', icon=icon) |
| 45 | |
| 46 | def main(): |
| 47 | |
| 48 | menu_def = ['UNUSED', ['Show','Hide','Exit']] |
| 49 | |
| 50 | tray = sg.SystemTray(menu=menu_def, data_base64=icon) |
| 51 | window = make_a_window() |
| 52 | start, current, paused = time_as_int(), 0, True |
| 53 | |
| 54 | while True: |
| 55 | event = tray.read(timeout=100) |
| 56 | if event == 'Exit': |
| 57 | break |
| 58 | elif event in('Show', sg.EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED) and not window: |
| 59 | print('Showing a new window') |
| 60 | window, paused = make_a_window(), True |
| 61 | elif event == 'Hide' and window: |
| 62 | window.close() |
| 63 | window = None |
| 64 | |
| 65 | if window: |
| 66 | event, values = window.read(timeout=1000) |
| 67 | if event in (sg.WIN_CLOSED, 'Minimize\nTo Tray'): |
| 68 | print('Minimizing to tray') |
| 69 | tray.show_message('Minimizing', 'Minimizing to Tray') |
| 70 | window.close() |
| 71 | window = None |
| 72 | continue |
| 73 | elif event == 'Start': |
| 74 | start, paused = time_as_int(), False |
| 75 | if not paused: |
| 76 | remaining = delay_time - (time_as_int() - start) |
| 77 | if remaining < 0: |
| 78 | tray.show_message('Look away', 'It is time to look away for 20 seconds') |
| 79 | start = time_as_int() |
| 80 | else: |
| 81 | window['-OUT-'].update(f'{remaining//60%60:2}:{remaining%60:02}') |
| 82 | tray.close() |
| 83 | if window: |
| 84 | window.close() |
| 85 | |
| 86 | |
| 87 | main() |
no test coverage detected