loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.4304698303880017","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IFB5U2ltcGxlR1VJV2ViIGFzIHNnCgoiIiIKICBUaGlzIFJlY2lwZSBkZW1vbnN0cmF0ZXM6CiAgMS4gUmVhZCB3aXRoIGEgVGltZW91dAogIDIuIFVwZGF0aW5nIGFuIEVsZW1lbnQgaW4gdGhlIHdpbmRvdwogIDMuIEhvdyBhd2Vzb21lIFB5U2ltcGxlR1VJIGlzCiIiIgpwcmludCgnU3RhcnR1cCB1cC4uLicpCnNnLkNoYW5nZUxvb2tBbmRGZWVsKCdCbGFjaycpCgpsYXlvdXQgPSBbW3NnLlRleHQoJ1N0b3B3YXRjaCcsIHNpemU9KDIwLCAyKSwganVzdGlmaWNhdGlvbj0nY2VudGVyJyldLAogICAgICAgICAgICBbc2cuVGV4dCgnJywgc2l6ZT0oMjAsIDIpLCBmb250PSgnSGVsdmV0aWNhJywgMjApLCBqdXN0aWZpY2F0aW9uPSdjZW50ZXInLCBrZXk9J19PVVRQVVRfJyldLAogICAgICAgICAgICBbc2cuVCgnICcgKiA1KSwgc2cuQnV0dG9uKCdTdGFydC9TdG9wJywgZm9jdXM9VHJ1ZSksIHNnLlF1aXQoKV1dCgp3aW5kb3cgPSBzZy5XaW5kb3coJ1J1bm5pbmcgVGltZXInLCBsYXlvdXQpCgp0aW1lcl9ydW5uaW5nID0gVHJ1ZQppID0gMAojIEV2ZW50IExvb3AKd2hpbGUgVHJ1ZToKICBpICs9IDEgKiAodGltZXJfcnVubmluZyBpcyBUcnVlKQogIGV2ZW50LCB2YWx1ZXMgPSB3aW5kb3cuUmVhZCh0aW1lb3V0PTEwKSAjIFBsZWFzZSB0cnkgYW5kIHVzZSBhIHRpbWVvdXQgd2hlbiBwb3NzaWJsZQogIGlmIGV2ZW50IGlzIE5vbmUgb3IgZXZlbnQgPT0gJ1F1aXQnOiAgIyBpZiB1c2VyIGNsb3NlZCB0aGUgd2luZG93IHVzaW5nIFggb3IgY2xpY2tlZCBRdWl0IGJ1dHRvbgogICAgICBicmVhawogIGVsaWYgZXZlbnQgPT0gJ1N0YXJ0L1N0b3AnOgogICAgICB0aW1lcl9ydW5uaW5nID0gbm90IHRpbWVyX3J1bm5pbmcKICB3aW5kb3cuRmluZEVsZW1lbnQoJ19PVVRQVVRfJykuVXBkYXRlKCd7OjAyZH06ezowMmR9Lns6MDJkfScuZm9ybWF0KChpIC8vIDEwMCkgLy8gNjAsIChpIC8vIDEwMCkgJSA2MCwgaSAlIDEwMCkpCgp3aW5kb3cuQ2xvc2UoKSAgICMgYmUgc3VyZSBhbmQgY2xvc2UgdGhlIHdpbmRvdyBzbyB0aGUgc2VydmVyIHN0b3Bz"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import PySimpleGUIWeb as sg

"""
  This Recipe demonstrates:
  1. Read with a Timeout
  2. Updating an Element in the window
  3. How awesome PySimpleGUI is
"""
print('Startup up...')
sg.ChangeLookAndFeel('Black')

layout = [[sg.Text('Stopwatch', size=(20, 2), justification='center')],
            [sg.Text('', size=(20, 2), font=('Helvetica', 20), justification='center', key='_OUTPUT_')],
            [sg.T(' ' * 5), sg.Button('Start/Stop', focus=True), sg.Quit()]]

window = sg.Window('Running Timer', layout)

timer_running = True
i = 0
# Event Loop
while True:
  i += 1 * (timer_running is True)
  event, values = window.Read(timeout=10) # Please try and use a timeout when possible
  if event is None or event == 'Quit':  # if user closed the window using X or clicked Quit button
      break
  elif event == 'Start/Stop':
      timer_running = not timer_running
  window.FindElement('_OUTPUT_').Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))

window.Close()   # be sure and close the window so the server stops