| 7 | |
| 8 | def counter_label(label): |
| 9 | def count(): |
| 10 | if running: |
| 11 | global counter |
| 12 | # To manage the intial delay. |
| 13 | if counter == 0: |
| 14 | display = 'Ready!' |
| 15 | else: |
| 16 | tt = datetime.utcfromtimestamp(counter) |
| 17 | string = tt.strftime('%H:%M:%S') |
| 18 | display = string |
| 19 | |
| 20 | label['text'] = display |
| 21 | |
| 22 | # label.after(arg1, arg2) delays by |
| 23 | # first argument given in milliseconds |
| 24 | # and then calls the function given as second argument. |
| 25 | # Generally like here we need to call the |
| 26 | # function in which it is present repeatedly. |
| 27 | # Delays by 1000ms=1 seconds and call count again. |
| 28 | label.after(1000, count) |
| 29 | counter += 1 |
| 30 | |
| 31 | # Triggering the start of the counter. |
| 32 | count() |
| 33 | |
| 34 | |