I am working on a simple executable which allows me to select a table element.
Currently, when i select a table element, it produces a popup notifying that i have selected the particular element
However, i wish to print the element out in the large empty space next to the table each time i select an element, however the solutions i found didn’t exactly fit what i have in mind. Is there a solution to my predicament?
import PySimpleGUI as sg
choices = ('Windows Enterprise 10','Windows Server 19','MacOS','Ubuntu','Debian')
layout = [ [sg.Text('Pick an OS')],
[sg.Listbox(choices, size=(20, 5), key='-OS-', enable_events=True)] ]
window = sg.Window('Pick an OS', layout,size=(500,200))
while True: # the event loop
event, values = window.read()
if event == sg.WIN_CLOSED:
break
if values['-OS-']: # if something is highlighted in the list
sg.popup(f"The OS you selected is: {values['-OS-'][0]}")
window.close()
2
Answers
Put another element to show the result beside your
sg.Listbox
, then update that element with value ofsg.Listbox
. Element can besg.Text
which need to split message to lines by yourself, orsg.Multiline
.