MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / main

Function main

DemoPrograms/Demo_Desktop_Widget_Postit.py:36–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34# ----- Make sure it doesn't get any smaller than it is initially -----
35
36def main():
37 loc = sg.user_settings_get_entry('-location-', (None, None))
38 window = make_window(loc)
39
40 while True: # Event Loop
41 event, values = window.read()
42 print(event, values)
43 if event in (sg.WIN_CLOSED, 'Exit'):
44 if event == 'Exit':
45 sg.user_settings_set_entry('-location-', window.current_location())
46 break
47 if event == 'Edit Me':
48 sg.execute_editor(__file__)
49 elif event == 'Change Font':
50 font = sg.popup_get_text('Main Information Font and Size (e.g. courier 70)', default_text=sg.user_settings_get_entry('-font-'), keep_on_top=True, location=window.current_location())
51 if font:
52 sg.user_settings_set_entry('-font-', font)
53 loc = window.current_location()
54 window.close()
55 window = make_window(loc)
56 elif event in [str(x) for x in range(1,11)]:
57 window.set_alpha(int(event)/10)
58 sg.user_settings_set_entry('-alpha-', int(event)/10)
59 elif event == 'Choose Title':
60 new_title = sg.popup_get_text('Choose a title for your date', default_text=sg.user_settings_get_entry('-title-', 'Postit'), location=window.current_location(), keep_on_top=True)
61 if new_title is not None:
62 window['-TITLE-'].update(new_title)
63 sg.user_settings_set_entry('-title-', new_title)
64 sg.user_settings_set_entry('-text-', window['-ML-'].get().rstrip())
65
66 window.close()
67
68
69if __name__ == '__main__':

Callers 1

Calls 7

current_locationMethod · 0.80
set_alphaMethod · 0.80
make_windowFunction · 0.70
readMethod · 0.45
closeMethod · 0.45
updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected