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

Function custom_meter_example

DemoPrograms/Demo_Progress_Meters.py:146–164  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144
145
146def custom_meter_example():
147 # layout the form
148 layout = [[sg.Text('A typical custom progress meter')],
149 [sg.ProgressBar(1, orientation='h', size=(20, 20), key='progress')],
150 [sg.Cancel()]]
151
152 # create the form`
153 window = sg.Window('Custom Progress Meter', layout)
154 progress_bar = window['progress']
155 # loop that would normally do something useful
156 for i in range(10000):
157 # check to see if the cancel button was clicked and exit loop if clicked
158 event, values = window.read(timeout=0)
159 if event == 'Cancel' or event == None:
160 break
161 # update bar with loop value +1 so that bar eventually reaches the maximum
162 progress_bar.update_bar(i+1, 10000)
163 # done with loop... need to destroy the window as it's still open
164 window.close()
165
166
167'''

Callers 1

Calls 3

readMethod · 0.95
closeMethod · 0.95
update_barMethod · 0.80

Tested by

no test coverage detected