Skip to content

Instantly share code, notes, and snippets.

@thepycoder
Created April 25, 2022 07:47
Show Gist options
  • Save thepycoder/77673f1b3b847c07479f5835647bc448 to your computer and use it in GitHub Desktop.
Save thepycoder/77673f1b3b847c07479f5835647bc448 to your computer and use it in GitHub Desktop.
PySimpleGUI code for pushup lockscreen
class PushupLockscreen:
def __init__(self):
sg.theme('Black')
# define the window layout
layout = [
[
sg.Column(
[[sg.Image(filename='', key='image')]]
),
sg.Column(
[
[sg.Button('0', key='counter', size=(10, 3), font='Helvetica 45')],
[sg.Button('N/A', key='primed', size=(10, 2), font='Helvetica 30')],
[sg.Button('N/A', key='class', size=(10, 2), font='Helvetica 30')]
]
)
]
]
# create the window and show it without the plot
self.window = sg.Window('Pushup Lockscreen', layout, no_titlebar=True, location=(0, 0), size=(800, 600))
# ....
def update_gui(self, frame, prediction):
# Print or plot prediction
imgbytes = cv2.imencode('.png', frame)[1].tobytes()
self.window['counter'].update(self.counter.count)
if self.counter.primed:
primed_text = "ACTIVE"
primed_color = GREEN
else:
primed_text = "INACTIVE"
primed_color = RED
if prediction == 0:
button_color = WHITE
prediction_text = "NO PRSN"
elif prediction == 1:
button_color = RED
prediction_text = 'DOWN'
else:
button_color = GREEN
prediction_text = 'UP'
# Actual updates
self.window['primed'].update(primed_text, button_color=primed_color)
self.window['class'].update(prediction_text, button_color=button_color)
self.window['image'].update(data=imgbytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment