I am learning PySimpleGui by referring the tutorials at
I need to add buttons to my layout to enter a value, then display the value in adjoining textbox
So far, i have been able to create the buttons and the textboxes.
Following is my code:-
import PySimpleGUI as sg
layout = [[sg.Text('Enter Value:')],
[sg.Input(do_not_clear=False), sg.Text('Value selected is:'), sg.Text(sg.InputText(""), key='_USERNAME_')],
[sg.Button('Enter'), sg.Exit()],
[sg.Text('List Of Values:')],
[sg.Listbox(values=('value1', 'value2', 'value3'), size=(30, 2), key='_LISTBOX_')]]
window = sg.Window('My Application', layout)
while True:
event, values = window.Read()
print(event, values)
if event is None or event == 'Exit':
break
if event == 'Enter':
window.Element('_LISTBOX_').Update(values=[event, values, 'new value 3'])
#window.Element('_USERNAME_').Update(values=[values]) #need to update the text box with value entered
window.Close()
However, i am not able to display the entered value in the text box. I have added a comment in the code (which gives an error for now) where i need to update the text box with entered value.
Please help!
Edit: I was able to display the value in a popup, but i need to display in the text box