AK Python
1.86K subscribers
39 photos
2 videos
11 files
236 links
Join here to unlock your programming ability
Download Telegram
import PySimpleGUI as sg
import time

# Basic timer in PSG

def Timer():
sg.theme('DarkAmber')

gui= [[sg.Text(size=(24, 10), font=('Bahnschrift ', 20),
justification='center', key='text')],
[sg.Button('Pause', key='-RUN-PAUSE-'),
sg.Button('Reset'),
sg.Exit(button_color=('white', 'firebrick4'))]]
window = sg.Window('AK Timer', gui,
no_titlebar=False, auto_size_buttons=True)

#logic started
i = 0
paused = False
start_time = int(round(time.time() * 100))

while True:
# This is the code that reads and updates your window
button, values = window.read(timeout=10)
window['text'].update('{:02d}:{:02d}.{:02d}'.format(
(i // 100) // 60, (i // 100) % 60, i % 100))

#conditions

if values is None or button == 'Exit':
break

if button == 'Reset':
i = 0

elif button == '-RUN-PAUSE-':
paused = not paused
window['-RUN-PAUSE-'].update('Run' if paused else 'Pause')

if not paused:
i += 1

window.close()

Timer()
👍1