PySimpleGUI/Demo_Keyboard_Realtime.py

21 lines
499 B
Python
Raw Normal View History

2018-08-20 23:00:02 +00:00
import PySimpleGUI as sg
2018-08-21 23:10:26 +00:00
with sg.FlexForm("Realtime Keyboard Test", return_keyboard_events=True, use_default_focus=False) as form:
layout = [[sg.Text("Hold down a key")],
[sg.SimpleButton("OK")]]
2018-08-20 23:00:02 +00:00
form.Layout(layout)
2018-08-21 23:10:26 +00:00
2018-08-20 23:00:02 +00:00
while True:
button, value = form.ReadNonBlocking()
2018-08-21 23:10:26 +00:00
if button == "OK":
print(button, value, "exiting")
2018-08-20 23:00:02 +00:00
break
if button is not None:
print(button)
elif value is None:
break