Merge branch 'master' into Dev-latest
This commit is contained in:
commit
3b9850ed39
|
@ -1,26 +1,23 @@
|
|||
import sys
|
||||
import PySimpleGUI as sg
|
||||
|
||||
# Recipe for getting keys, one at a time as they are released
|
||||
# If want to use the space bar, then be sure and disable the "default focus"
|
||||
|
||||
with sg.FlexForm('Realtime Keyboard Test', return_keyboard_events=True, use_default_focus=False) as form:
|
||||
text_elem = sg.Text('', size=(12,1))
|
||||
layout = [[sg.Text('Press a key')],
|
||||
with sg.FlexForm("Keyboard Test", return_keyboard_events=True, use_default_focus=False) as form:
|
||||
text_elem = sg.Text("", size=(18,1))
|
||||
layout = [[sg.Text("Press a key or scroll mouse")],
|
||||
[text_elem],
|
||||
[sg.SimpleButton('OK')]]
|
||||
[sg.SimpleButton("OK")]]
|
||||
|
||||
form.Layout(layout)
|
||||
# ---===--- Loop taking in user input --- #
|
||||
while True:
|
||||
button, value = form.Read()
|
||||
button, value = form.ReadNonBlocking()
|
||||
|
||||
if button == 'OK':
|
||||
print(button, 'exiting')
|
||||
if button == "OK" or (button is None and value is None):
|
||||
print(button, "exiting")
|
||||
break
|
||||
if button is not None:
|
||||
text_elem.Update(button)
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
import PySimpleGUI as sg
|
||||
|
||||
# Recipe for getting a continuous stream of keys when using a non-blocking form
|
||||
# If want to use the space bar, then be sure and disable the "default focus"
|
||||
|
||||
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')]]
|
||||
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")]]
|
||||
|
||||
form.Layout(layout)
|
||||
# ---===--- Loop taking in user input --- #
|
||||
|
||||
while True:
|
||||
button, value = form.ReadNonBlocking()
|
||||
|
||||
if button == 'OK':
|
||||
print(button, value, 'exiting')
|
||||
if button == "OK":
|
||||
print(button, value, "exiting")
|
||||
break
|
||||
if button is not None:
|
||||
print(button)
|
||||
|
|
|
@ -37,6 +37,8 @@ import fitz
|
|||
import PySimpleGUI as sg
|
||||
from binascii import hexlify
|
||||
|
||||
sg.ChangeLookAndFeel('GreenTan')
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
rc, fname = sg.GetFileBox('PDF Browser', 'PDF file to open', file_types=(("PDF Files", "*.pdf"),))
|
||||
if rc is False:
|
||||
|
@ -126,7 +128,7 @@ while True:
|
|||
if button is None:
|
||||
continue
|
||||
|
||||
if button in ("Escape:27"): # this spares me a 'Quit' button!
|
||||
if button in ("Escape:27",): # this spares me a 'Quit' button!
|
||||
break
|
||||
# print("hex(button)", hexlify(button.encode()))
|
||||
if button[0] == chr(13): # surprise: this is 'Enter'!
|
||||
|
|
Loading…
Reference in New Issue