()
| 55 | |
| 56 | |
| 57 | def 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 | |
| 79 | if __name__ == '__main__': |
no test coverage detected