()
| 24 | window.metadata = new_size # Store the new subsample value as the Window's metadata |
| 25 | |
| 26 | def main(): |
| 27 | |
| 28 | base64_digits = {'0':i0, '1':i1, '2':i2, '3':i3, '4':i4, '5':i5, '6':i6, '7':i7, '8':i8, '9':i9, ':':colon, ' ':blank, '.':dot} |
| 29 | |
| 30 | subsample = sg.user_settings_get_entry('-subsample-', 2) |
| 31 | location =sg.user_settings_get_entry('-location-', (None, None)) |
| 32 | alpha = sg.user_settings_get_entry('-alpha-', 0.9) |
| 33 | menu_sizes[subsample-1] = sg.SYMBOL_CHECK_SMALL + menu_sizes[subsample-1] |
| 34 | right_click_menu = [[''], ['Version', 'Edit Me', 'Save Location', 'Size', menu_sizes, 'Alpha', [str(x) for x in range(1, 11)], 'Exit', ]] |
| 35 | |
| 36 | layout = [[sg.Image(blank, key=('-IMAGE-', i), p=0, subsample=subsample) for i in range(max_digits)]] |
| 37 | |
| 38 | window = sg.Window('', layout, background_color='black', no_titlebar=True, grab_anywhere=True, right_click_menu=right_click_menu, location=location, keep_on_top=True, enable_close_attempted_event=True, alpha_channel=alpha, metadata=subsample) |
| 39 | |
| 40 | while True: |
| 41 | event, values = window.read(timeout=300) |
| 42 | if event in (sg.WIN_CLOSED, 'Exit', sg.WIN_CLOSE_ATTEMPTED_EVENT): |
| 43 | if event != sg.WIN_CLOSED: |
| 44 | sg.user_settings_set_entry('-location-', window.current_location()) |
| 45 | break |
| 46 | # Update the Image Elements with current time |
| 47 | date = datetime.datetime.now() |
| 48 | time_string = f'{date:%I}:{date:%M}:{date:%S}' |
| 49 | subsample = window.metadata |
| 50 | for i, c in enumerate(time_string): |
| 51 | window[('-IMAGE-', i)].update(base64_digits[c], subsample=subsample) |
| 52 | |
| 53 | # Process the event |
| 54 | if event == sg.TIMEOUT_EVENT: # if a timeout, then do nothing (saves a TINY amount of time not checking all the if statements...) |
| 55 | pass |
| 56 | elif event == 'Edit Me': |
| 57 | sg.execute_editor(__file__) |
| 58 | elif event.startswith('Version'): |
| 59 | sg.popup_scrolled(sg.get_versions(), non_blocking=True, keep_on_top=True, grab_anywhere=False, location=window.current_location()) |
| 60 | elif event in [str(x) for x in range(1,11)]: # Alpha channel selected |
| 61 | window.set_alpha(int(event)/10) |
| 62 | sg.user_settings_set_entry('-alpha-', int(event)/10) |
| 63 | elif event.endswith('Small'): # Size changed to Small |
| 64 | right_click_meny_new_size(window, 3) |
| 65 | elif event.endswith('Medium'): # Size changed to Medium |
| 66 | right_click_meny_new_size(window, 2) |
| 67 | elif event.endswith('Large'): # Size changed to Large |
| 68 | right_click_meny_new_size(window, 1) |
| 69 | elif event == 'Save Location': # Gernally not neeeded since save on exit, but may make user feel better |
| 70 | sg.user_settings_set_entry('-location-', window.current_location()) |
| 71 | |
| 72 | window.close() |
| 73 | |
| 74 | if __name__ == '__main__': |
| 75 |
no test coverage detected