___4 years____ Python programming experience
____7 years___ Programming experience overall
____Yes______ Have used another Python GUI Framework (tkiner, Qt, etc) previously (yes/no is fine)?
I'm working with a barcode scanner which acts like a keyboard by typing a string of numbers followed by a return/enter keypress. When using Input(), this works fine. But I can't figure out how to do this with the InputText object. I don't even really need a text box at all.
And when I set the window to return keyboard events, it only returns the first number of the barcode. Is there a different object I can use?
PySimpleGUI is a GUI so there's going to be a window for example. If you want a window where the user enters text, then returning keyboard events should be returning every keypress that's made while the window has focus.
This program does not have an input box. You receive an event for every character that is typed. You can add those characters as they come in to a string to build up an entire input string.
When it detects the return key, it prints out the value you entered
import PySimpleGUI as sg
sg.change_look_and_feel('Dark Blue 3')
layout = [ [sg.Text('Type a string followed by return key')]]
window = sg.Window('Window Title', layout, return_keyboard_events=True)
my_string = ''
while True: # Event Loop
event, values = window.read()
if event in (None, 'Exit'):
break
if event == '\r':
print(f'You entered: {my_string}')
my_string = ''
else:
my_string += event
window.close()
I think the demo program above should get you what you're looking for. If not, re-open the Issue.
Most helpful comment
PySimpleGUI is a GUI so there's going to be a window for example. If you want a window where the user enters text, then returning keyboard events should be returning every keypress that's made while the window has focus.
This program does not have an input box. You receive an event for every character that is typed. You can add those characters as they come in to a string to build up an entire input string.
When it detects the return key, it prints out the value you entered