Defines the layout and creates the window for the main window If the parm test_window is True, then a simplified, and EASY to close version is shown :param location: (x,y) location to create the window :type location: Tuple[int, int] :param test_window: If True, then this is a
(location, test_window=False)
| 85 | return None |
| 86 | |
| 87 | def make_window(location, test_window=False): |
| 88 | """ |
| 89 | Defines the layout and creates the window for the main window |
| 90 | If the parm test_window is True, then a simplified, and EASY to close version is shown |
| 91 | |
| 92 | :param location: (x,y) location to create the window |
| 93 | :type location: Tuple[int, int] |
| 94 | :param test_window: If True, then this is a test window & will close by clicking on it |
| 95 | :type test_window: bool |
| 96 | :return: newly created window |
| 97 | :rtype: sg.Window |
| 98 | """ |
| 99 | title = sg.user_settings_get_entry('-title-', '') |
| 100 | if not test_window: |
| 101 | theme = sg.user_settings_get_entry('-theme-', THEME) |
| 102 | sg.theme(theme) |
| 103 | |
| 104 | # ------------------- Window Layout ------------------- |
| 105 | # If this is a test window (for choosing theme), then uses some extra Text Elements to display theme info |
| 106 | # and also enables events for the elements to make the window easy to close |
| 107 | if test_window: |
| 108 | top_elements = [[sg.Text(title, size=(20, 1), font=title_font, justification='c', k='-TITLE-', enable_events=True)], |
| 109 | [sg.Text('Click to close', font=title_font, enable_events=True)], |
| 110 | [sg.Text('This is theme', font=title_font, enable_events=True)], |
| 111 | [sg.Text(sg.theme(), font=title_font, enable_events=True)]] |
| 112 | right_click_menu = [[''], ['Exit',]] |
| 113 | else: |
| 114 | top_elements = [[sg.Text(title, size=(20, 1), font=title_font, justification='c', k='-TITLE-')]] |
| 115 | right_click_menu = [[''], ['Choose Title', 'Edit Me', 'New Theme', 'Save Location', 'Refresh', 'Set Refresh Rate', 'Show Refresh Info', 'Hide Refresh Info', 'Alpha', [str(x) for x in range(1, 11)], 'Exit', ]] |
| 116 | |
| 117 | layout = top_elements + \ |
| 118 | [[sg.Text('0', size=main_info_size, font=main_info_font, k='-MAIN INFO-', justification='c', enable_events=test_window)], |
| 119 | [sg.pin(sg.Text(size=(15, 2), font=refresh_font, k='-REFRESHED-', justification='c', visible=sg.user_settings_get_entry('-show refresh-', True)))]] |
| 120 | |
| 121 | # ------------------- Window Creation ------------------- |
| 122 | return sg.Window('Desktop Widget Template', layout, location=location, no_titlebar=True, grab_anywhere=True, margins=(0, 0), element_justification='c', |
| 123 | element_padding=(0, 0), alpha_channel=sg.user_settings_get_entry('-alpha-', ALPHA), finalize=True, right_click_menu=right_click_menu, keep_on_top=True) |
| 124 | |
| 125 | |
| 126 | def main(location): |
no outgoing calls
no test coverage detected