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

Function main

DemoPrograms/Demo_All_Elements.py:97–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95 return window
96
97def main():
98 window = make_window(sg.theme())
99
100 # This is an Event Loop
101 while True:
102 event, values = window.read(timeout=100)
103 # keep an animation running so show things are happening
104 if event not in (sg.TIMEOUT_EVENT, sg.WIN_CLOSED):
105 print('============ Event = ', event, ' ==============')
106 print('-------- Values Dictionary (key=value) --------')
107 for key in values:
108 print(key, ' = ',values[key])
109 if event in (None, 'Exit'):
110 print("[LOG] Clicked Exit!")
111 break
112
113 window['-GIF-IMAGE-'].update_animation(sg.DEFAULT_BASE64_LOADING_GIF, time_between_frames=100)
114 if event == 'About':
115 print("[LOG] Clicked About!")
116 sg.popup('PySimpleGUI Demo All Elements',
117 'Right click anywhere to see right click menu',
118 'Visit each of the tabs to see available elements',
119 'Output of event and values can be see in Output tab',
120 'The event and values dictionary is printed after every event', keep_on_top=True)
121 elif event == 'Popup':
122 print("[LOG] Clicked Popup Button!")
123 sg.popup("You pressed a button!", keep_on_top=True)
124 print("[LOG] Dismissing Popup!")
125 elif event == 'Test Progress bar':
126 print("[LOG] Clicked Test Progress Bar!")
127 progress_bar = window['-PROGRESS BAR-']
128 for i in range(100):
129 print("[LOG] Updating progress bar by 1 step ("+str(i)+")")
130 progress_bar.update(current_count=i + 1)
131 print("[LOG] Progress bar complete!")
132 elif event == "-GRAPH-":
133 graph = window['-GRAPH-'] # type: sg.Graph
134 graph.draw_circle(values['-GRAPH-'], fill_color='yellow', radius=20)
135 print("[LOG] Circle drawn at: " + str(values['-GRAPH-']))
136 elif event == "Open Folder":
137 print("[LOG] Clicked Open Folder!")
138 folder_or_file = sg.popup_get_folder('Choose your folder', keep_on_top=True)
139 sg.popup("You chose: " + str(folder_or_file), keep_on_top=True)
140 print("[LOG] User chose folder: " + str(folder_or_file))
141 elif event == "Open File":
142 print("[LOG] Clicked Open File!")
143 folder_or_file = sg.popup_get_file('Choose your file', keep_on_top=True)
144 sg.popup("You chose: " + str(folder_or_file), keep_on_top=True)
145 print("[LOG] User chose file: " + str(folder_or_file))
146 elif event == "Set Theme":
147 print("[LOG] Clicked Set Theme!")
148 theme_chosen = values['-THEME LISTBOX-'][0]
149 print("[LOG] User Chose Theme: " + str(theme_chosen))
150 window.close()
151 window = make_window(theme_chosen)
152 elif event == 'Edit Me':
153 sg.execute_editor(__file__)
154 elif event == 'Versions':

Callers 1

Calls 6

update_animationMethod · 0.80
draw_circleMethod · 0.80
make_windowFunction · 0.70
readMethod · 0.45
updateMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected