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

Function CustomMeter

DemoPrograms/Demo_Machine_Learning.py:57–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55
56
57def CustomMeter():
58 # layout the form
59 layout = [[sg.Text('A custom progress meter')],
60 [sg.ProgressBar(1000, orientation='h',
61 size=(20, 20), key='progress')],
62 [sg.Cancel()]]
63
64 # create the form`
65 window = sg.Window('Custom Progress Meter', layout)
66 progress_bar = window['progress']
67 # loop that would normally do something useful
68 for i in range(1000):
69 # check to see if the cancel button was clicked and exit loop if clicked
70 event, values = window.read(timeout=0, timeout_key='timeout')
71 if event == 'Cancel' or event == None:
72 break
73 # update bar with loop value +1 so that bar eventually reaches the maximum
74 progress_bar.update_bar(i+1)
75 # done with loop... need to destroy the window as it's still open
76 window.CloseNonBlocking()
77
78
79if __name__ == '__main__':

Callers 1

Calls 2

readMethod · 0.95
update_barMethod · 0.80

Tested by

no test coverage detected